Guide · Developers, AI builders

How to build agent payments

Software that can pay changes what software can be: an agent that holds a budget and answers 402 challenges can buy its own API calls, its own data, its own compute. No contracts, no invoicing, no human in the loop: a price, a signature, a retry.

This guide wires an agent into U.CASH payments: the key pair, the 402 flow, the server side, and the patterns that keep a budgeted agent from misbehaving.

You needA runtime for your agent (Node, Python, anything that can hold a key)A funded wallet for the agentA service to sell (yours) or to buy (everyone else's)

Step by step

Every step, in order.

Step 01

Give the agent a key pair

The agent's wallet is its money: generate a key pair, fund it with the assets it will spend, and scope the balance to a budget. The key is the agent's entire identity on the payment layer.

Step 02

Speak 402 on the client side

When a server answers 402 Payment Required with a price and a payment address, the agent builds the transaction, signs, pays, and retries the original request with proof. The SDKs wrap the whole handshake.

Step 03

Price your own endpoints

On the server side, answer unauthenticated requests with a 402 and a payment request: amount, asset, destination. Verified payment releases the response. Per-request, per-call, per-token: pricing becomes code.

Step 04

Set budgets and limits

Cap the agent's spend per period, per counterparty, and per task. The wallet enforces what code forgets: a runaway loop meets an empty key, not an unlimited card.

Step 05

Watch the receipts

Every payment is an on-chain transaction with a hash. Agent ledgers reconcile themselves: what was spent, for what, provable after the fact.

The part that matters

The interesting failure modes are all budget-shaped. An agent optimizing a metric will happily pay infinity for marginal gains unless the budget curve stops it; tie spend caps to task value, log every 402 answered with its purpose, and prefer per-call pricing to subscriptions so a wedged agent idles cheap instead of billing forever. The non-custodial key model is the safety architecture: exposure equals the funded balance, nothing more.

Go deeper

HTTP-402AI agentsDeveloper docs

FAQ

Which assets can an agent pay with?
Whatever the server prices in, typically a stablecoin or the network token for predictable unit economics. The handshake is the standard; the asset is a parameter.
How does a server verify a payment?
By watching the chain or trusting the payment layer's signed confirmation: the transaction either landed at the address for the amount or it did not. No chargebacks exist to account for.
Can agents pay each other?
Yes: both sides speak the same 402 handshake, so machine-to-machine commerce is the same code as machine-to-service. Budgets on both ends keep it civilized.

Other guides

How to accept crypto payments

Accept Bitcoin, Ethereum, stablecoins and 53 more assets at checkout in minutes: connect…

How to swap across chains

Swap any asset for any other across 34 networks: connect a wallet, pick the pair, review…

How to buy UCASH

Three ways to get UCASH, the U.CASH network token: card or bank through the partner ramp,…

Keep going

How to build agent payments, done right

Six guides, one platform, every rail non-custodial.