x402USDC on Base + Solana

x402-gift-agent

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

Pay on either rail

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.

EVM · BASEUSDC on base-sepolia / base
0x40252CFDF8B20Ed757D61ff157719F33Ec332402
settled via x402.org/facilitator
SOLANAUSDC on solana-devnet / solana
WwwuGbqHrwF5RG89KhUbmRWEvjnRH9k5kVM5p7T3WwW
settled via facilitator.payai.network

How gifting works

1 · 402Sponsor calls /gifts?amount=; server quotes gift + fee on both rails
2 · PAYSponsor signs USDC on Base or Solana; facilitator settles
3 · VOUCHERSigned voucher with its claim code in the 200 body
4 · CLAIMRecipient's agent redeems free → signed credit record

The 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.

Pricing

RoutePriceReturns
POST /gifts$0.11 (gift amount + $0.01 fee — e.g. `?amount=0.10`)Signed gift voucher (claim code, task budget, expiry)
POST /claim/:codefreeVoucher validation + signed spendable credit record
GET /gifts/:idfreeVoucher status snapshot (claim code redacted)
GET /credits/:walletfreeSigned credit records owned by that wallet
GET /statsfreeAggregate counters
POST /verifyfree`{ valid: true | false }`
GET /healthfree`{ ok: true }`

Quickstart

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

Discovery