ExploreKnow Your AgentPaymentsHow it worksDevelopersPricingSponsors Sign in

x402 demo · Base Sepolia testnet

Pay for an API call with x402

This page sells a small report for 0.01 test USDC using x402, the open standard for paying over HTTP. Neptuv is the facilitator: it checks the payment and the payer, then settles it. The test USDC goes straight to the seller; Neptuv only pays the network fee.

Top trusted agents report

0.01 test USDC

You'll sign a USDC transfer in your wallet. No gas needed from you. It's test money on Base Sepolia, with no real value.

  1. Ask for the report → the server answers 402 Payment Required with the price
  2. Sign the payment in your wallet
  3. Neptuv checks the signature, the amount and the payer
  4. Neptuv settles it on Base Sepolia and the report unlocks

Need test USDC?

Get 20 free test USDC at faucet.circle.com (choose Base Sepolia). Your wallet switches to Base Sepolia when you pay.

How an AI agent pays this

An agent does the same thing in code: call the URL, read the price from the PAYMENT-REQUIRED header, sign, and call again with PAYMENT-SIGNATURE. Any x402 client library works too.

agent_pays.py
import base64, json, secrets, time, requests
from eth_account import Account
from eth_account.messages import encode_typed_data

URL = "https://neptuv.xyz/demo/x402/report"
agent = Account.from_key(AGENT_KEY)            # the agent's own wallet, with test USDC

r = requests.get(URL)                          # 1. 402 + price
req = json.loads(base64.b64decode(r.headers["PAYMENT-REQUIRED"]))["accepts"][0]
now = int(time.time())
auth = {"from": agent.address, "to": req["payTo"], "value": int(req["amount"]),
        "validAfter": now - 60, "validBefore": now + 120, "nonce": "0x" + secrets.token_hex(32)}
typed = {"types": {"EIP712Domain": [{"name": "name", "type": "string"}, {"name": "version", "type": "string"},
                                    {"name": "chainId", "type": "uint256"}, {"name": "verifyingContract", "type": "address"}],
                   "TransferWithAuthorization": [{"name": n, "type": t} for n, t in [("from", "address"), ("to", "address"),
                       ("value", "uint256"), ("validAfter", "uint256"), ("validBefore", "uint256"), ("nonce", "bytes32")]]},
         "primaryType": "TransferWithAuthorization",
         "domain": {"name": req["extra"]["name"], "version": req["extra"]["version"], "chainId": 84532,
                    "verifyingContract": req["asset"]},
         "message": auth}
sig = agent.sign_message(encode_typed_data(full_message=typed)).signature.hex()   # 2. sign
payload = {"x402Version": 2, "accepted": req, "payload": {"signature": "0x" + sig.removeprefix("0x"),
           "authorization": {k: str(v) for k, v in auth.items()}}}
r = requests.get(URL, headers={"PAYMENT-SIGNATURE": base64.b64encode(json.dumps(payload).encode()).decode()})
print(r.json())                                # 3–4. checked, settled, report

Selling to AI agents yourself? Use Neptuv as your facilitator: setup guide.