All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
- Adopted
developas the integration branch and retainedmainfor stable releases. - Added enforced pull request routes for development, release, and hotfix branches.
- Added automated pull request title and description validation.
- Added pull request CI for policy tests, formatting, linting, build, and unit tests.
- Removed the root
legacy/archive containing the retired Python SDK, old TypeScript SDK, and superseded examples and specifications. The compatibility npm packages undertypescript/packages/legacy/remain supported by the current workspace.
- Upgrade all 11
@bankofai/x402-*packages together; published internal dependencies resolve to~1.1.0. - Custom money parsers now receive decimal strings. Convert only for comparisons and preserve the string for token-amount conversion.
- TRON integrations should use canonical CAIP-2 identifiers:
tron:0xcd8690dc(Nile),tron:0x94a9059e(Shasta), andtron:0x2b6653dc(mainnet). - ERC-6492 facilitator deployments require an explicit
eip6492AllowedFactoriesallowlist.
- Explicit
authorization,upfront, andescrowpayment-flow orchestration across core, HTTP, and MCP transports. - Client spend caps, transaction limits, payment-selection policies, and lifecycle hooks.
- EVM support for deployed smart accounts, ERC-7702 delegation, and allowlisted ERC-6492 counterfactual wallets.
- Builder-code multi-service attribution, expanded SIWX validation, and dynamic extension-field handling.
- Legacy v1.0
SchemeNetworkServerimplementations may omit payment-flow declarations and continue using the authorization flow. HTTPFacilitatorClientnow uses typed timeout errors, rate-limit retries, stricter response validation, and a 90-second default timeout.- EVM and TRON price conversion preserves decimal precision and token-symbol selection across supported server schemes.
- README, release notes, package changelogs, examples, and the Node.js requirement are aligned with the v1.1.0 package set.
- Restored BSC default assets and tightened EVM Permit2 and settlement-receipt validation.
- Normalized nullable MCP fields for cross-SDK interoperability while preserving existing response metadata.
- Hardened Express, Fastify, Hono, and Next.js route matching against encoded separators and line terminators.
- Added a forced release build to prevent stale generated declarations from entering npm tarballs.
- Format, lint, forced release build, and all 34 workspace test tasks pass.
- All 11 npm tarballs report version
1.1.0, rewrite internal dependencies to~1.1.0, and contain noworkspace:ranges or stale TRON fee declarations.
Implemented by @roger-gan in PR #83. See RELEASE_NOTES.md for the full release notes.
- TypeScript-only pnpm/turbo monorepo published as granular
@bankofai/x402-*packages (core,evm,tron,fetch,express,mcp,extensions). coreand the EVM mechanism forked from thex402-foundation/x402upstream; TRON mechanism is in-house.- Supported schemes:
exact(ERC-3009 / Permit2),upto,batch-settlement,auth-capture(EVM), andexact_gasfree(TRON). - BSC testnet USDT (
0x337610d2…, 18 dec, permit2) added to the expressexactexample alongside DHLU and USDC. - Mainnet USDT registered in the EVM default-asset registry (
eip155:56, permit2).
- Fetch client
TOKEN_ADDRESSESindexed by chain family soUSDTresolves to the correct contract per network (BSC testnet vs TRON Nile). - README aligned with the TypeScript-only SDK;
.env-exact.examplelists USDT among EVM token options. - The previous-generation Python + TypeScript SDK moved to
legacy/for reference.
- TRON facilitator settle receipt polling switched from
trx.getTransaction(fullNode preconfirm, which could transiently readREVERTon mainnet and cause false settle failures) to the fullNodegettransactioninfobyidendpoint, waiting forblockNumber+receipt.result. ~3-6s latency with authoritative results, mirroring tronpy'sget_transaction_info.
- BSC testnet USDT
exactend-to-end settle:0x477f00845964271d53cc36028756fa4ce260674ff6b103e6a86a47f2e79a9edd(SUCCESS). - TRON mainnet USDT
exacton-chain success:604f51c8…0acc(contractRet: SUCCESS); receipt-polling fix verified against this tx.
- TS facilitator client, facilitator engine, Hono / Express middleware, and fetch wrapper.
- TS facilitator signer layer (
FacilitatorSigner,EvmFacilitatorSigner,TronFacilitatorSigner) for off-chain typed-data verification, contract writes, balance checks, and receipt polling. - TS
exact,exact_permit, andexact_gasfreefacilitator verify + settle paths, matching the Python facilitator behavior. - Public TS exports for facilitator APIs, signer APIs, protocol constants, middleware, and updated mechanism constructors.
- TS facilitator mechanisms now use explicit facilitator signers, aligning the TypeScript API with Python's signer-injected facilitator model.
- Python package metadata is aligned to the final
0.6.0release version. exactfee quote now returns a zero-fee quote instead ofnull, matching the Python facilitator.
- TS TRON facilitator settlement derives the facilitator address from
TRON_FACILITATOR_PRIVATE_KEY/TRON_PRIVATE_KEYwhen direct private-key signing is enabled. This keeps the transaction owner address aligned with the key used by TronWeb signing and fixesPrivate key does not match address in transactionduringexact_permitsettle. - TS TRON facilitator startup warns when the direct-signing private key address differs from the agent-wallet active address, making stale keystore/env mismatches visible in QA logs.
- TS SDK build passed.
- TS SDK test suite passed: 19 files / 158 tests.
- x402-demo TypeScript flow verified on TRON Nile:
exact_gasfree:97ec5443edaf4bbe8633ee8fc0dc923c4809df4f95625718d1f33e499cf2313dexact_permit:ae91d7e02fea6855f22ffcb945dbf280ff526f72ef156f997e22d4cc8c053e80
- TS facilitator signer layer (
FacilitatorSigner,EvmFacilitatorSigner,TronFacilitatorSigner) for off-chain typed-data verification, contract writes, balance checks, and receipt polling. - TS
exactfacilitator settlement for EVM and TRON viatransferWithAuthorization. - TS
exact_permitfacilitator settlement for EVM and TRON viaPaymentPermit.permitTransferFrom. - TS
exact_gasfreefacilitator verify + settle via GasFree API proxy, matching the Python facilitator behavior. - Unit coverage for TS GasFree facilitator quote, verify, and settle paths.
- TS facilitator mechanism constructors now use explicit facilitator signers, aligning the TypeScript API with Python's signer-injected facilitator model.
exactfee quote now returns a zero-fee quote instead ofnull, matching the Python facilitator.
- TS SDK build passed.
- TS SDK test suite passed: 19 files / 158 tests.
- Published npm beta:
@bankofai/x402@0.6.0-beta.1under thebetadist-tag. - x402-demo TypeScript flow verified on TRON Nile:
exact_gasfree:97ec5443edaf4bbe8633ee8fc0dc923c4809df4f95625718d1f33e499cf2313dexact_permit:6aeccd9ff25e9c241b08082ea11149177597ae041daf6aa5dd6c0b7c0634d20a
FacilitatorClient(typescript/packages/x402/src/facilitator/client.ts) — TS 端补齐对远程 facilitator 的客户端调用(/supported、/fee/quote、/verify、/settle),与 Pythonbankofai.x402.facilitator.FacilitatorClient接口一致。X402Facilitator(typescript/packages/x402/src/facilitator/x402Facilitator.ts) — TS 端 facilitator 引擎,按(network, scheme)路由FacilitatorMechanism,支持 EVM 地址 checksum 规范化,与 Pythonbankofai.x402.facilitator.X402Facilitator接口一致。x402Hono/x402Expressserver middleware (typescript/packages/x402/src/middleware/) — Hono + Express 一行接入收费 API,框架无关核心逻辑封装在processX402Request。X402FetchClient增强 (typescript/packages/x402/src/http/client.ts) — 补齐put/patch/delete方法,支持注入fetchImpl/selector;新增parsePaymentResponseHeader()从成功响应里提取 settle receipt。FacilitatorError(typescript/packages/x402/src/errors.ts) — facilitator HTTP / 协议错误类型,含 status + body。- 公开协议常量
PAYMENT_SIGNATURE_HEADER/PAYMENT_REQUIRED_HEADER/PAYMENT_RESPONSE_HEADER。 - 测试覆盖:facilitator client (11) + facilitator engine (14) + middleware core (9) + Hono adapter (5) + Express adapter (4) + fetch client (7) = 50 个新测试,整体 101/101 通过。
- Hono 和 Express 加为
peerDependenciesMeta的可选 peer deps;不安装也能用框架无关核心。
test_nile_uses_default_without_api_key测试断言对齐 nile fallback RPC URL 行为(之前实现已加 fallback 但测试未跟上)。
- npm:
@bankofai/x402@0.6.0-beta.0 - PyPI:
bankofai-x402==0.6.0b0
- Exact V2 compatibility with Coinbase x402 Foundation spec —
exactscheme payload now conforms to the upstream V2 wire format for EVM and TRON - BSC Testnet (eip155:97) support with DHLU test token for
exactEVM payments - BSC testnet smoke test examples (TypeScript and Python) under
examples/bsc-testnet-smoke/ nativeExactEvmunit tests for EVM exact scheme- Server-side
x-payment-signatureverification tests (Python)
nativeExact/nativeExactEvm/nativeExactTronmechanisms updated to emit V2-compatible payloads (authorizationstructure with typed fields instead of flat hex blob)PaymentPayloadTypeScript type expanded to support both V1 and V2 payload shapes- Token registry (
tokens.ts) updated with BSC testnet DHLU entry - GasFree utility refactored for cleaner error handling and status polling
- TypeScript SDK local build restored for exact v2 (
package-lock.jsonregenerated) - Python
tx_verificationutility updated for V2 payload structure
- Minimum Node.js version raised from 18 to 20 (pnpm 10 requires Node >= 20)
- GasFree API endpoints now route through the BankOfAI proxy (
https://facilitator.bankofai.io/{mainnet,shasta,nile}) instead of the upstreamopen.gasfree.io/open-test.gasfree.ioendpoints — clients no longer need API keys or secrets getGasFreeApiBaseUrl()/get_gasfree_api_base_url()now throwsUnsupportedNetworkErrorfor unrecognised networks instead of returning a default fallback URL
GasFreeAPIClientnow supportsaclose()and async context manager (async with) for proper resource cleanup- Improved
GasFreeAPIClientreliability with better error handling and connection management
- HMAC-SHA256 signature authentication from
GasFreeAPIClient— the BankOfAI proxy handles auth transparently getGasFreeApiKey()/get_gasfree_api_key()andgetGasFreeApiSecret()/get_gasfree_api_secret()config helpers — no longer needed- Deprecation stubs for removed gasfree auth functions — clean break for the proxy migration
- Fallback RPC endpoint (
https://hptg.bankofai.io) for TRON mainnet whenTRON_GRID_API_KEYis not set — eliminates rate-limit failures for developers without a TronGrid API key getTronRpcUrl()helper in TypeScript for fallback-aware RPC URL resolutionTRON_MAINNET_FALLBACK_URLconstant in Python for consistent fallback endpoint reference- Warning messages (Python
logger.warning, TypeScriptconsole.warn) when the fallback endpoint is in use
resolveRpcUrl()in TypeScript now delegates togetTronRpcUrl()for TRON networks, ensuring fallback logic is applied consistentlyTronClientSigner.getTronWeb()usesgetTronRpcUrl()instead of directly indexingTRON_RPC_URLS
SufficientBalancePolicynow checks balance via the mechanism'scheck_balance()/checkBalance()method instead of querying the signer's wallet directly — fixes incorrect balance lookups for GasFree payments where spendable balance lives in a separate custodial address- Eliminated redundant GasFree API call in
create_payment_payloadby reusing the_check_gasfree_balancehelper - Removed unnecessary
awaiton synchronousgetAddress()in TypeScript GasFree mechanism - Fixed misleading test name that said "drops" but asserted "keeps"
check_balance()/checkBalance()method onClientMechanisminterface — mechanisms can override to check balance at the correct address for their payment schemeresolve_mechanism()/resolveMechanism()public method onX402Clientfor policies to look up mechanisms by scheme+network- Policy test suites for both Python and TypeScript covering sufficient/insufficient balance, missing mechanism, exception resilience, and all-unaffordable scenarios
SufficientBalancePolicynow drops requirements with no matching mechanism (previously kept them); safe within theX402Clientpipeline where mechanism filtering already runs upstream
- Handle null
datain GasFree status API responses that causedAttributeError/TypeErrorduring settlement polling - Retry transient HTTP errors during
waitForSuccesspolling instead of crashing the settlement flow - Abort polling after
max_errors(default: 3) consecutive failures to avoid silently retrying permanent errors until timeout - Reset error counter after each successful poll so only truly consecutive errors trigger abort
- Explicit null guards on all GasFree API response
datafields (getAddressInfo,getProviders,submit) - Guard
submitreturn value against missingidfield - Fix variable shadowing in Python
submit(messageparameter shadowed by local) - Use
is None/== nullchecks for precision (avoids false positives on falsy values)
GasFreeResponse<T>.datatyped asT | nullin TypeScript to reflect actual API contractgetStatus/get_statusreturn type widened to nullablewaitForSuccess/wait_for_successacceptsmax_errors/maxErrorsparameter (default: 3)- Timeout error messages now include error count for better observability
- Clamp GasFree client deadlines to provider bounds (mainnet: 50–600s, others: 50–3600s)
- Add a 5s safety margin: +5s to min and −5s to max to absorb clock drift and network latency
- When above provider max, clamp down (never extend beyond max); when below min, fail fast
- Align GasFree default deadline fallback to the per-network max to avoid noisy clamps
- Log when a GasFree deadline is clamped for easier diagnosis
- Align TRON mainnet GasFreeController address with GasFree SDK to prevent TIP-712 signature verification mismatches
- GasFree client signing logs (signer, domain, message) to aid signature debugging
- TypeScript GasFree TIP-712 signing now converts all address fields to EVM
0xformat before signing
- Tests to assert GasFree TIP-712 signing uses EVM-formatted addresses (TypeScript and Python)
- Refactored client and facilitator signers to accept wallet instances and resolve addresses through async factory methods
- Standardized signer integration around the agent-wallet
Walletcapability surface for message, typed-data, and transaction signing - Normalized TRON transaction signing by extracting signatures from wallet-signed transaction payloads when wallets return full signed transaction JSON
- GasFree activateFee support: When a TRON GasFree account is not yet activated,
activateFeefrom the API asset info is now included inmaxFeecalculation to prevent transaction failures due to insufficient fee allowance. - Comprehensive test coverage for activateFee edge cases (both Python and TypeScript SDKs):
- activateFee included when account not activated
- activateFee ignored when account already activated
- Zero activateFee handled correctly
- Missing activateFee field defaults to 0
- activateFee stacks on top of higher facilitator fee
- Balance check accounts for activateFee
SupportedResponse.feefield (Python and TypeScript) — fee info is now exclusively via/fee/quotepricingparameter fromX402Facilitator.supported()
- Added missing
schemeandassetfields to TypeScriptFeeQuoteResponseinterface SettleResponseerror paths now includenetworkfield inX402FacilitatorandX402ServerFacilitatorClientHTTP timeout increased from 30s to 120s for GasFree settlement
- GasFree Support: Full integration for the GasFree payment scheme on TRON. Users can pay with USDT/USDD without holding TRX for gas.
- Facilitator Provider Selection:
ExactGasFreeFacilitatorMechanism.fee_quote()selects a GasFree provider and returns it viafeeTo/caller. Clients use the provider fromrequirements.extra.feewith automatic fallback to the GasFree API. - GasFree Facilitator Validation: Comprehensive permit validation including token whitelist, fee amount floor, deadline expiry, and provider allowlist checks.
- Transaction Polling: Facilitator supports asynchronous polling for GasFree transaction status (
SUCCEED/FAILED) with a 3-minute grace period. - Cross-Language Integration: Validated interoperability between TypeScript Client and Python Facilitator for both
exact_permitandexact_gasfreepayments.
- Signer Refactor: Standardized EIP-712 / TIP-712 signers to be Domain Neutral.
sign_typed_dataandverify_typed_datanow require an explicitprimary_typeargument. - EIP-712 Type Definitions:
EIP712Domainis no longer included in type dictionaries — domain is passed separately, consistent with ethers v6 / TronWeb v6 conventions. - Constants Standardized: Standardized naming for protocol-specific EIP-712 constants (
GASFREE_PRIMARY_TYPE,PAYMENT_PERMIT_EIP712_DOMAIN_TYPE). - Client Fee Logic:
maxFeecalculated asmax(transferFee, facilitatorFee), with fallback to 1 token only when no fee info is provided. @gasfree/gasfree-sdkImport: Uses default import with destructuring for CJS/ESM compatibility.- Improved Logging: Enhanced facilitator audit logs and resource usage tracking.
- Pydantic Models: Consistent field naming across response models. Optional
web3.pydependency handling in EVM signers.
- tronpy client now supports TronGrid API key via
TRON_GRID_API_KEY
0.1.5 - 2026-02-05
- Multi-network facilitator support (Nile and Mainnet simultaneously)
- Async transaction verification with AsyncTron client
- Updated PaymentPermit contract addresses:
- Mainnet:
THnW1E6yQWgx9P3QtSqWw2t3qGwH35jARg - Shasta:
TVjYLoXatyMkemxzeB9M8ZE3uGttR9QZJ8 - Nile:
TQr1nSWDLWgmJ3tkbFZANnaFcB5ci7Hvxa
- Mainnet:
- Server automatically fetches facilitator address from
/supportedendpoint - Removed
max_amountfilter fromPaymentRequirementsFilter - All tronpy operations converted to AsyncTron with proper async/await
- Simplified transaction verification to status check only (60s timeout)
- Fixed on-chain transaction failure:
permit.callernow matches facilitator address - Fixed contract ABI to match new PaymentPermit deployment
- Fixed all linting and formatting issues
- Fixed test imports to use new mechanism names
0.1.4 - 2026-02-05
- x402 payment protocol implementation for TRON blockchain
- Support for TRON Mainnet, Nile, and Shasta testnets
- TIP-712 (TRON's EIP-712) signature support
- "upto" payment scheme for pay-per-use APIs
X402Server- Resource server with payment protectionX402Client- Client SDK for creating payment permitsX402Facilitator- Facilitator server for payment settlementX402HttpClient- HTTP client with automatic 402 handling- FastAPI integration via
x402_protecteddecorator - TRON client, server, and facilitator mechanisms
- TIP-712 signers for TRON
- Token registry with USDT support
- Comprehensive test suite
X402Client- Core payment clientX402FetchClient- Fetch-based HTTP client with automatic 402 handlingUptoTronClientMechanism- TRON payment mechanismTronClientSigner- TIP-712 signature support- Token approval management
- Full TypeScript type definitions
- Examples moved to separate repository: x402-tron-demo