feat(x402): support USDT payments on BNB Smart Chain#455
Merged
Conversation
The Nansen API now advertises USDT on BNB Smart Chain (eip155:56) as an x402 payment option. Payment signing already handles any EVM network generically (chain id, token contract, and EIP-712 domain all come from the 402 accepts entry), so this wires up the remaining network-specific piece: the post-payment balance check. - Add eip155:56 to the EVM payment-token registry (now exported as EVM_X402_TOKENS) with the BSC USDT contract and 18-decimal precision — the existing tokens (Base USDC, X Layer USDT0) use 6 decimals, so the divisor is now per-token instead of a hardcoded 1e6. - Add bsc to CHAIN_RPCS with a NANSEN_BSC_RPC override, matching the existing per-chain env-var pattern. - Tests for the registry (networks, decimals, token contracts, RPCs). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
kome12
approved these changes
Jun 11, 2026
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.
What
The Nansen API now advertises USDT on BNB Smart Chain (
eip155:56) as an x402 payment option. This PR adds BSC support to the CLI's x402 auto-payment flow.Why almost everything already worked
Payment signing is network-generic: the chain id, token contract, recipient, amount, and EIP-712 domain (
extra.name/extra.version) are all taken from the 402acceptsentry, and the fallback loop inapi.jsalready tries each advertised network in order. So a wallet holding BSC USDT could already pay — but the post-payment balance check was wrong for BSC.Changes
src/x402.js— the per-network EVM token map (now exported asEVM_X402_TOKENS) gainseip155:56(BSC USDT0x55d398…7955) and a per-tokendecimalsfield. BSC USDT uses 18 decimals, unlike the 6-decimal Base USDC / X Layer USDT0, so the previous hardcoded1e6divisor would have reported balances off by 10¹².src/rpc-urls.js— addbsctoCHAIN_RPCS(defaulthttps://bsc-dataseed.binance.org, override withNANSEN_BSC_RPC), matching the existing per-chain pattern.src/__tests__/x402-balance.test.js— registry tests: covered networks, decimals, pinned token contracts, RPC resolution.Testing
vitest run— x402 suites green (11/11 in the touched areas); full suite 1490 passed with one unrelated flake inupdate-check.test.js(passes in isolation, before and after this change).🤖 Generated with Claude Code