Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added warden-gas-forecaster example to Agent-Kit-Examples #7

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
21 changes: 21 additions & 0 deletions warden-gas-forecaster/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2025 AlchemistAction

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
95 changes: 95 additions & 0 deletions warden-gas-forecaster/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# **AI Gas Price Forecaster** 🚀
An AI-powered gas price prediction tool that fetches real-time Ethereum gas prices and predicts future values using OpenAI. This project features a **Node.js backend** and an **Angular frontend**.
## **📌 Features**
✨ Fetches real-time Ethereum gas prices
🤖 Predicts future prices with AI (using OpenAI)
📊 Displays live vs predicted gas prices on a graph
🔗 Seamless combination of a robust backend and an interactive frontend
🚀 Easily deployable on **Railway**, **Heroku**, or **Fly.io**
## **🚀 How to Run Locally**
### 1️⃣ Clone the Repository
``` bash
git clone https://github.com/yourusername/warden-gas-forecaster.git
cd warden-gas-forecaster
```
### 2️⃣ Set Up the Backend (requires nvm 18+)
``` bash
npm install
```
Create a `.env` file inside the `backend/` root directory with the following values:
``` ini
OPENAI_API_KEY=your_openai_key
PRIVATE_KEY=your_warden_private_key
```
Start the backend server:
``` bash
node src/index.js
```
✅ **You should see**:
``` bash
✅ Server running at http://localhost:3000
```
### 3️⃣ Set Up the Frontend
``` bash
cd frontend
npm install
```
Update the API URL in `frontend/src/environments/environment.ts`:
``` typescript
export const environment = {
production: false,
apiUrl: 'http://localhost:3000'
};
```
Start the frontend:
``` bash
npm start
```
🌐 **The app will open in your browser at**:
```
http://localhost:4200
```
## **🌍 API Endpoints**

| **Method** | **Endpoint** | **Description** |
| --- | --- | --- |
| GET | /gas-prices | Returns real-time and predicted gas prices |
### **📋 Example Response:**
``` json
{
"real": [
{ "timestamp": "2025-02-09T16:59:01.123Z", "price": 2654.61 },
{ "timestamp": "2025-02-09T16:59:11.456Z", "price": 2654.81 }
],
"predicted": [
{ "timestamp": "2025-02-09T16:59:02.789Z", "price": 2653.97 },
{ "timestamp": "2025-02-09T16:59:32.123Z", "price": 2654.55 }
]
}
```
## **🎯 Project Structure**
``` plaintext
warden-gas-forecaster/
│── backend/
│ ├── src/
│ │ ├── server.js # Express backend
│ │ ├── agent.js # AI prediction logic
│ │ ├── services/ # Supporting services
│ │ ├── utils/ # Helper utilities
│ ├── package.json
│ ├── .env
│── frontend/
│ ├── src/
│ │ ├── app/
│ │ │ ├── gas-chart/ # Angular chart component
│ │ │ ├── app.module.ts # Angular module
│ ├── package.json
│── README.md
```
## **🔥 Deployment**
You can deploy this project on **Railway**, **Heroku**, or **Fly.io**.
Follow the detailed steps in the [`DEPLOYMENT.md`](./DEPLOYMENT.md) file.
## **📜 Future Improvements**
✅ Refactor app to show gas fee instead of actual ETH price.
✅ Enhance UI with dark/light mode toggle
✅ Integrate database support to store historical prices
17 changes: 17 additions & 0 deletions warden-gas-forecaster/frontend/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Editor configuration, see https://editorconfig.org
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true

[*.ts]
quote_type = single
ij_typescript_use_double_quotes = false

[*.md]
max_line_length = off
trim_trailing_whitespace = false
42 changes: 42 additions & 0 deletions warden-gas-forecaster/frontend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# See https://docs.github.com/get-started/getting-started-with-git/ignoring-files for more about ignoring files.

# Compiled output
/dist
/tmp
/out-tsc
/bazel-out

# Node
/node_modules
npm-debug.log
yarn-error.log

# IDEs and editors
.idea/
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# Visual Studio Code
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
.history/*

# Miscellaneous
/.angular/cache
.sass-cache/
/connect.lock
/coverage
/libpeerconnection.log
testem.log
/typings

# System files
.DS_Store
Thumbs.db
4 changes: 4 additions & 0 deletions warden-gas-forecaster/frontend/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=827846
"recommendations": ["angular.ng-template"]
}
20 changes: 20 additions & 0 deletions warden-gas-forecaster/frontend/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "ng serve",
"type": "chrome",
"request": "launch",
"preLaunchTask": "npm: start",
"url": "http://localhost:4200/"
},
{
"name": "ng test",
"type": "chrome",
"request": "launch",
"preLaunchTask": "npm: test",
"url": "http://localhost:9876/debug.html"
}
]
}
42 changes: 42 additions & 0 deletions warden-gas-forecaster/frontend/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
// For more information, visit: https://go.microsoft.com/fwlink/?LinkId=733558
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "start",
"isBackground": true,
"problemMatcher": {
"owner": "typescript",
"pattern": "$tsc",
"background": {
"activeOnStart": true,
"beginsPattern": {
"regexp": "(.*?)"
},
"endsPattern": {
"regexp": "bundle generation complete"
}
}
}
},
{
"type": "npm",
"script": "test",
"isBackground": true,
"problemMatcher": {
"owner": "typescript",
"pattern": "$tsc",
"background": {
"activeOnStart": true,
"beginsPattern": {
"regexp": "(.*?)"
},
"endsPattern": {
"regexp": "bundle generation complete"
}
}
}
}
]
}
59 changes: 59 additions & 0 deletions warden-gas-forecaster/frontend/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Frontend

This project was generated using [Angular CLI](https://github.com/angular/angular-cli) version 19.1.6.

## Development server

To start a local development server, run:

```bash
ng serve
```

Once the server is running, open your browser and navigate to `http://localhost:4200/`. The application will automatically reload whenever you modify any of the source files.

## Code scaffolding

Angular CLI includes powerful code scaffolding tools. To generate a new component, run:

```bash
ng generate component component-name
```

For a complete list of available schematics (such as `components`, `directives`, or `pipes`), run:

```bash
ng generate --help
```

## Building

To build the project run:

```bash
ng build
```

This will compile your project and store the build artifacts in the `dist/` directory. By default, the production build optimizes your application for performance and speed.

## Running unit tests

To execute unit tests with the [Karma](https://karma-runner.github.io) test runner, use the following command:

```bash
ng test
```

## Running end-to-end tests

For end-to-end (e2e) testing, run:

```bash
ng e2e
```

Angular CLI does not come with an end-to-end testing framework by default. You can choose one that suits your needs.

## Additional Resources

For more information on using the Angular CLI, including detailed command references, visit the [Angular CLI Overview and Command Reference](https://angular.dev/tools/cli) page.
Loading