Skip to content
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions agents/gas-estimator/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Agent Configuration
AGENT_PORT=3002
OWNER_WALLET=
GITHUB_HANDLE=dagangtj

# Webhook URL (for marketplace registration)
AGENT_WEBHOOK_URL=http://localhost:3002

# PayPol Marketplace (optional, defaults to localhost)
PAYPOL_MARKETPLACE_URL=http://localhost:3000

# Daemon wallet (optional, for on-chain operations)
DAEMON_PRIVATE_KEY=
128 changes: 128 additions & 0 deletions agents/gas-estimator/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
# Gas Estimation Agent

Multi-chain gas cost comparison agent for the PayPol marketplace. Compares real-time gas prices across **Tempo L1**, **Ethereum**, **Arbitrum**, and **Base**, helping users choose the most cost-effective chain for their transactions.

## Features

✅ **Multi-chain support**: Tempo L1, Ethereum, Arbitrum, Base
✅ **Real-time gas prices** in gwei and USD equivalent
✅ **Cost estimation** for common operations:
- Simple transfer (21k gas)
- ERC-20 transfer (65k gas)
- Contract deployment (1.5M gas)
✅ **Smart recommendations** for cheapest chain
✅ **15-second caching** for performance
✅ **RPC fallback handling** for reliability

## Quick Start

```bash
# Install dependencies
npm install

# Configure environment
cp .env.example .env
# Edit .env with your wallet address

# Start the agent
npm run dev

# Register on marketplace (optional)
npm run register
```

## Example Response

```json
{
"operation": "ERC-20 Transfer",
"estimates": [
{
"chain": "Tempo L1",
"gasPrice": "0.00 gwei",
"cost": "$0.0000",
"speed": "1s"
},
{
"chain": "Base",
"gasPrice": "0.02 gwei",
"cost": "$0.0039",
"speed": "2s"
},
{
"chain": "Arbitrum",
"gasPrice": "0.05 gwei",
"cost": "$0.0098",
"speed": "2s"
},
{
"chain": "Ethereum",
"gasPrice": "25.00 gwei",
"cost": "$4.8750",
"speed": "12s"
}
],
"recommendation": "Tempo L1 has zero gas fees with fast finality (1s). Highly recommended for cost-sensitive operations.",
"timestamp": "2026-02-27T07:45:00.000Z",
"cached": false
}
```

## Usage Examples

**Simple transfer:**
```
"What's the cheapest chain for a simple transfer?"
```

**ERC-20 transfer:**
```
"Compare gas costs for an ERC-20 token transfer"
```

**Contract deployment:**
```
"How much does it cost to deploy a contract on each chain?"
```

## Architecture

- **RPC providers**: Public endpoints with fallback support
- **Caching**: 15-second TTL to reduce RPC calls
- **Error handling**: Graceful degradation on RPC failures
- **Price oracle**: ETH/USD price for cost calculations

## Configuration

Edit `.env`:

```bash
AGENT_PORT=3002
OWNER_WALLET=0xYourWalletAddress
GITHUB_HANDLE=your-github
AGENT_WEBHOOK_URL=http://localhost:3002
```

## API Endpoints

| Method | Path | Description |
|--------|------|-------------|
| `GET` | `/manifest` | Agent metadata |
| `POST` | `/execute` | Execute gas estimation job |
| `GET` | `/health` | Health check |

## Bounty Compliance

This agent fulfills all requirements from issue #7:

- ✅ Queries gas prices from 4+ chains (Tempo, Ethereum, Arbitrum, Base)
- ✅ Returns gas costs in native units (gwei) and USD equivalent
- ✅ Estimates cost for common operations (transfer, ERC-20, deploy)
- ✅ Provides recommendation for cheapest chain
- ✅ Caches results with configurable TTL (15s)
- ✅ Handles RPC failures gracefully with fallbacks
- ✅ Registers on PayPol marketplace via SDK

## License

MIT
Loading