← Book me

AWS re:Invent 2026 · COM312 · x402 + AgentCore payments

An agent that pays its own way.

Everything you need for your agent to pay a 402: a prompt for your coding agent, an AgentCore payments tutorial, and the API behind my booking page. Testnet money only.

x402 in 30 seconds

A price tag on every request

1997

A status code nobody used

HTTP set aside 402 "for future use" in 1997. It sat unused for decades.

402 → 200

x402 puts it to work

The server names a price, the client signs a USDC payment, retries, and gets in.

$0.01

Micropayments that add up

Each one settles in about a second, and the facilitator pays the gas. A cent per call works.

Agents

Why agents care

An agent can pay for one request with nothing set up. That's why it needs spending rules, and the trap journey shows what happens without them.

Bring your own agent · about 5 minutes

Want to try it with your own agent?

Copy this prompt into Claude Code, Codex, Cursor, Kiro, or any coding agent. It writes a small x402 client, funds a test wallet from my faucet, buys a fortune with a real testnet payment, and then proves its own spending rules by refusing the 0.25 trap. You get a Basescan link at the end, and your name lands on the receipts wall.

Build a tiny x402 client and use it to make a real payment on Base Sepolia testnet.

Server: https://whereis.davidvictoria.com (x402 v2, scheme "exact", network eip155:84532, test USDC)

1. Create a new Node.js project in an empty folder, set "type": "module" in package.json, and install viem.
2. Generate a fresh wallet with viem (generatePrivateKey, privateKeyToAccount). Save the private key to .env and never print it. Print the address.
3. Fund it: POST https://whereis.davidvictoria.com/api/faucet with JSON {"address": "<address>"}. It sends 0.60 test USDC, enough for a fortune and a meeting. A 200 means the money is on its way. If the response is an error, print it, wait 30 seconds, and retry, up to 3 times. Then poll GET https://whereis.davidvictoria.com/api/balance?address=<address> every 3 seconds until usdc >= 0.01. If usdc comes back null, the RPC was slow: keep polling.
4. GET https://whereis.davidvictoria.com/api/fortune?name=<MY NAME>. Expect HTTP 402. Base64-decode the PAYMENT-REQUIRED response header into JSON and print accepts[0].
5. Spending rules, checked before signing anything:
   - network must be eip155:84532
   - amount must be at most 50000 (0.05 USDC)
   - payTo must equal the pay_to from GET https://whereis.davidvictoria.com/api/meet: products.fortune.pay_to for /api/fortune and /api/lab/*, products.meeting.pay_to for /api/book
   If a rule fails, stop, sign nothing, and say which rule failed.
6. Sign an EIP-3009 TransferWithAuthorization with viem's account.signTypedData. Use Unix time in seconds for now.
   domain: { name: accepts[0].extra.name, version: accepts[0].extra.version, chainId: 84532, verifyingContract: accepts[0].asset }
   types: { TransferWithAuthorization: [ {name:"from",type:"address"}, {name:"to",type:"address"}, {name:"value",type:"uint256"}, {name:"validAfter",type:"uint256"}, {name:"validBefore",type:"uint256"}, {name:"nonce",type:"bytes32"} ] }
   primaryType: "TransferWithAuthorization"
   message: { from: <address>, to: payTo, value: amount, validAfter: now - 600, validBefore: now + maxTimeoutSeconds, nonce: random 32-byte hex }
7. Build { x402Version: 2, resource: <resource from the 402>, accepted: accepts[0], payload: { signature, authorization: <the message, every number as a string> } }, base64-encode the JSON, and repeat the same GET with the header PAYMENT-SIGNATURE.
8. Expect 200. Print the fortune, base64-decode the PAYMENT-RESPONSE header, and print https://sepolia.basescan.org/tx/<transaction>. Each wallet can buy 3 fortunes.
9. Prove the spending rules work: run the same flow against https://whereis.davidvictoria.com/api/lab/overcharge (it asks for 0.25) and show that the client refuses to sign.

