GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — nirium-avalanche/avalanche at main · nirium-protocol/nirium-avalanche

Expand file tree

/

avalanche

/
Copy path

Directory actions

More options

More options

Directory actions

More options

More options

Latest commit

 

History

History
History
/

avalanche

/
Copy path

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
erc8004-fuji
erc8004-fuji
 
 
fixtures
fixtures
 
 
fuji-demo
fuji-demo
 
 
market
market
 
 
policy
policy
 
 
sdk
sdk
 
 
test
test
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
make-fixtures.mjs
make-fixtures.mjs
 
 
package-lock.json
package-lock.json
 
 
package.json
package.json
 
 
run-tests.sh
run-tests.sh
 
 
verify-evm-core.mjs
verify-evm-core.mjs
 
 
verify-evm-receipt.mjs
verify-evm-receipt.mjs
 
 

README.md

nirium-avalanche

Pay and charge with x402 on Avalanche, refuse a payment before it is signed, and keep a payer-signed receipt bound to the exact USDC Transfer log.

The chain already shows who paid whom, how much and when. The receipt adds what the chain does not keep: which order the payment was for and who declared it. Anyone can check it against Avalanche with a public RPC. Part of Nirium. Source, tests and the team's test payments: nirium-avalanche.

npm install nirium-avalanche
import { x402Serve, createX402Fetch, settlementOf, bindReceipt, verifyReceipt, createRulesPolicy } from "nirium-avalanche";

// Charge for your own API. Runs on your server: Nirium runs nothing in the middle.
app.use(x402Serve({ payTo: "0x...", network: "eip155:43113", routes: { "GET /data": "$0.01" } }));

// Pay, with a policy: a payment it refuses is never signed.
const pay = createX402Fetch({ signer: account, network: "eip155:43113", maxAmountPerPayment: "10000",
  policy: createRulesPolicy({ maxAmount: "10000" }) });
const res = await pay("https://seller.example/data", { headers: { "X-Nirium-Ref": "order-42" } });

// A payer-signed receipt bound to the transfer, and its check against the chain.
const receipt = await bindReceipt({ tx: settlementOf(res).transaction, network: "eip155:43113", ref: "order-42", signer: account });
const { ok } = await verifyReceipt(receipt);

account is a viem account for the payer's own key. Networks: Avalanche Fuji and C-Chain mainnet (mainnet needs allowMainnet: true). x402Serve needs express (4.22.3+ or 5.3.0+) in your app. Settlement is done by PayAI, an independent x402 facilitator.

Import What it is
nirium-avalanche x402Serve, createX402Fetch, settlementOf, bindReceipt, verifyReceipt, createRulesPolicy
nirium-avalanche/policy The pre-sign policy gate (decodes what is about to be signed, asks your policy, signs only on a bound ALLOW)
nirium-avalanche/policy/rules A small reference policy engine: max amount, approval line, allowlists
nirium-avalanche/receipt bindReceipt and verifyReceipt on their own, without the Express middleware
nirium-avalanche/decision Decision receipts: bindDecision, verifyDecision, collectDecisions (also exported from nirium-avalanche)
nirium-avalanche/verify The receipt verifier as a library. No Node-only code, so it runs in Node and in the browser

Check a receipt from the command line:

npx -p nirium-avalanche nirium-verify-evm receipt.json

Exit code 0 means valid, 1 means a check failed, 2 means bad input.

Receipts are tamper-evident, not tamper-proof, and they do not prove that goods or a service were delivered. Non-custodial: every key stays with whoever pays or receives. No external audit yet. Report security problems privately: SECURITY.md.

License: Apache-2.0

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.