A collection of agents that have their own wallets for transactions query data, start trading strategies. Each with their own speciality.
Agents functionalities are enriched via Providers and their premium
routes can be protected over 402.
Some providers allow for storing data offchain and syncing with data on periods, based on webhooks or cron jobs.
This is a Next.js project bootstrapped with create-onchain-agent.
It integrates Coinbase AgentKit on Base to provide AI-driven, onchain interactions.
Install dependencies:
bun installConfigure environment variables (see .env.example):
cp .env.example .envStart the dev server:
bun run devYou can customize the agent configuration. By default:
- AgentKit wiring:
app/api/agent/prepare-agentkit.ts - Agent instantiation:
app/api/agent/create-agent.ts
Choose OpenAI or Groq via environment variables and model selection in code.
AgentKit requires a Wallet Provider to interact with EVM chains. This project uses CdpSmartWalletProvider on Base (defaults to base-sepolia).
Action Providers define capabilities (wallet, ERC-20, swaps, price feeds, strategies). Built-ins plus custom providers are registered.
- AgentKit repo: https://github.com/coinbase/agentkit
- Explore Wallet Providers & Action Providers
- Extend with custom Action Providers for your use case
- CDP docs: https://docs.cdp.coinbase.com/
- AgentKit docs: https://docs.cdp.coinbase.com/agentkit/docs/welcome
- Next.js: https://nextjs.org/docs
- Tailwind CSS: https://tailwindcss.com/docs
- Contribution Guide: https://github.com/coinbase/agentkit/blob/main/CONTRIBUTING.md
- Discord: https://discord.gg/CDP
- Onchain trading assistant powered by Coinbase AgentKit on Base.
- Streams live prices via Pyth, evaluates triggers, and (optionally) executes swaps.
- Persists strategies and trigger history to local JSON files.
- Coinbase AgentKit (Base): https://github.com/coinbase/agentkit
- CDP docs: https://docs.cdp.coinbase.com
- Base network: https://www.base.org
- LLM:
OPENAI_API_KEYorGROQ_API_KEY(one required) - CDP/AgentKit:
CDP_API_KEY_ID,CDP_API_KEY_SECRET(required)CDP_WALLET_SECRET(recommended)NETWORK_ID(default:base-sepolia)PAYMASTER_URL,RPC_URL,IDEMPOTENCY_KEY(optional)
- Smart wallet cache:
wallet_data.txt(auto-created)
# --- LLM (choose one) ---
# OPENAI_API_KEY= # Get from https://platform.openai.com/api-keys
# GROQ_API_KEY= # Get from https://console.groq.com/keys
# --- Coinbase CDP / AgentKit ---
CDP_API_KEY_ID=
CDP_API_KEY_SECRET=
# Optional but recommended for managed wallet lifecycle
CDP_WALLET_SECRET=
# Network (default used by app if unset)
# Acceptable values: base, base-sepolia
NETWORK_ID=base-sepolia
# Optional advanced config
# PAYMASTER_URL=
# RPC_URL=
# IDEMPOTENCY_KEY=
# --- Convex (dev or prod) ---
# For local dev, after starting Convex with `bunx convex dev`,
# copy the printed values for URL and Site URL.
CONVEX_DEPLOYMENT=dev:your-project-slug # team: <team>, project: <project>
NEXT_PUBLIC_CONVEX_URL=
NEXT_PUBLIC_CONVEX_SITE_URL=
# --- Cambrian / Deep42 MCP ---
# Request an API key from Cambrian/Deep42 or your admin.
# See CAMBRIAN_MCP_IMPLEMENTATION.md for details.
CAMBRIAN_API_KEY=- OpenAI API key: https://platform.openai.com/api-keys
- Groq API key: https://console.groq.com/keys
- Coinbase CDP API keys: https://portal.cdp.coinbase.com/ (create a project → API Keys)
- Convex URLs: run
bunx convex devlocally to getNEXT_PUBLIC_CONVEX_URLandNEXT_PUBLIC_CONVEX_SITE_URL, or see your Convex dashboard. - Cambrian API key: see
CAMBRIAN_MCP_IMPLEMENTATION.mdor request from Cambrian/Deep42 team.
- Strategies:
data/strategies.json - Trigger history:
data/trigger_history.json
- POST
api/agent- Sends a user message to the AgentKit-powered agent and returns the final response text.
- Body:
{ "userMessage": "...", "agentId"?: "..." }→{ "response": "..." } - Code:
app/api/agent/route.ts
- GET
api/agents- Returns the list of available agents.
- Code:
app/api/agents/route.ts
- GET
api/assets- Returns wallet address and Base token balances (ETH, USDC, WETH, DAI).
- Code:
app/api/assets/route.ts
- GET
api/strategies?agentId=<id>- Returns strategies for the specified agent.
- Code:
app/api/strategies/route.ts
- PATCH
api/strategies- Updates a strategy by
idwith validated numeric fields. - Body:
{ "id": "...", "agentId": "...", "updates": { ... } } - Code:
app/api/strategies/route.ts
- Updates a strategy by
- GET
api/strategy-stream?agentId=<id>- SSE stream of the current strategies list for the specified agent.
- Code:
app/api/strategy-stream/route.ts
- GET
api/prices-stream- SSE stream of live price updates.
- Code:
app/api/prices-stream/route.ts
- GET
api/trigger-history?agentId=<id>- JSON array of trigger events for the specified agent. Add
?stream=trueto stream via SSE. - Code:
app/api/trigger-history/route.ts
- JSON array of trigger events for the specified agent. Add
- GET
agents/[agentSlug]/agent.json- Returns agent metadata from local registry by slug.
- Code:
app/agents/[agentSlug]/agent.json/route.ts
- GET
.well-known/[agentSlug]/agent-card.json- Returns the agent card (fetches from Convex via
CONVEX_SITE_URL). - Code:
app/.well-known/[agentSlug]/agent-card.json/route.ts
- Returns the agent card (fetches from Convex via
- Agent init:
app/api/agent/create-agent.ts:38- LLM: OpenAI
gpt-4o-minior Groqllama-3.3-70b-versatile - Tools: from AgentKit via
getLangChainTools - Memory:
MemorySaver - System prompt includes guidance, CDP/AgentKit links, and faucet hint on Base Sepolia
- LLM: OpenAI
- AgentKit + Wallet:
- Config:
app/api/agent/prepare-agentkit.ts:87 - Wallet:
CdpSmartWalletProvider(Base by default:base-sepolia) - Action providers registered:
- Built-in:
wallet,erc20,weth,cdpApi,cdpSmartWallet,x402 - Custom:
pyth(live prices, SSE):app/providers/newPythActionProvider.ts:50tradeStrategy(CRUD + subscriptions):app/providers/tradeStrategyActionProvider.ts:59dexScreener(token discovery):app/providers/dexScreenerActionProvider.ts:47dexSwap(CDP Trade API, smart account):app/providers/swapActionProvider.ts:151
- Built-in:
- Smart wallet info persisted to
wallet_data.txton first run
- Config:
- Strategies persisted/managed via actions and API:
- Create/list/update/remove: tradeStrategy provider
- Broadcast updates via SSE:
app/utils/strategyBroadcast.ts:1
- Live Prices:
pyth.getPricefetches feed ID;subscribeToPriceFeedstreams live updates- Broadcast to SSE:
app/utils/priceBroadcast.ts:1
- Trigger Engine:
- Evaluates thresholds and percentages (+ cooldown) per strategy on each price tick
- Logs events and updates strategy state
- Code:
app/utils/priceTriggerEngine.ts:26
- Swap Execution:
- Hooked via
setExecutionCallbacktoSwapActionProvider.executeAutomatedSwap - Currently logs parameters; modeled for CDP Trade API execution
- Code:
app/api/agent/prepare-agentkit.ts:32,app/providers/swapActionProvider.ts:163
- Hooked via
- Agent request/response and price data:
app/types/api.ts:1 - Strategy/Trigger event:
app/types/strategy.ts:1 - Default Base tokens/metadata:
app/types/asset.ts:21
- Agent call (optional agent selection):
curl -sX POST http://localhost:3000/api/agent \
-H 'Content-Type: application/json' \
-d '{"userMessage":"What is my smart wallet address?","agentId":"warren-debuffett"}'- List agents:
curl -s http://localhost:3000/api/agents | jq- Strategies (per agent):
curl -s 'http://localhost:3000/api/strategies?agentId=warren-debuffett'
curl -sX PATCH http://localhost:3000/api/strategies \
-H 'Content-Type: application/json' \
-d '{"id":"warren-eth-buy-fear","agentId":"warren-debuffett","updates":{"buyThreshold":24,"cooldownMinutes":1440}}'- SSE (terminal view):
curl -N 'http://localhost:3000/api/strategy-stream?agentId=warren-debuffett'
curl -N http://localhost:3000/api/prices-stream
curl -N 'http://localhost:3000/api/trigger-history?agentId=warren-debuffett&stream=true'- Agent metadata endpoints:
curl -s 'http://localhost:3000/agents/warren-debuffett/agent.json' | jq
curl -s 'http://localhost:3000/.well-known/warren-debuffett/agent-card.json' | jq