v2.3 โ€” x402 Payment Gateway Live

Connect any AI Agent
to Base Chain DeFi

Check balances, swap tokens, track pools, analyze wallets, monitor prices โ€” all through natural language. The first production-ready MCP server for Base.

โšก See All 14 Tools ๐Ÿ“– Quick Start GitHub โ†’
14
MCP Tools
3
Revenue Tiers
$0.001
Per Call (x402)
10
Free Calls/Day

โšก Quick Start

One command. Your AI agent has access to Base Chain.

$ pip install -r requirements.txt && python server.py
# Or via Docker:
$ docker build -t defai-gateway . && docker run --rm defai-gateway

๐Ÿ› ๏ธ All 14 Tools

From basic balance checks to full swap execution. Three pricing tiers.

get_balance FREE
ETH + ERC-20 token balances for any wallet. Auto-detects USDC, AERO, DAI, WETH. USD estimates via CoinGecko.
โ†’ {"ETH": "1.234", "USDC": "5000.00", "AERO": "150.25"}
get_token_info FREE
Name, symbol, decimals, total supply. Links to BaseScan.
โ†’ {"name": "Aerodrome", "symbol": "AERO", "supply": "500M"}
get_gas_price FREE
Live Base gas in gwei. Estimated tx cost included.
โ†’ {"gas_price_gwei": 0.12, "tx_cost_eth": "0.00000252"}
check_allowance FREE
Check token allowance before swapping. See if approval needed.
โ†’ {"allowance": "0.00", "needs_approval": true}
build_approve_transaction FREE
Build unlimited or specific approval tx for Aerodrome Router.
โ†’ {"tx": {"to": "0x...", "data": "0x09..."}, "gas_limit": 50000}
get_pools PREMIUM
Top Aerodrome liquidity pools. Filters by TVL. 3 fallback data sources.
โ†’ {"pools": [{"AERO/WETH": "$48.2M", "APR": "14.8%"}]}
analyze_wallet PREMIUM
Full wallet breakdown: ETH, tokens, tx count, contract detection.
โ†’ {"eth": "5.2", "tokens": ["AERO", "USDC"], "txs": 142}
track_new_tokens PREMIUM
Scan Base for new token contracts. 3-tier: Blockscout โ†’ Clanker โ†’ on-chain.
โ†’ {"count": 5, "tokens": ["MOON", "STAR", ...]}
get_token_price PREMIUM
Live USD price for any token (ETH, USDC, AERO, BTC, SOL, ...).
โ†’ {"ETH": {"usd": 3200.50}}
get_recent_transactions PREMIUM
Recent wallet activity via Blockscout API. Instant, no API key needed.
โ†’ {"txs": [{"hash": "0x...", "value": "0.5 ETH"}]}
monitor_price PREMIUM
Check price + compare against target. Limit-order style monitoring.
โ†’ {"pair": "USDC/AERO", "rate": 850.5, "alert": true}
get_payment_status PREMIUM
Your tier, remaining calls, upgrade options.
โ†’ {"tier": "free", "calls_left": 7}
get_swap_quote $GATE
Live quote with price impact, route info, gas estimate.
โ†’ {"expected": "850.5 AERO", "route": "direct", "impact": "0.02%"}
build_swap_transaction $GATE
Full EIP-1559 swap tx. Multi-hop routing. Sign with any wallet.
โ†’ {"tx": {"to": "0x...", "data": "0x...", "nonce": 5, "gas": 250000}}

๐Ÿ”„ Complete Swap Flow

From check to signed transaction in 4 MCP calls.

# 1. Check allowance
$ python -c "import server; print(server.check_allowance('USDC', '0xYourWallet'))"

# 2. Build approval tx (if needed)
$ python -c "import server; print(server.build_approve_transaction('USDC', caller_address='0xYourWallet'))"

# 3. Get quote
$ python server.get_swap_quote('USDC', 'AERO', 100, caller_address='0xYourWallet')

# 4. Build swap tx
$ python server.build_swap_transaction('USDC', 'AERO', 100, slippage=0.5, caller_address='0xYourWallet')

# 5. Sign in wallet โ†’ Send โ†’ Done!

๐Ÿ’ฐ x402 Payment Gateway

AI agents pay per API call in USDC on Base. No subscription needed โ€” just send and use.

Send USDC

Send โ‰ฅ $0.01 USDC on Base to the fee wallet. Any amount works.

Verify Deposit

POST /deposit with your tx_hash. Server verifies on-chain and adds credits.

Call Tools

POST /mcp with your tool + args. Each call costs ~$0.001 USDC.

Or Go Free

10 calls/day free. $GATE holders get unlimited access.

# Start the x402 server
$ python x402_server.py --port 4020 --fee-wallet 0xYourWallet

# Check pricing & status
$ curl http://localhost:4020/pricing
$ curl http://localhost:4020/status

# Call a tool (paid)
$ curl -X POST http://localhost:4020/mcp \
  -H "Content-Type: application/json" \
  -H "X-402-Tx-Hash: 0xYourTxHash" \
  -H "X-402-Address: 0xYourWallet" \
  -d '{"tool":"get_balance","args":{"address":"0x..."}}'

๐Ÿ—๏ธ Architecture

Zero-dependency MCP server. No database. No state. Deploy anywhere.

AI Agent โ”€โ”€โ”ฌโ”€โ”€ MCP (stdio) โ”€โ”€โ†’ DeFAI Gateway โ”€โ”€โ”ฌโ”€โ”€ Base RPC (on-chain) โ”‚ โ”œโ”€โ”€ Blockscout API โ”‚ โ”œโ”€โ”€ Aerodrome API โ”‚ โ”œโ”€โ”€ CoinGecko API โ”‚ โ””โ”€โ”€ Clanker API โ”‚ โ””โ”€โ”€ HTTP (x402) โ”€โ”€โ†’ x402 Gateway โ”€โ”€โ”ฌโ”€โ”€ USDC verification โ”œโ”€โ”€ Credit ledger โ”œโ”€โ”€ /mcp, /deposit โ”œโ”€โ”€ /status, /pricing โ””โ”€โ”€ /health

๐Ÿ’ฐ Pricing

Pay per call via x402, subscribe for Pro, or hold $GATE for unlimited.

Free
$0/mo
For prototyping and exploration
  • 10 calls/day via x402 free tier
  • Balances, tokens, gas prices
  • Approval tx builder
  • Allowance checker
  • Community support
Get Started โ†’
$GATE Holder
โˆž
Unlimited + revenue share
  • Unlimited calls
  • Swap execution (EIP-1559)
  • Multi-hop routing
  • Revenue share from fees
  • Voting on protocol upgrades
Learn About $GATE โ†’

Ready to connect your AI agent to Base?

One pip install. 14 tools. Zero API keys needed for basic usage.

โญ Star on GitHub ๐Ÿ“ง Contact