diff --git a/docs/ai-agents/trading/data-fetching.mdx b/docs/ai-agents/trading/data-fetching.mdx index 317e5da3e..523f70fce 100644 --- a/docs/ai-agents/trading/data-fetching.mdx +++ b/docs/ai-agents/trading/data-fetching.mdx @@ -1,7 +1,7 @@ --- title: "Fetching Market Data" -description: "Use x402 to access live market data from CoinGecko, Alchemy, and other sources — no API key management required" -keywords: ["x402 market data", "trading agent data", "CoinGecko x402", "Alchemy x402", "pay per call data", "agent data fetching"] +description: "Use x402 to access live market data from CoinGecko, Alchemy, Quicknode, and other sources — no API key management required" +keywords: ["x402 market data", "trading agent data", "CoinGecko x402", "Alchemy x402", "Quicknode x402", "pay per call data", "agent data fetching"] --- import { DataFetchingDemo } from "/snippets/DataFetchingDemo.jsx" @@ -145,6 +145,96 @@ PAYMENT_SIG=$(npx @alchemy/x402 pay --private-key ./wallet-key.txt --payment-req See the full [Alchemy Agentic Gateway skill](https://github.com/alchemyplatform/skills/tree/main/skills/agentic-gateway) for wallet bootstrap, payment handling, and SDK integration. +### Quicknode — onchain data + +Quicknode's x402 gateway at `https://x402.quicknode.com` gives your agent direct RPC access to Base (mainnet and Sepolia) without an account or API key. Pay per request in USDC, or buy credits in bulk if you're making a lot of calls. + + + What sets Quicknode apart from other x402 providers: three payment tiers (per-request at `$0.001`, nanopayments at `$0.0001` via Circle Gateway, and credit drawdown for bulk use), WebSocket connections for streaming Base data, and a built-in Base Sepolia faucet so you can start testing without sourcing testnet USDC elsewhere. + + +Fetch token balances on Base: + + + + ```bash Terminal + # Read USDC balance for an address on Base + # balanceOf(address) selector: 0x70a08231 + curl -X POST "https://x402.quicknode.com/base-mainnet" \ + -H "Content-Type: application/json" \ + -d '{ + "jsonrpc": "2.0", + "id": 1, + "method": "eth_call", + "params": [{ + "to": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", + "data": "0x70a08231000000000000000000000000YOUR_ADDRESS_HERE" + }, "latest"] + }' + ``` + + If the endpoint returns `402`, sign the EIP-712 payment payload from the response body and include it as a `PAYMENT-SIGNATURE` header on retry. Each call costs `$0.001` USDC. Failed requests and JSON-RPC errors don't cost anything, so you only pay when you actually get data back. + + + Nanopayments run `$0.0001` per call, 10x cheaper than per-request. They require a Circle Gateway Wallet deposit and are available on Base Sepolia for now. + + ```bash Terminal + # Read USDC balance for an address on Base Sepolia + # balanceOf(address) selector: 0x70a08231 + curl -X POST "https://x402.quicknode.com/base-sepolia" \ + -H "Content-Type: application/json" \ + -d '{ + "jsonrpc": "2.0", + "id": 1, + "method": "eth_call", + "params": [{ + "to": "0x036CbD53842c5426634e7929541eC2318f3dCF7e", + "data": "0x70a08231000000000000000000000000YOUR_ADDRESS_HERE" + }, "latest"] + }' + ``` + + When you get the `402` back, find the `accepts` entry where `extra.name` is `"GatewayWalletBatched"`, sign it, and send it as the `PAYMENT-SIGNATURE` header on retry. Testnet cap is 10,000 requests (about `$1` total). + + + For high-volume use, authenticate with SIWX and pay with credits instead: + + ```bash Terminal + # 1. Sign in with your wallet (SIWX) + curl -X POST "https://x402.quicknode.com/auth" \ + -H "Content-Type: application/json" \ + -d '{ + "message": "", + "signature": "", + "type": "siwx" + }' + + # 2. Read USDC balance using the JWT + # balanceOf(address) selector: 0x70a08231 + curl -X POST "https://x402.quicknode.com/base-mainnet" \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer " \ + -d '{ + "jsonrpc": "2.0", + "id": 1, + "method": "eth_call", + "params": [{ + "to": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", + "data": "0x70a08231000000000000000000000000YOUR_ADDRESS_HERE" + }, "latest"] + }' + ``` + + Credits cost `$10` per 1,000,000 on mainnet. You only get charged for successful responses. + + + +If you're building a TypeScript agent, the [`@quicknode/x402`](https://www.npmjs.com/package/@quicknode/x402) SDK handles auth, payment signing, JWT management, and WebSocket connections so you don't have to wire up the 402 flow manually. + + + Quicknode includes a testnet faucet on Base Sepolia. After authenticating, call `POST /drip` to get free USDC for testing. No external faucet needed. + + ## Making data calls inside an OpenClaw agent Install the [Sponge Wallet](https://www.paysponge.com) skill or [CDP Agentic Wallet](https://docs.cdp.coinbase.com/agentic-wallet/) skills, then prompt your agent directly: