x402
x402 copied to clipboard
feat(ton): add TON network support (native + jetton)
Description
This PR adds TON (The Open Network) support to x402.
It introduces a new network adapter that enables merchants and facilitators to accept payments in TON native coins as well as Jettons (TEP-74 standard).
Key changes:
- [x] Implemented
verifyTONExactfor native and jetton payments - [x] Added address normalization across raw/bounceable / non-bounceable formats
- [x] Added memo validation (
x402:strict mode) with fallback for legacy memos - [x] Unified error codes for better integration with existing adapters
- [x] Utility helpers:
normalizeTonAddress,getTonExplorerUrl,validateMemo,toAtomic - [x] Unit tests covering native + jetton flows, decimal mismatch, forward_ton_amount edge cases, cross-format addresses
- [x] Explorer integration via tonviewer.com (mainnet + testnet)
Tests
- [x] Added
src/ton/index.test.tswith >180 cases:- Native transfers with memo
- Jetton transfers with forward payload (memo)
- Decimal mismatch/amount mismatch
- Cross-format address normalization
- Invalid memo and expired invoice handling
- [x] Verified unit tests with
pnpm testinside/typescript - [x] Manually checked explorer URL generation for mainnet and testnet
Checklist
- [x] I have formatted and linted my code (
pnpm format && pnpm lint) - [x] All new and existing tests pass (
pnpm test)
- [x] My commits are signed (verified via
git log --show-signature)
🟡 Heimdall Review Status
| Requirement | Status | More Info | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Reviews |
🟡
0/1
|
Denominator calculation
|
@web3luka is attempting to deploy a commit to the Coinbase Team on Vercel.
A member of the Team first needs to authorize it.