Agent Wallet · Base Sepolia · x402
An agent that pays on its own, and can't overspend
An AI agent gets its own wallet with spending limits written into a smart contract. It pays for API calls by itself. Any payment that breaks a rule is refused before money moves, and every payment and refusal is on a public record anyone can check.
Status: In development. The contracts aren't deployed yet; live payments will appear on this page once they are.
How a payment works
- 1
The agent calls a paid API
The API answers 402 Payment Required with a price, for example 0.01 test USDC, using the open x402 standard.
- 2
The wallet checks the rules
Before signing, the agent asks its wallet contract to authorise the payment. The contract checks every limit on-chain, where the agent can't get around it.
- 3
Allowed: the payment settles
The agent signs a standard x402 payment with the wallet as payer. The x402 facilitator settles it in test USDC and the API returns its data.
- 4
Refused: nothing moves
The contract records the refusal as a public event with its reason. No money moves and the API is never paid.
The rules each agent wallet enforces
The operator sets these. A change applies from the agent's very next payment.
Per-payment cap
No single payment may be larger than this.
Demo: 1 USDC
Daily budget
Total spend per day (UTC) can't go over this.
Demo: 5 USDC
Task budget
Each task the agent works on has its own budget.
Demo: market-research, 2 USDC
Allowed payees
The agent can only pay addresses on its list.
Demo: the demo API only
Pause switch
The operator can stop all payments at once.
Demo: off
Why a payment can be refused
Every refusal carries exactly one of these reasons, checked in this order.
PAUSEDThe operator has paused this agent.INVALID_AMOUNTThe amount is zero, or the payment has already expired.PAYEE_NOT_ALLOWEDThe recipient isn't on the agent's allowed list.OVER_PER_PAYMENT_CAPThis single payment is above the per-payment cap.OVER_TASK_BUDGETIt would push the task over its budget.OVER_DAILY_BUDGETIt would push today's spending over the daily budget.INSUFFICIENT_FUNDSThe wallet doesn't hold enough USDC.
What this page will show
Sample data for illustration. Nothing below is on-chain yet.
research-bot-01
Today0.01 / 5.00 USDC
Task: market-research0.01 / 2.00 USDC
| Time | Payment | Amount | Result |
|---|---|---|---|
| 09:00:12 | api.demo.yunshu.ai/quote | 0.01 | Paid |
| 09:00:15 | api.demo.yunshu.ai/quote | 1.50 | Refused · OVER_PER_PAYMENT_CAP |
| 09:00:19 | unlisted-service.example | 0.01 | Refused · PAYEE_NOT_ALLOWED |
Built with
- Solidity + Foundry
- OpenZeppelin
- x402
- USDC on Base Sepolia
- viem
- Cloudflare Workers
- Astro