AgentRouterDocsStorefront ↗
Menu

Coinbase

Set up Coinbase Agentic Wallet with email, add test funds and use an existing deployed smart account to buy inference.

Start the wallet

You need Node.js 24+ with npm, an email address and a terminal. The complete guide also uses Python 3, curl, jq and uuidgen. Install missing tools first. A Coinbase exchange account is not required.

Coinbase manages the signing key on its backend in secure enclaves. Signing and wallet access depend on Coinbase's service. Local login/session credentials are sensitive; the Linux application directory is not a private-key backup.

Coinbase key storage

Shell
npx [email protected] status

Expected result

Accept the package installation prompt if shown. The wallet server reports Running. For startup problems on a headless Linux host, use the Linux appendix.

Sign in by email

Replace YOUR_EMAIL with your email address in your own terminal.

Shell
npx [email protected] auth login 'YOUR_EMAIL'

Expected result

A verification code is sent to your email. Keep it private.

Verify your email

Replace YOUR_CODE with the six-digit code from your email. Enter it only in your own terminal, never in an agent conversation.

Shell
npx [email protected] auth verify YOUR_CODE
npx [email protected] status

Expected result

Status reports Authenticated.

Get your address

Read your wallet's EVM address. Use this same address when funding.

Shell
npx [email protected] address

Expected result

Copy the EVM address, not a session credential.

Get test USDC

Open the Circle faucet, select USDC and Base Sepolia, paste your EVM address, and choose Send 20 USDC. Wait for confirmation. You can also transfer Base Sepolia test USDC from an existing wallet.

If Circle is unavailable, use the Coinbase CDP faucet: sign in to a CDP developer account, open Faucets, choose Base Sepolia and USDC, enter the address and choose Claim. The CDP account is separate from the wallet's email login.

Do not buy or send real funds for this setup.

Expected result

The faucet confirms the transfer. Verify the balance in the next step.

Check your balance

Read the USDC balance under Base Sepolia.

Shell
npx [email protected] balance --chain base-sepolia

Expected result

Have at least 1.00 test USDC for the documented offer. Always inspect the actual offer before paying.

Check account deployment

An already-deployed smart account is required by this purchase path. This check reads public contract data; it does not deploy the account or make a payment.

If it reports NOT DEPLOYED, stop before purchase. A supported first-deployment procedure is not yet included here. Funding the address alone is not proof of deployment.

Shell
H07_WALLET="$(npx --no-install [email protected] address --chain base-sepolia)" &&
curl -fsS https://sepolia.base.org \
  -H 'Content-Type: application/json' \
  --data "{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"eth_getCode\",\"params\":[\"$H07_WALLET\",\"latest\"]}" |
python3 -c 'import json,sys; c=json.load(sys.stdin).get("result"); print("DEPLOYED" if isinstance(c,str) and c.startswith("0x") and len(c)>2 else "NOT DEPLOYED" if c=="0x" else "CHECK FAILED")'

Expected result

Continue only on DEPLOYED. Stop on NOT DEPLOYED, CHECK FAILED, or an error.

Optional test ETH

The documented USDC x402 flow has the facilitator pay settlement gas. A zero-ETH purchase was not independently tested in the supplied Coinbase walkthrough, so its successful purchase does not prove that case.

Only if another transaction requires unsponsored gas, obtain Base Sepolia test ETH from the Coinbase faucet by choosing ETH, or transfer it from another wallet. The Pinky Base Sepolia faucet is another supplied option: enter the same public EVM address, complete its human check and request testnet ETH.

Never provide a seed phrase or private key to a faucet. Who pays x402 gas.

Expected result

Keep both assets on Base Sepolia. ETH funding is not a substitute for the smart-account deployment check.

Read the purchase offer

This unpaid request returns HTTP 402 with a PAYMENT-REQUIRED header and an empty body. It neither signs nor pays. The header contains standard-base64 x402 v2 JSON; your wallet client reads it in the next step.

Check the current offer before authorizing payment: exact, Base Sepolia (eip155:84532), USDC asset 0x036CbD53842c5426634e7929541eC2318f3dCF7e, amount 1000000 (1 test USDC), and the recipient. Stop if the terms differ from what you intend to buy. The quote is for access credit, not the price of one model request.

No AgentRouter account or proprietary recovery header is required. The wallet owner still needs to authorize wallet setup and spending.

Shell
curl -sS -X POST https://api.agentrouter.cc/v1/purchase \
  -D - -o /dev/null

Expected result

HTTP 402 Payment Required, Cache-Control: no-store, a PAYMENT-REQUIRED header and an empty body. The decoded header has x402Version: 2, resource.url: /v1/purchase and an accepts array. Each option supplies its network, asset, amount, recipient and EIP-3009 signing metadata. A 402 error without that header is not a usable offer.

Prepare one wallet

Use the same wallet in the purchase step. These checks do not authorize a payment. Keep wallet/session output private.

The purchase command also uses jq to load the delivered key privately. Have at least 1 test USDC and inspect the offer's amount, network, asset and recipient. The wallet client handles signing; never paste a wallet private key into a prompt or this site.

Tested with Coinbase [email protected] and a deployed smart account. Complete Coinbase setup and fund Base Sepolia USDC first. Headless Linux needs a working wallet server/display; stop if status cannot reach it. An undeployed smart account is not this tested path.

Expect a running, authenticated wallet and the Base Sepolia balance.

Shell
npx [email protected] status
npx [email protected] balance --chain base-sepolia
npx [email protected] x402 details https://api.agentrouter.cc/v1/purchase --json

Expected result

These readiness checks should not return a bearer key or settle a payment.

Compare the decoded offer with step 1. Do not proceed on missing funds, an unavailable wallet, an unsupported offer or unapproved terms. New wallet versions need their own compatibility check.

Buy once and keep the key

Run the block for your chosen wallet once, with the owner's spending approval. After buying, use the delivered key. Switching wallets is not another step and does not undo a purchase.

The command saves the full result in a new private directory and loads AGENTROUTER_KEY without displaying it. Keep the terminal open for inference. Do not run these commands with shell tracing, paste the result into model context, or put it in a served directory.

The client handles PAYMENT-SIGNATURE and the PAYMENT-RESPONSE receipt. If any command fails, times out, or delivery is uncertain, stop; do not rerun pay. Another invocation can create another purchase. Preserve the private response and receipt. These stock-client examples do not retain an optional recovery capability, so self-service lost-key recovery is not available for this flow. Never repay automatically to recover a key.

Coinbase caps this purchase at 1 test USDC. Expect the API response body in data.

Shell
umask 077
PURCHASE_DIR="$(mktemp -d "$HOME/agentrouter-purchase.XXXXXX")" &&
npx --no-install [email protected] x402 pay \
  https://api.agentrouter.cc/v1/purchase \
  -X POST --max-amount 1000000 --json \
  >"$PURCHASE_DIR/result.json" 2>"$PURCHASE_DIR/error.log" &&
AGENTROUTER_KEY="$(jq -er '.data.key | select(type == "string" and length > 0)' "$PURCHASE_DIR/result.json")" &&
export AGENTROUTER_KEY

Expected result

The API returns HTTP 200 with key, usage and PAYMENT-RESPONSE.

The commands export the opaque bearer key without printing it. A zero client exit code alone is insufficient: the response must contain the key and confirmed payment receipt. Keep the original response privately. Inspect the transaction through the Base Sepolia explorer, without sharing the bearer key.

Use your key

Continue to Discover models, then use the OpenAI-compatible API or Anthropic-compatible API. These steps are shared by both wallets.

Need help? Troubleshooting · Headless Linux setup