BS
BaseScreener

Quickstart

Make your first paid query in under 5 minutes

Quickstart

Prerequisites

  • A Base wallet funded with USDC (or a developer API key)
  • Node.js 18+

Install dependencies

bash
npm install @coinbase/agentkit viem

Make your first query

typescript
import { AgentKit } from '@coinbase/agentkit' import { privateKeyToAccount } from 'viem/accounts' const account = privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`) const agentKit = await AgentKit.from({ account }) // The x402 client handles the 402 → sign → retry cycle automatically const result = await agentKit.fetch('https://apitoken.agentchaintools.xyz/graphql', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ query: `{ newTokens(maxAgeSeconds: 3600, minLiquidityUsd: 10000, limit: 5) { tokens { address symbol price { usd change24h } risk { score isHoneypot } } } }` }) }) const data = await result.json() console.log(data.data.newTokens.tokens)

The first request returns a 402 with payment requirements. AgentKit signs the Permit2 authorization and retries automatically. You only pay when you receive data.

Using a developer API key (no wallet needed)

For testing during development, you can use an API key instead of x402 payments:

typescript
const result = await fetch('https://apitoken.agentchaintools.xyz/graphql', { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-API-Key': 'sk_test_your_key_here', }, body: JSON.stringify({ query: `{ newTokens(limit: 5) { tokens { symbol price { usd } } } }` }) })

API keys have a credit balance that decreases with each query based on complexity. Switch to x402 for production.

Checking query cost before paying

Send any query without a payment header or API key. The 402 response body tells you the exact cost:

json
{ "error": "Payment required", "details": { "amount": "0.000360", "currency": "USDC", "queryCostUnits": 18, "costPerUnit": 0.00002 } }

Your agent can read this and decide whether to proceed.

Get your wallet funded

You can acquire USDC on Base via:

  • Coinbase — direct withdrawal to Base
  • bridge.base.org — bridge from Ethereum mainnet
  • Uniswap on Base — swap ETH → USDC

Try it without paying

Use the Playground to test queries for free. The playground uses a server-side bypass so you can explore the schema and data without any payment.