Skip to content
This repository was archived by the owner on Nov 27, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion avalanche/erc8004-fuji/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ node register.mjs --uri ipfs://<agent card CID>

# 3. Validation request (sent by the owner or operator of agentId)
node validation-request.mjs --validator 0x<validator> --agent-id <n> \
--cid <receipt CID> --receipt ./receipt.json [--dry-run]
(--cid <receipt CID> | --uri <https URL pinned to a commit>) --receipt ./receipt.json [--dry-run]

# 4. Validator response (only the address named in step 3)
node validation-response.mjs --request-hash 0x<requestHash> --response <0-100> \
Expand Down Expand Up @@ -97,3 +97,5 @@ key in the environment.
- Fuji's public RPC rejects `eth_getLogs` over more than 100 blocks.
- Routescan returns `logIndex` as `"0x"` when it is 0. Already handled.
- `samples/sample-receipt.json` is a synthetic receipt for dry runs. It is not real.
- Live writes sign locally (`sendSimulated` in `common.mjs`). Reusing a simulated request as is
makes viem ask the RPC to sign (`eth_sendTransaction`), which public RPCs refuse.
7 changes: 7 additions & 0 deletions avalanche/erc8004-fuji/common.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ export function walletFor(signer) {
return createWalletClient({ account: signer, chain: avalancheFuji, transport: http(RPC_URL) });
}

// Sends a simulated request signed locally. The simulation was run with the account as a plain
// address, so its request carries an address; without overriding it, viem would ask the RPC to
// sign (eth_sendTransaction), which public RPCs refuse.
export function sendSimulated(signer, request) {
return walletFor(signer).writeContract({ ...request, account: signer });
}

