An intelligent agent system that generates production-ready Go code for EVM blockchain monitoring, using Groq's ultra-fast LLM inference.
The Ethereum Virtual Machine (EVM) is a decentralized runtime environment that executes smart contracts on Ethereum and 50+ compatible blockchains (Polygon, BSC, Avalanche, etc.). It enables:
- DeFi applications (trading, lending, borrowing)
- NFTs (digital ownership, marketplaces)
- DAOs (decentralized governance)
- Smart contracts (trustless, transparent code execution)
Your system monitors the EVM (read-only) - it observes blockchain activity without executing transactions.
┌─────────────────────────────────────────────────────────────────┐ │ PYTHON AGENT (Orchestrator) │ ├─────────────────────────────────────────────────────────────────┤ │ CONFIG → PLAN → GENERATE → TEST → VALIDATE → EXECUTE → FIX │ │ ↑_______________________________________________________↓ │ │ GROQ LLM | │ └─────────────────────────────────────────────────────────────────┘ │ ▼ generated/ ┌─────────────────────────────────────────────────────────────────┐ │ GO BACKEND (EVM Processor) │ ├─────────────────────────────────────────────────────────────────┤ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │ │ │ Blockchain │ │ Metrics │ │ REST API │ │ │ │ Client │→│ Collector │→│ Server │ │ │ └─────────────┘ └─────────────┘ └─────────────┘ │ │ ↓ ↓ ↓ │ │ ETH RPC TPS Calc :8080/metrics │ └─────────────────────────────────────────────────────────────────┘ │ ▼ ┌─────────────────────────────────────────────────────────────────┐ │ REACT DASHBOARD │ ├─────────────────────────────────────────────────────────────────┤ │ • Real-time Block Height • TPS (blocks/sec) │ │ • Gas Price (Gwei) • Pending Transactions │ └─────────────────────────────────────────────────────────────────┘
text
agentic-evm-processor/ ├── agent/ # Python agent (orchestrator) │ ├── core/ # Agent loop, state, Groq client │ └── stages/ # 7-stage pipeline (config → fix) ├── configs/ # YAML configuration files ├── dashboard/ # React frontend │ ├── src/ │ │ ├── App.tsx │ │ └── pages/Dashboard.tsx │ └── package.json ├── generated/ # Created by agent (not committed) │ ├── cmd/processor/ # Go main entry point │ ├── internal/ # Blockchain client, API server │ └── go.mod ├── .env # API keys (never commit) ├── .env.example # Template for API keys ├── requirements.txt # Python dependencies └── run_agent.py # Start the agent
The agent executes a 7-stage loop to generate the Go backend:
| Stage | Purpose |
|---|---|
| CONFIG | Loads agent_config.yaml and chain_config.yaml |
| PLAN | Creates build plan based on configuration |
| GENERATE | Writes Go code (blockchain client, API server, main.go) |
| TEST | Runs go test on generated code |
| VALIDATE | Checks formatting, linting, module dependencies |
| EXECUTE | Builds and runs the Go binary |
| FIX | Auto-fixes compilation errors (uses Groq) |
Once generated, the Go binary:
- Connects to Ethereum RPC endpoint (read from
.env) - Fetches real-time blockchain data:
- Current block height
- Gas price (in Gwei)
- Pending transaction count
- Calculates TPS (blocks per second)
- Exposes REST API at
:8080/api/metrics - Serves CORS-enabled endpoints for the dashboard
- Python 3.9+ (for the agent)
- Go 1.21+ (to run generated code)
- Node.js 18+ (for dashboard)
- Purpose: LLM inference for code generation
- Get it: console.groq.com (free tier available)
- Where to use:
.envfile
- Purpose: Fetch real blockchain data
- Get it: alchemy.com or infura.io (free tier)
- Where to use:
.envfile - Without it: Backend runs in mock mode (static data)
# 1. Clone and enter directory
cd agentic-coding-evm-processor
# 2. Install Python dependencies
pip install -r requirements.txt
# 3. Setup dashboard
cd dashboard && npm install && cd ..
# 4. Configure API keys
cp .env.example .env
# Edit .env and add your GROQ_API_KEY and ETH_RPC_URL
# 5. Run the agent (generates Go code for bsckend)
python run_agent.py
# 6. Start the generated Go backend
cd generated
go mod tidy
go run cmd/processor/main.go
# 7. Start the dashboard (new terminal)
cd dashboard
npm start
Dashboard Access
Dashboard: http://localhost:3000
API (served by Go): http://localhost:8080/api/metrics
Health: http://localhost:8080/api/health
Testing the API
bash
curl http://localhost:8080/api/metrics
Expected response (example):
json
{
"blockHeight": 18500000,
"transactionsPerSecond": 0.12,
"gasPrice": 35,
"pendingTransactions": 127
}
Agent Behavior
With GROQ_API_KEY: Groq s requires for intelligent code generation
With ETH_RPC_URL: Real blockchain data
Without ETH_RPC_URL: Mock blockchain data (static values)
Environment Variables
bash
# Required for agent intelligence
GROQ_API_KEY=your_groq_key
# Required for real blockchain data
ETH_RPC_URL=https://eth-mainnet.g.alchemy.com/v2/your_key
# Optional: Change default ports
DASHBOARD_PORT=3000
API_PORT=8080
Common Issues
Issue Solution
Port 8080 already in use lsof -i :8080 then kill -9 <PID>
Dashboard shows 0.0 for gas price API returning hex - check curl output
Module not found: react-scripts Run npm install in dashboard directory
go.mod file not found Agent generates it - run python run_agent.py first
Advanced: eRPC Proxy
For production deployments, consider using eRPC - an open-source proxy that aggregates multiple RPC endpoints for failover, caching, and load balancing.
License
MIT