mpp-make-payments
Example payment client — pays for an MPP-gated resource the way an autonomous agent would, with safe retries that reuse the same signed credential.
402 with an atum-escrow challenge, and pays for it automatically with no human in the loop.
The client holds its own signing key, so it pays as the participant that key belongs to. That is how the 402 flow works — it checks the signature, not who is behind the software. Establishing who is answerable when software spends for someone else is Know Your Agent, a separate question.
Prerequisites
Node.js 20+
Node.js 20+
npm is included with Node.js.Verify:
A funded testnet wallet for your agent
A funded testnet wallet for your agent
Your agent needs a wallet that holds the source token on the chain the merchant accepts.Export its private key — use a testnet-only wallet, never one holding real funds. See Set up a testnet wallet.Against the merchant’s default stub submitter no real transaction is submitted, so any private key works for a local run.
Source-token approval (testnet / mainnet only)
Source-token approval (testnet / mainnet only)
For real settlement, the Permit2 contract must be approved to spend your source token. The client can do this for you: set
RPC_URL in .env and it approves the token before paying, via the ensureSourceApproval helper.Skip this step when running against the stub merchant — no on-chain approval is needed.Prerequisites for real settlement
Local stub runs need no funds. Before you point the client at testnet or mainnet, confirm your payer wallet has the source token, native gas for the one-time Permit2approve(), and an active allowance — see Prerequisites.
1. Clone and install
2. Configure
PRIVATE_KEY in .env to your agent wallet’s 0x-prefixed key — it’s the only value you need to run against the local stub merchant. The client’s other variables (MERCHANT_URL, RPC_URL) are documented in the example README; the corridor itself is the merchant’s config, not the client’s.
3. Start the merchant (if running locally)
Follow Agentic receives to start the merchant server first:The merchant is a separate app, so it needs its own
npm install (the clone step only installed mpp-make-payments). To install all four example apps at once instead, run npm run install:all from the repo root.4. Run the client
Back inmpp-make-payments:
What’s happening
Looking atsrc/client.ts and src/purchase.ts:
registerClientteaches themppxclient how to build and sign anatum-escrowcredential; the source account is derived from your key.- The client requests the resource under a purchase identifier in the URL (
/paid/<purchase id>), reads the402atum-escrowchallenge (which carries that id asintentId), and signs a Permit2 authorization over the source token. - It retries with that credential in an
Authorization: Paymentheader. - If settlement is still pending, it re-attempts the same purchase: fresh
402, newly signed credential, same purchase id. The gateway resolves onto the original payment — see Idempotency andsrc/purchase.ts.
Going to testnet or mainnet
Real settlement means funding your agent’s wallet, approving the source token (Permit2), and pointingMERCHANT_URL at a merchant that settles through a live Atum Payment Gateway. See the example README for .env values, funding amounts, and on-chain verification — its Going to testnet or mainnet section walks through that app.
New to Atum’s environments? See Choose an environment for which one to target and what to expect from production-testnet. Run through the pre-flight checklist before your first real payment.