Skip to content

About

Payment-bound receipts and a pre-sign policy for x402 payments on Arbitrum

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

12 Commits

Folders and files

nirium-arbitrum

tests CodeQL License: Apache-2.0

Pay and charge with x402 on Arbitrum, refuse a payment before it is signed, and keep a receipt that says what the payment was for.

The chain already shows who paid whom, how much, and when. A Nirium receipt adds what the chain does not keep: which order a payment was for and who declared it, signed by the payer and bound to one specific USDC Transfer log. Anyone can check it against Arbitrum with a public RPC and nothing else from us.

This is Nirium on Arbitrum. Nirium started on Stellar; this repo brings the same receipt format and the same pre-sign policy contract to Arbitrum One and Arbitrum Sepolia. The code is the EVM code of nirium-avalanche with Arbitrum's network table.

Status

Piece Arbitrum Sepolia Arbitrum One
Receipt verifier (arbitrum/verify-evm-receipt.mjs) yes, our selftest receipt yes, our selftest receipt; fixtures from our own selftest
Pre-sign policy (arbitrum/policy/) offline tests not yet
Pay and charge library (arbitrum/sdk/) yes (selftest, 1 Dec 2026) yes (selftest, 1 Dec 2026)
x402 market (arbitrum/market/) offline tests yes, live at nirium-market-arbitrum.fly.dev (selftest sale, 1 Dec 2026)

A row says "yes" only once a settled payment's hash is in evidence/. Every payment there is made by the team to test the flow, labeled selftest, and is not usage. Nothing here has had an external audit.

What is here

Path What it does
docs/payment-binding-v1.md The receipt format and what a verifier checks
docs/decision-receipt-v1.md Decision receipts: a payer-signed record of what the pre-sign policy decided, including payments it refused (DENY, WAIT), which leave nothing on-chain
arbitrum/verify-evm-core.mjs Checks a receipt against a USDC Transfer log (tx hash + block logIndex), the EIP-3009 AuthorizationUsed nonce and the payer's signature. The CLI, verifyReceipt and a browser run this file
arbitrum/verify-evm-receipt.mjs The command line for it
arbitrum/sdk/ The library: x402Serve to charge, createX402Fetch to pay (with an optional policy), bindReceipt and verifyReceipt
arbitrum/policy/ Pre-sign policy: DENY, WAIT, a timeout and every malformed answer sign nothing
arbitrum/market/ x402 market: Arbitrum network conditions (fees, block fill, block time) for $0.01 per query
arbitrum/demo/ Reference x402 exact payment with PayAI as facilitator, then the receipt
scripts/ Arbitrum Sepolia key setup
evidence/ The team's test payments, each with its receipt and explorer link

Quick start

import { x402Serve, createX402Fetch, settlementOf, bindReceipt, createRulesPolicy } from "nirium-arbitrum";

app.use(x402Serve({ payTo: "0x...", network: "eip155:421614", routes: { "GET /data": "$0.01" } }));

const pay = createX402Fetch({ signer: account, network: "eip155:421614", maxAmountPerPayment: "10000",
  policy: createRulesPolicy({ maxAmount: "10000" }) });
const res = await pay("https://seller.example/data");
const receipt = await bindReceipt({ tx: settlementOf(res).transaction, network: "eip155:421614", ref: "order-42", signer: account });

x402Serve runs on your server: Nirium runs nothing in the middle and receives nothing.

Tests

Suite Command Network
Verifier core (hash against node:crypto, EIP-191, the full check on recorded RPC answers, altered fields) cd arbitrum && npm ci && npm run test:verify none
Verifier, 10 cases against a real Arbitrum One payment (the team's own selftest) cd arbitrum && npm ci && bash run-tests.sh public Arbitrum One RPC
Pre-sign policy, 19 tests cd arbitrum && npm ci && npm run test:policy none
Library cd arbitrum && npm ci && npm run test:sdk one test reads the public Arbitrum Sepolia RPC
Market cd arbitrum && npm ci && cd market && npm ci && npm test none

CI runs all of them on every pull request. The verifier fixtures point at the team's own selftest payment and are labeled as such: they test the verifier, they are not usage of this project.

Rules this code follows

  • Non-custodial: every key belongs to whoever pays or receives. Nirium never holds one.
  • Mainnet payments need an explicit opt-in on the client (NIRIUM_ALLOW_MAINNET=1 or allowMainnet: true).
  • Settlement is done by PayAI, an independent facilitator. Nirium runs no facilitator.
  • Receipts are tamper-evident, not tamper-proof: an edited receipt no longer matches its hash or its signature. A receipt does not prove that goods or a service were delivered.
  • Keys never go in this repo. The key script writes outside it and refuses to run inside it.

Security

See SECURITY.md. Please report vulnerabilities privately, not in a public issue.

License

Apache-2.0

About

Payment-bound receipts and a pre-sign policy for x402 payments on Arbitrum

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages