Hackathon: Stablecoin Commerce Stack Challenge — Track 4: Agentic Economy Free local AI (Ollama + Llama 3) · Circle USDC · Arc L1 Testnet
An AI agent that charges $0.01 USDC per query, deducted from a Circle wallet and settled on the Arc blockchain in real time. The AI runs completely free and locally via Ollama — no OpenAI or Anthropic account needed.
# Install Ollama: https://ollama.com/download
# Then:
ollama serve # start Ollama (keep this running)
ollama pull llama3 # download Llama 3 (~4GB, one-time)git clone https://github.com/yourusername/inferpay
cd inferpay
npm install
cp .env.example .env.local
# Fill in CIRCLE_API_KEY, AGENT_WALLET_ID, AGENT_WALLET_ADDRESSnpm run dev
# Open http://localhost:3000That's it. No AI API key needed.
User → Next.js Frontend
→ POST /api/infer
→ Circle Wallets (charge $0.01 USDC on Arc)
→ InferPayAgent.sol (record payment on-chain)
→ Ollama local API (run Llama 3 inference — FREE)
→ Response + tx receipt → UI
| Variable | Required | Description |
|---|---|---|
CIRCLE_API_KEY |
✅ | From console.circle.com |
CIRCLE_BASE_URL |
✅ | https://api-sandbox.circle.com |
CIRCLE_WALLET_SET_ID |
✅ | From Circle console |
AGENT_WALLET_ID |
✅ | Treasury wallet ID |
AGENT_WALLET_ADDRESS |
✅ | Treasury wallet address |
OLLAMA_BASE_URL |
optional | Default: http://localhost:11434 |
OLLAMA_MODEL |
optional | Default: llama3 |
COST_PER_INFERENCE_USDC |
optional | Default: 0.01 |
Any model you pull with ollama pull <name> works. Recommended:
| Model | Size | Speed | Quality |
|---|---|---|---|
llama3 |
4.7GB | Fast | Great |
llama3:8b |
4.7GB | Fast | Great |
llama3:70b |
40GB | Slow | Excellent |
mistral |
4.1GB | Fast | Good |
phi3 |
2.3GB | Very fast | Good |
Change model in .env.local: OLLAMA_MODEL=mistral
- ✅ USDC — primary payment rail for per-inference charges
- ✅ Circle Wallets — developer-controlled wallets on Arc
- ✅ Circle Gateway — treasury routing
- ✅ Nanopayments — sub-cent high-frequency payment pattern
inferpay/
├── app/
│ ├── api/
│ │ ├── infer/route.js ← paid inference endpoint
│ │ ├── wallet/route.js ← wallet create/balance
│ │ ├── transactions/route.js ← tx history
│ │ └── health/route.js ← Ollama health check
│ ├── dashboard/page.jsx ← full UI with Ollama status
│ └── layout.jsx / page.jsx
├── lib/
│ ├── agent.js ← orchestrates payment + Ollama
│ ├── ollama.js ← Ollama API client
│ └── circle.js ← Circle API client
├── contracts/
│ └── InferPayAgent.sol ← Arc smart contract
└── scripts/deploy.js
# Add to .env.local:
# DEPLOYER_PRIVATE_KEY=...
# ARC_USDC_ADDRESS=...
npm install --save-dev @nomicfoundation/hardhat-toolbox
npx hardhat run scripts/deploy.js --network arc_testnet- Circle Wallets on Arc — dollar-denominated gas makes $0.01 micropayments viable. ETH gas volatility would make sub-cent pricing unpredictable.
- USDC — stable, predictable unit of account for metered AI billing.
- Nanopayments pattern — exactly right for agentic pay-per-use workloads.
- Sandbox faucet (
/v1/faucet/drips) made testnet onboarding instant - Arc's predictable fees are a genuine DX improvement over EVM chains
- Developer-controlled wallets abstract key management complexity
- Native webhooks for transfer state changes would reduce polling
- Clearer docs on Arc testnet USDC contract addresses
- A Circle CLI (like Stripe CLI) for local webhook forwarding
- Gas abstraction / sponsored transactions for USDC transfers
- A dedicated "agent wallet" tier with built-in rate limits and spending caps
MIT — built for the Stablecoin Commerce Stack Challenge hackathon.