Repository navigation
Conversation
Add an experimental x402 network family for Nano beside EVM, Solana and NEAR. The buyer publishes a send block of native XNO to payTo and presents its hash; the gateway reads the block from the offer's Nano node with block_info and requires a confirmed state send to payTo of at least the offered raw amount. No facilitator is called, no key is held and nothing is broadcast. The block hash is the replay key, settle reads the block again under the replay reservation, and a node that does not answer is PAYMENT_PROVIDER_UNAVAILABLE. Addresses are checked with their BLAKE2b checksum (nano_ and legacy xrb_). XNO has no USD rate in the gateway, so a resource with a Nano offer must be priced in XNO and list only Nano offers.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
NICE-TO-HAVE,experimental. An optional offer family; EVM, Solana and NEAR offers are unchanged.Problem
Nano (XNO) is feeless and fast, which suits per-call agent payments. Today
findX402Network('nano:mainnet')returnsundefined, and config load refuses a Nano offer.Change
nanofamily and anano:mainnetprofile: native XNO, 30 decimals,asset: XNO.nano-address.ts(no SDK) checksnano_andxrb_addresses, including the BLAKE2b-40 checksum. Node'scryptohas only 64-byte BLAKE2b, so a short RFC 7693 one is inlined; no new dependency.nano.ts, loaded lazily likenear.ts. The payload is{ blockHash }. Verify callsblock_info(json_block) on the offer'srpcUrland requires a confirmedstatesendwithlink_as_account == payToand amount >= the offer's raw amount. The replay key is sha256 of the network and the hash. Settle re-reads the block under the replay reservation; nothing is sent. No facilitator call, no key, no broadcast.PAYMENT_PROVIDER_UNAVAILABLE. Settle also setssettlementNotSubmitted, so the attempt is released for a retry.versionmust reportnetwork: live.XNOand list only Nano offers; config load andcreateRequirementrefuse anything else. Use a resource's ownx402.accepts; others keep USDC.experimentalmatrix rows. Contract surface unchanged.Tests
Mocked RPC or stubbed
fetchonly; the facilitator mock is asserted never called.nano.test.ts: BLAKE2b vs node'sblake2b512; genesis address round-trip;xrb_alias; bad checksum and malformed addresses; payload and verifier refusals.provider-nano.test.tsnegative cases: no payment block, malformed hash, wrong amount, wrong recipient, wrong network, wrong asset, unconfirmed block, receive block, node down. Also a USD price refused.integration/x402-nano.test.ts: config cases, and a gateway run of 402, then 200, then the same hash refused withPAYMENT_REPLAYED. The backend is called once.Against master's sources, these tests fail (40 failures: "nano:mainnet is not a known network").
What I ran (Node 22.22.0)
npm ci && npm test: before, 129 files, 2665 passed / 35 skipped. After, 132 files, 2726 passed / 35 skipped.npm run check:contractpasses (88 symbols, unchanged);npm run lintandnpm run typecheckare clean.check:metadata,build,test:cli:distand the packaging test pass.npm run test:coverage: without Foundry, thesrc/payments/**branch threshold fails on master (87.06%) and on this branch (87.45%).test:e2e, Docker, a live Nano node.Limits
payTo, so use apayTothat receives only gateway payments.amountBaseUnitsrecords what was sent.facilitatorblock and mainnet guardrails still apply, though Nano never calls the facilitator.