Pay once in USDC and get a signed gift voucher — claim code, task budget, expiry — back in the same response. The recipient's agent redeems it for free and receives a signed, spendable credit record.
git clone https://github.com/nirholas/x402-gift-agent && cd x402-gift-agent npm install && npm run dev
Every paid route answers with a dual-rail 402. The accepts array carries one EVM entry and one Solana entry; your client (or the checkout modal) picks whichever wallet it has. Each rail settles through its own facilitator — no single one handles both.
base-sepolia / base0x40252CFDF8B20Ed757D61ff157719F33Ec332402x402.org/facilitatorsolana-devnet / solanaWwwuGbqHrwF5RG89KhUbmRWEvjnRH9k5kVM5p7T3WwWfacilitator.payai.network/gifts?amount=; server quotes gift + fee on both railsThe claim code is in the payment response, not an email. Forward it however you like — the recipient's agent redeems it against a wallet on either rail and gets a signed credit record it can present to an executor.
| Route | Price | Returns |
|---|---|---|
POST /gifts | $0.11 (gift amount + $0.01 fee — e.g. `?amount=0.10`) | Signed gift voucher (claim code, task budget, expiry) |
POST /claim/:code | free | Voucher validation + signed spendable credit record |
GET /gifts/:id | free | Voucher status snapshot (claim code redacted) |
GET /credits/:wallet | free | Signed credit records owned by that wallet |
GET /stats | free | Aggregate counters |
POST /verify | free | `{ valid: true | false }` |
GET /health | free | `{ ok: true }` |
import { wrapFetchWithPayment } from "x402-fetch";
import { privateKeyToAccount } from "viem/accounts";
const payFetch = wrapFetchWithPayment(fetch, privateKeyToAccount(process.env.PRIVATE_KEY));
// buy a $0.50 gift (costs $0.51) bound to a Solana recipient
const voucher = await (await payFetch("http://localhost:4022/gifts?amount=0.50", {
method: "POST", headers: { "content-type": "application/json" },
body: JSON.stringify({
sponsor: "0xYourAddress",
recipient: "WwwuGbqHrwF5RG89KhUbmRWEvjnRH9k5kVM5p7T3WwW",
message: "have your agent book us dinner"
})
})).json();
voucher.claimCode; // "GIFT-4A7C-19F0-B3D2" — the purchased artifact
/.well-known/x402 — machine-readable manifest, both networks per resource (indexable by x402scan.com, the x402 Bazaar, agentic.market)