x402 · Agent buy
Agents buy RWAs, keyless.
An autonomous agent acquires a tokenized real-world asset end-to-end with only its own EVM key. It authenticates with a signature, funds itself in USDC over x402, and Realmint bridges and routes the buy.
Bind the same flow into OpenAI, Gemini, LangChain, CrewAI, or the Vercel AI SDK via the published tool schemas.
Why x402
What you get out of the box
Funding and execution an agent can drive on its own, with no custody and no key handover.
Keyless authentication
The agent signs an EIP-191 challenge with its own EVM key. No API key to provision, rotate, or leak.
Gasless self-funding
USDC moves via an EIP-3009 authorization over x402. The agent needs USDC on Base — but no ETH for gas.
Automatic bridge + route
Realmint bridges the USDC over CCTP and routes the buy to the best venue. No manual cross-chain steps.
Non-custodial by design
Signing is always local; Realmint never holds keys. Spending the funds still needs the agent's own signature.
Quickstart
Three calls with the SDK
The SDK holds the agent's EVM key and signs locally. Reach for raw HTTP only when no JS runtime is available.
import { agentLogin, fundWithX402, signerFromViemAccount } from "@realmint/sdk";
import { privateKeyToAccount } from "viem/accounts";
// 1. Keyless auth — sign a challenge with the agent's EVM key (stays local)
const account = privateKeyToAccount(process.env.AGENT_PRIVATE_KEY!);
const { client } = await agentLogin({
ownerEoa: account.address,
signMessage: (m) => account.signMessage({ message: m }),
});
// 2. Self-fund in USDC over x402 (gasless EIP-3009 transfer on Base)
// payX402: your x402 payment signer (e.g. the Coinbase x402 SDK on Base)
const payX402: X402PaymentSigner = /* ... */;
await fundWithX402(client, { owner_eoa: account.address, amount_usdc: 5, asset_id: "tslax" }, payX402);
// 3. Buy — Realmint bridges + routes; the UserOp is signed locally
const intent = await client.buy(
{ asset_id: "tslax", source_token: "USDC", amount_in: 5, agent_wallet: account.address },
signerFromViemAccount(account),
);Under the hood
The end-to-end flow
What the SDK does for you — every leg is a public, documented endpoint.
Authenticate (keyless)
Request a challenge, sign it with the EVM key (EIP-191), and exchange the signature for a short-lived bearer token. No API key required.
POST /v1/agent/auth/challenge → /v1/agent/auth/tokenSelf-fund over x402
The first call returns 402 with payment requirements. Sign a USDC EIP-3009 transferWithAuthorization and retry with the X-PAYMENT header; Realmint settles it via the Coinbase facilitator.
POST /v1/route/x402-buy → 402 Payment RequiredBridge settles automatically
Realmint bridges the USDC to the agent's smart account over CCTP (a few minutes). Poll the portfolio until the balance lands.
GET /v1/portfolio/<smart_account>Route the buy
Create an intent, prepare it, sign the returned UserOp hash locally, then submit and execute. Realmint picks the best venue for the asset.
POST /v1/route/intent → /prepare → /executePoll to completion
Poll the intent until it reports completed. The asset settles into the agent's smart account.
GET /v1/route/intent/<id> → status: completedShip it
Don't reinvent the lifecycle
Start from the reference agent or the SDK — both implement the full flow, including local signing.