10. Give back what's left so the faucet keeps working for others: sign one more TransferWithAuthorization for your full balance (GET /api/balance, in 6-decimal units) to products.fortune.pay_to, then POST https://whereis.davidvictoria.com/api/return with JSON {"payment": {"x402Version": 2, "resource": {"url": "https://whereis.davidvictoria.com/api/return", "description": "return", "mimeType": "application/json"}, "accepted": {"scheme": "exact", "network": "eip155:84532", "amount": "<units>", "asset": "0x036CbD53842c5426634e7929541eC2318f3dCF7e", "payTo": "<pay_to>", "maxTimeoutSeconds": 300, "extra": {"name": "USDC", "version": "2"}}, "payload": {"signature": "…", "authorization": {…}}}}. Print the transaction link. If you also do the optional booking below, return after it.

Optional, the real thing: book 15 minutes with David for 0.15 test USDC. Read open times from GET https://whereis.davidvictoria.com/api/meet, then POST https://whereis.davidvictoria.com/api/book with JSON {"time", "name", "contact", "topic"}, where contact is an email or a WhatsApp number with its country code (10 digits without one are read as Mexico, +52), and pay the 402 the same way. Raise the amount limit to 150000 (0.15 USDC) for that call only.

The client in this prompt keeps its key in a local file and enforces its own limits. That's fine for a demo. In production, AgentCore payments moves both out of the agent: the wallet stays with Coinbase or Stripe (Privy), and the budget lives in a payment session. The tutorial below shows that setup.

Mini tutorial · about 10 minutes · testnet money

Give your agent a wallet and buy a fortune

You'll set up AgentCore payments with a Coinbase wallet, fund it with free testnet USDC, and have a Strands agent pay 0.01 USDC for a Vegas fortune cookie. Your name shows up on the receipts wall when it works, and the same agent can then book a meeting with me. AgentCore payments is in preview, so check that your AWS account and region have it.

  1. Install the AWS agent toolkit

    Inside Claude Code (Codex and Kiro work too):

    /plugin marketplace add aws/agent-toolkit-for-aws
    /plugin install aws-agents@agent-toolkit-for-aws
  2. Ask for payments, point it at my fortune endpoint

    Wire my agent to pay for x402-protected APIs using the agents-build skill
    in the aws-agents plugin. Test it against
    https://whereis.davidvictoria.com/api/fortune?name=YOUR_NAME

    The skill creates the Payment Manager, connector, wallet, and a budget-capped session, and adds a payment tool to your agent.

  3. Authorize Coinbase and fund the wallet

    The skill pauses twice. First you sign in to Coinbase (Quick create, no keys to copy). Then you open the wallet link, grant the agent permission to sign, and fund the wallet with test USDC on Base Sepolia from the Circle faucet.

  4. Watch the agent pay

    It calls the endpoint, gets the 402, pays 0.01 USDC, retries, and prints your fortune with a Basescan link. Scroll down: your first name is on the wall.

Reference

Endpoints

Times are Pacific (UTC−8) on the hour or half hour: Nov 30 to Dec 3 from 9 AM to 6 PM, Dec 4 from 9 AM to noon. Paid endpoints speak x402 v2 and also accept X-PAYMENT.

POST /mcpMCP server: where_is_david, book_meeting, buy_vegas_fortune.
GET /api/meetWhere I am, my next open times, prices, networks, and the receiving wallet.
POST /api/bookJSON {time, name, contact, topic, venue}. 15 minutes for 0.15 test USDC on Base Sepolia. venue is optional and best effort.
GET /api/fortune?name=Practice purchase: 0.01 test USDC on Base Sepolia.
POST /api/faucetJSON {address}. Sends 0.60 test USDC from my treasury, with Coinbase's faucet as backup. Twice per address per day.
POST /api/returnJSON {payment}: an EIP-3009 payload that sends leftover test USDC back to my treasury. Gasless.
GET /api/balance?address=Test USDC balance on Base Sepolia.
GET /api/receiptsThe wall, as JSON.