// Simulates and estimates gas. Returns { request, result, gas } or throws with the revert reason.
export async function simulateAndEstimate({ address, abi, functionName, args, account }) {
try {
Expand Down
4 changes: 2 additions & 2 deletions avalanche/erc8004-fuji/register.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import { parseEventLogs } from "viem";
import { identityAbi } from "./abi.mjs";
import {
IDENTITY_REGISTRY, EXPLORER_TX, publicClient, parseArgs, need, resolveAccount, walletFor,
IDENTITY_REGISTRY, EXPLORER_TX, publicClient, parseArgs, need, resolveAccount, sendSimulated,
simulateAndEstimate, gasReport, run,
} from "./common.mjs";

Expand All @@ -27,7 +27,7 @@ run(async () => {

if (args["dry-run"]) { console.log("--dry-run: nothing sent."); return; }

const hash = await walletFor(signer).writeContract(sim.request);
const hash = await sendSimulated(signer, sim.request);
console.log(`tx sent ${hash}`);
const receipt = await publicClient.waitForTransactionReceipt({ hash });
if (receipt.status !== "success") throw new Error(`tx reverted in block ${receipt.blockNumber}`);
Expand Down
14 changes: 8 additions & 6 deletions avalanche/erc8004-fuji/validation-request.mjs
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
// validationRequest(validator, agentId, requestURI, requestHash) on the Fuji ValidationRegistry.
// requestHash = keccak256 of the receipt file's EXACT bytes.
// Usage:
// node validation-request.mjs --validator <address> --agent-id <n> --cid <CID> --receipt <file.json>
// node validation-request.mjs --validator <address> --agent-id <n> (--cid <CID> | --uri <url>) --receipt <file.json>
// [--dry-run [--from <address>]]
// Key (live runs only): env NIRIUM_EVM_AGENT_KEY (owner or operator of agentId). Never printed.
import { parseEventLogs, zeroAddress } from "viem";
import { identityAbi, validationAbi } from "./abi.mjs";
import {
IDENTITY_REGISTRY, VALIDATION_REGISTRY, EXPLORER_TX, publicClient, parseArgs, need, asAddress,
hashFile, resolveAccount, walletFor, simulateAndEstimate, gasReport, run,
hashFile, resolveAccount, sendSimulated, simulateAndEstimate, gasReport, run,
} from "./common.mjs";

run(async () => {
const args = parseArgs();
const validator = asAddress(need(args, "validator"), "--validator");
const agentId = BigInt(need(args, "agent-id"));
const cid = need(args, "cid").replace(/^ipfs:\/\//, "");
const receiptPath = need(args, "receipt", "receipt JSON file, exactly as uploaded to IPFS");
const requestURI = `ipfs://${cid}`;
// --uri takes any URI (e.g. an https URL pinned to a commit); --cid builds ipfs://<CID>.
const requestURI = typeof args.uri === "string"
? args.uri
: `ipfs://${need(args, "cid", "or pass --uri <url>").replace(/^ipfs:\/\//, "")}`;
const receiptPath = need(args, "receipt", "receipt JSON file, byte-for-byte what the URI serves");
const { hash: requestHash, size } = hashFile(receiptPath);
const { account, signer } = resolveAccount(args, "NIRIUM_EVM_AGENT_KEY");

Expand Down Expand Up @@ -49,7 +51,7 @@ run(async () => {

if (args["dry-run"]) { console.log("--dry-run: nothing sent."); return; }

const hash = await walletFor(signer).writeContract(sim.request);
const hash = await sendSimulated(signer, sim.request);
console.log(`tx sent ${hash}`);
const receipt = await publicClient.waitForTransactionReceipt({ hash });
if (receipt.status !== "success") throw new Error(`tx reverted in block ${receipt.blockNumber}`);
Expand Down
4 changes: 2 additions & 2 deletions avalanche/erc8004-fuji/validation-response.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { parseEventLogs, zeroHash } from "viem";
import { validationAbi } from "./abi.mjs";
import {
VALIDATION_REGISTRY, EXPLORER_TX, publicClient, parseArgs, need, asBytes32, hashFile,
resolveAccount, walletFor, simulateAndEstimate, gasReport, run,
resolveAccount, sendSimulated, simulateAndEstimate, gasReport, run,
} from "./common.mjs";

run(async () => {
Expand Down Expand Up @@ -48,7 +48,7 @@ run(async () => {

if (args["dry-run"]) { console.log("--dry-run: nothing sent."); return; }

const hash = await walletFor(signer).writeContract(sim.request);
const hash = await sendSimulated(signer, sim.request);
console.log(`tx sent ${hash}`);
const receipt = await publicClient.waitForTransactionReceipt({ hash });
if (receipt.status !== "success") throw new Error(`tx reverted in block ${receipt.blockNumber}`);
Expand Down
38 changes: 38 additions & 0 deletions evidence/2026-11-26/cchain-a3-binding.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"version": "nirium-payment-binding-v1",
"content_sha256": "63fc6fbcac0c8abbc8f111a07a1bcf221c4f663801a318071618a27e67a9300d",
"record": {
"labels": [
"selftest"
],
"payment": {
"amount": "10000",
"asset": "0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",
"decimals": 6,
"from": "0xe3b9cEdab108E29081c93E5F5c9754B7949E87a7",
"locator": {
"index": 12,
"kind": "evm-log"
},
"network": "eip155:43114",
"to": "0x29d3cd4944B29972f2D54e48c6076e8911Cb1Bd5",
"tx": "0x9b718e4249efea418291da2cb4169dcfc344e0b1794d2a2937c7fa08dc4d3f83",
"x402": {
"nonce": "0xb1d403e33b1899e272dc5c6c1ce5c42ddf5c392a9ba15642ef15b27c325fea09",
"resource": "http://localhost:4021/paid",
"scheme": "exact"
}
},
"purpose": {
"note": "Nirium sprint day 1 selftest on Avalanche C-Chain mainnet",
"ref": "selftest-2026-11-26-cchain-01"
}
},
"agent": {
"alg": "eip191-secp256k1",
"key": "0xe3b9cEdab108E29081c93E5F5c9754B7949E87a7",
"signature": "0x60db53cf09ef952895dffd2dbfbeba41e9b4bfd9adfd8dcfd8836f60c6ebcc9b74a21921f8498349eb293d98f450acaf8ad79a2d39c7796980ac0dff82c240b01c",
"statement": "nirium-audit-v1:63fc6fbcac0c8abbc8f111a07a1bcf221c4f663801a318071618a27e67a9300d"
},
"network": "eip155:43114"
}
101 changes: 101 additions & 0 deletions evidence/2026-11-26/fuji-a2-validation-review.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
{
"version": "nirium-validation-review-v1",
"subject": "evidence/2026-11-26/fuji-a2-binding.json",
"subjectNetwork": "eip155:43113",
"verifier": "avalanche/verify-evm-receipt.mjs",
"result": "VALID",
"score": 100,
"checks": [
{
"name": "version == nirium-payment-binding-v1",
"ok": true,
"detail": "version=nirium-payment-binding-v1"
},
{
"name": "network == record.payment.network",
"ok": true,
"detail": "doc=eip155:43113 payment=eip155:43113"
},
{
"name": "locator.kind == evm-log",
"ok": true,
"detail": "kind=evm-log"
},
{
"name": "content_sha256 == sha256(canonical(record))",
"ok": true,
"detail": "doc=09739cb9bd6dbefc7b381e2559061a0b93600a4ac3664cbd99c3505f5b9b3651 computed=09739cb9bd6dbefc7b381e2559061a0b93600a4ac3664cbd99c3505f5b9b3651"
},
{
"name": "asset is Circle USDC for this network",
"ok": true,
"detail": "asset=0x5425890298aed601595a70AB815c96711a31Bc65 expected=0x5425890298aed601595a70AB815c96711a31Bc65"
},
{
"name": "decimals == 6",
"ok": true,
"detail": "decimals=6"
},
{
"name": "network == eip155:<RPC chainId>",
"ok": true,
"detail": "rpc chainId=43113"
},
{
"name": "tx status success (1)",
"ok": true,
"detail": "status=success block=61670610"
},
{
"name": "log 1 emitted by asset",
"ok": true,
"detail": "emitter=0x5425890298aed601595a70ab815c96711a31bc65"
},
{
"name": "log 1 is Transfer",
"ok": true,
"detail": "event=Transfer"
},
{
"name": "Transfer.from == payment.from",
"ok": true,
"detail": "log=0x9deC1D6AD171bEb9b0cFd5AfC27895346f49637D"
},
{
"name": "Transfer.to == payment.to",
"ok": true,
"detail": "log=0x241d8C05f2a33F8701B933B704d329CC88367007"
},
{
"name": "Transfer.value == payment.amount",
"ok": true,
"detail": "log=10000 record=10000"
},
{
"name": "AuthorizationUsed(payment.from, x402.nonce) in same tx",
"ok": true,
"detail": "found 1: 0x9deC1D6AD171bEb9b0cFd5AfC27895346f49637D/0x1cf30f775fe29264b96d700fc09d7cbb46b91afbec5b32d4f1c01e3247b38be5"
},
{
"name": "agent.alg == eip191-secp256k1",
"ok": true,
"detail": "alg=eip191-secp256k1"
},
{
"name": "agent.statement == nirium-audit-v1:<content_sha256>",
"ok": true,
"detail": "statement=nirium-audit-v1:09739cb9bd6dbefc7b381e2559061a0b93600a4ac3664cbd99c3505f5b9b3651"
},
{
"name": "agent.key == payment.from (payer signs)",
"ok": true,
"detail": "key=0x9deC1D6AD171bEb9b0cFd5AfC27895346f49637D"
},
{
"name": "EIP-191 signature by agent.key over agent.statement",
"ok": true,
"detail": ""
}
],
"note": "Team self-test: the validator key is also a team key. This shows the ERC-8004 mechanics, not an independent third-party validation."
}
6 changes: 6 additions & 0 deletions evidence/2026-11-26/fuji-agent-card.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "Nirium selftest agent (Avalanche Fuji)",
"description": "Test agent used by the Nirium team to point ERC-8004 validation requests at Nirium payment-binding receipts. Self-test only; not a production agent.",
"receiptFormat": "nirium-payment-binding-v1",
"repository": "https://github.com/nirium-protocol/nirium-multichain"
}
30 changes: 26 additions & 4 deletions evidence/README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,40 @@
# Evidence

Every payment here was made by the team to test the flow. They are labeled `selftest` and are
**not usage**. Each receipt can be checked by anyone with the verifier and a public RPC:
**not usage**. Mainnet payments used a few cents from the team's own funds. Each receipt can be
checked by anyone with the verifier and a public RPC:

```bash
cd solana && npm ci && node verify-svm-receipt.mjs ../evidence/2026-11-26/solana-devnet-s2-binding.json
cd avalanche && npm ci && node verify-evm-receipt.mjs ../evidence/2026-11-26/fuji-a2-binding.json
cd avalanche && npm ci && node verify-evm-receipt.mjs ../evidence/2026-11-26/cchain-a3-binding.json
```

## Payments

| Date (UTC) | Network | Transaction | Locator | Amount | Receipt | Verifier |
|---|---|---|---|---|---|---|
| 2026-11-26 14:59 | Avalanche Fuji (`eip155:43113`) | [`0x7ca309a4…29f9`](https://testnet.snowtrace.io/tx/0x7ca309a41b019393d2d9e77ec89aff54a2d644b37657b8f2eaa93331cc6429f9) | logIndex 1 (block 61670610) | 0.01 USDC | `2026-11-26/fuji-a2-binding.json` | VALID, payer-signed |
| 2026-11-26 15:00 | Solana devnet | [`2uyixpix…bWwj`](https://explorer.solana.com/tx/2uyixpix6haUfxhzRfMNkFJJaTxngKJ7WNqMLLRQL4vee6MzME5Jwmrg82p7gdbfDq1ds6hw7Lq9tiEL5foZbWwj?cluster=devnet) | top-level ix 2, tx v0, Memo = order ref | 0.01 USDC | `2026-11-26/solana-devnet-s2-binding.json` | VALID, payer-signed |
| 2026-11-26 15:32 | **Avalanche C-Chain mainnet** (`eip155:43114`) | [`0x9b718e42…3f83`](https://snowtrace.io/tx/0x9b718e4249efea418291da2cb4169dcfc344e0b1794d2a2937c7fa08dc4d3f83) | logIndex 12 (block 101457077) | 0.01 USDC | `2026-11-26/cchain-a3-binding.json` | VALID, payer-signed |

All three were x402 `exact` payments settled by the PayAI facilitator. The C-Chain one was
settled by a PayAI relayer through Multicall3, so the transaction's `to` is not the USDC
contract: the receipt is bound to the specific `Transfer` log, which is why the locator is a log
index. The testnet receipts were also checked against altered copies of themselves (amount,
locator, receiver, nonce or memo, an edited `purpose`, an altered signature): every altered copy
failed for the expected reason.

## ERC-8004 on Avalanche Fuji

The Fuji receipt above was put through the ERC-8004 validation flow on Fuji:

| Step | Transaction | Result |
|---|---|---|
| `register` (agent card `2026-11-26/fuji-agent-card.json`) | [`0xd91c19b3…1e43`](https://testnet.snowtrace.io/tx/0xd91c19b316e1663d1949b917d92039685ae6b13a93d73bac0927b08aa8b21e43) | agentId 368 |
| `validationRequest` pointing at the receipt | [`0x59de4635…36dc`](https://testnet.snowtrace.io/tx/0x59de463597b207102865f6233dd522257aa7bee116e3609c8c98b728dcb736dc) | requestHash `0xb4a812b5…e3e1` = keccak256 of the receipt file's bytes |
| `validationResponse` by the validator | [`0x7dc27e71…4a58`](https://testnet.snowtrace.io/tx/0x7dc27e71afb3d801b596bcc76ce51c41b3aebdba6cf9ed3ac5a7280e1da44a58) | response 100, tag `nirium-payment-binding-v1`, review `2026-11-26/fuji-a2-validation-review.json` |

Both were x402 `exact` payments settled by the PayAI facilitator. Each receipt was also checked
against altered copies of itself (amount, locator, receiver, nonce or memo, an edited
`purpose`, an altered signature): every altered copy failed for the expected reason.
The URIs point at this repo pinned to commit `9321ce8`, so their content cannot change; the
request and response hashes bind the exact bytes. The validator is the payTo key, which is also a
team key: this shows the ERC-8004 mechanics, not an independent third-party validation.