Repository navigation
Conversation
Add a Nano (XNO) leg next to the Base USDC rail. When a server offers an exact accept on nano:mainnet and MCPC_X402_NANO_KEY is set, mcpc builds a Nano state send block, signs it (ed25519 with blake2b), and sends it in PAYMENT-SIGNATURE as payload.block. The block is not broadcast; the server publishes it to settle. - nano.ts: address encoding with checksum, state block hash, signing, account_info/block_info/work_generate over MCPC_X402_NANO_RPC. The frontier block's hash and signature are checked against the account key before its balance is used, since the send amount is the balance drop. - Refuses to sign without MCPC_X402_NANO_MAX_RAW or above it. - Accept selection only picks networks mcpc can sign for, so a Base-only setup is never handed a nano accept, and nano is exact-only. - blake2b/ed25519 come from @noble/hashes and @noble/curves, already in the lockfile through viem, now listed as devDependencies at the same versions and bundled through the viem boundary module.
This branch has not been deployed
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.
Problem
mcpc can only pay x402 on Base. A server that also offers an
exactaccept onnano:mainnetcannot be paid in XNO. Selection also takes the first validexactentry on any network, so a list that starts with a network mcpc cannot sign for (nano, oreip155:1) fails with "Unknown network" even when a Base entry follows it.Change
src/lib/x402/nano.ts:nano_addresses with checksum, state block hash (blake2b), signing (ed25519 with blake2b-512), andaccount_info/block_info/work_generateagainstMCPC_X402_NANO_RPC. In Nano the amount sent is the balance drop, so the RPC is not trusted for the balance: the frontier block's hash and signature are checked against the account key first. The signed block goes inPAYMENT-SIGNATUREaspayload.block+payload.hashand is not broadcast. The server publishes it.signer.ts: dispatch onnano:mainnet(exact only). Selection only picks accepts mcpc can sign for, and nano only whenMCPC_X402_NANO_KEYis set. The no-match error lists networks, including nano.MCPC_X402_NANO_MAX_RAWor above it.--amount(USD) is refused for nano.@noble/hashes1.8.0 and@noble/curves1.9.1 are already in the lockfile through viem. They are now devDependencies at those exact versions and exported from the viem boundary module, so they get bundled like viem. No new package is installed. Bundle: 690 -> 726 KiB.check:referenceup to date).Verification
Node v22.22.0, pnpm 10.33.4:
pnpm install --frozen-lockfile && pnpm run build && pnpm run test:unit && pnpm run lintTest Files 58 passed (58),Tests 1345 passed (1345)Test Files 59 passed (59),Tests 1363 passed (1363). Lint shows 0 errors and the same 24 warnings as main.The new
signer.test.tsrun against main's source:Tests 8 failed | 30 passed (38). For example,skips nano accepts when no Nano key is configured:expected 'nano:mainnet' to be 'eip155:84532'. All of them pass on this branch.Vectors in
nano.test.ts:nano_3i1aq1cchnmbn9x5rsbap8b15akfh7wj7pwskuzi7ahz8oq6cobd99d4r3b7(RPC docsdeterministic_key)block_hashexample ->FF0144…4F17Built CLI against a local fake RPC:
x402 signrefused without the key, without the cap and above it, and with all three set printed the same block as the test.Risks
payload.blockin nodeprocessJSON,payload.hash) is a proposal, and servers must verify it and broadcast it.x402 init/import --nano. A Base wallet is still required. Bridges read the env when they start.amountUsdis 0 for nano, sox402 sign --jsonprintsamount: 0. UseamountAtomicUnits(raw).