How To Build an AI Agent on Robinhood Chain with GetBlock RPC
Learn how to build an agent that answers natural-language questions about Robinhood Chain
Robinhood Chain is Robinhood's Arbitrum-based Ethereum L2, built for tokenized stocks, real-world assets, and AI agents — it produces blocks roughly every 100ms. For an AI agent to be useful on a chain like this, it needs live onchain data: balances, blocks, transactions, and token state.
Large language models cannot read a blockchain on their own, and if you simply ask one about onchain values, it will guess confidently and wrongly. Raw JSON-RPC, on the other hand, is too low-level to hand to a model directly: hex quantities, wei amounts, and positional params invite unit mistakes. The missing piece is a thin tool layer that turns natural-language questions into real RPC calls and feeds human-readable results back to the model.
In this guide, you will learn how to build an AI agent that answers natural-language questions about Robinhood Chain using OpenAI function calling for reasoning and GetBlock RPC for live chain reads.
What you'll build
An agentic loop in agent.js — driven by npm run agent -- "<question>" — that:
Sends your question to an OpenAI model along with five JSON-schema tool definitions.
Executes every tool call the model requests as a real JSON-RPC call against your GetBlock endpoint.
Feeds the formatted results (
balanceEth,gasPriceGwei) back to the model astoolmessages.Repeats until the model has enough data, then prints its plain-text answer with Blockscout explorer links.
Optional
This guide also contains two helper scripts along the way:
quickstart.jsto verify your endpoint,watch-blocks.jsto stream the ~100ms block cadence over WebSocket.
You can skip this if you want too
Prerequisites
Node.js 18+ — the project uses ES modules and top-level
await.A Robinhood Chain RPC endpoint — created from your GetBlock dashboard (HTTP, plus WebSocket if you want block streaming).
An OpenAI API key needed only for the agent step.
Basic JavaScript knowledge.
Project Setup
Configure your endpoints and keys
In your GetBlock dashboard, click Get an endpoint, select Robinhood Chain (mainnet), and copy the JSON-RPC (HTTP) and WebSocket URLs. Store them in a .env file:
The access token in the URL path is how GetBlock authenticates you — no headers needed. Never commit .env; keep it in .gitignore.
Stream blocks over WebSocket (optional)
Robinhood Chain targets ~100ms blocks. GetBlock's WebSocket endpoint exposes eth_subscribe, which viem wraps in watchBlocks:
Run npm run watch and note the Δ +0s deltas — multiple blocks land within the same second.
That near-instant confirmation feedback is exactly why the chain suits agent-driven trading.
Build the agent: tools, implementations, and the loop
This is the core of the tutorial. The pattern is function calling: you describe tools to the model with JSON schemas, it decides when to call them, your code executes the real RPC calls, and the model reasons over the results.
The agent gets five read-only tools, all backed by your GetBlock endpoint:
get_chain_status
eth_chainId, eth_blockNumber, eth_gasPrice, eth_getBlockByNumber
asked about the network or gas
get_balance
eth_getBalance
asked what a wallet holds
get_block
eth_getBlockByNumber
asked about recent activity
get_transaction
eth_getTransactionByHash, eth_getTransactionReceipt
given a tx hash
get_token_info
eth_call (ERC-20 reads)
asked about a token / Stock Token
Two details worth copying into your own agents:
Prescriptive tool descriptions. Each description says when to call the tool, not just what it does — this measurably improves the model's tool selection.
Human-readable tool results. Tools return formatted values (
balanceEth,gasPriceGwei) rather than raw wei, so the model makes fewer unit mistakes and the answers read better.
Troubleshooting
GETBLOCK_RPC_URL is not set on startup
.env missing or not copied from the example
Copy .env.example to .env and paste your dashboard URLs.
Chain ID prints something other than 4663
The access token is for a different chain
Create a Robinhood Chain endpoint in the dashboard and use that token.
HTTP 401 / 403 from go.getblock.io
Invalid, revoked, or mistyped access token
Re-copy the exact URL (including trailing /) from the dashboard.
GETBLOCK_WS_URL is not set when running npm run watch
Only the HTTP endpoint was configured
Add the WebSocket URL from the same endpoint page.
watchBlocks prints txs: ?
newHeads delivers headers only on some nodes
Expected — fetch the full block with get_block when you need the tx list.
OpenAI 401 or model errors in agent.js
Missing/invalid OPENAI_API_KEY or unavailable model
Set the key; override the model with OPENAI_MODEL if needed.
Agent answers without calling tools
Vague tool descriptions after edits
Keep the "Call this when…" phrasing in every tool description.
Conclusion
You built an AI agent that reasons over live Robinhood Chain data: a Viemviem client pointed at a GetBlock RPC endpoint, five read-only JSON-RPC tools described to an OpenAI model as function-calling schemas, and an agentic loop that executes the model's tool calls and feeds formatted results back until it can answer in plain text. The same pattern — prescriptive tool descriptions, human-readable tool outputs, and a bounded tool loop — extends directly to write operations, event monitoring, and multi-turn onchain copilots.
Resources
Last updated
Was this helpful?