Package com.tnsai.payment.x402
package com.tnsai.payment.x402
x402 adapter for the
PaymentBroker SPI shipped
by tnsai-core in v0.9.4 (TNS-298).
This module is the first concrete payment-rail adapter under TNS-449. It lives in its own Maven module on purpose — the EVM crypto stack adds non-trivial transitive surface, and the framework's "lightweight by default" promise means agents that don't pay shouldn't compile-time-pull web3 deps.
What's shipped in P2 (this version)
Network— EVM / Solana network catalogue.EIP712TypedData— the 32-byte domain-separator + struct-hash pair the wallet needs to sign.Wallet— SPI a payer plugs their signing strategy into, with aWallet.Factoryand ServiceLoader-baseddiscover().WalletSpec— config bag the factory reads to instantiate a wallet.InMemoryWallet— test-only impl that returns a deterministic non-cryptographic byte array; for unit tests and quick assertions only, not a real signer.X402Config— the config record the upcomingX402PaymentBrokerwill consume.
What's deferred to later phases
- P3 — actual
X402PaymentBrokerimplementation,web3j-cryptodependency, EIP-712 hashing, secp256k1 signing, HTTP 402 replay loop. - P4 — production-grade
EnvKeystoreWallet+DelegatedWallet, mandate enforcement viaAuthorityScope.spendCeiling, liability record emission. - P5 — reference dogfood wiring.
- P6 — Base mainnet flag + production-readiness checklist.
- Since:
- 0.10.5 (TNS-449 P2)
-
ClassDescriptionThe two 32-byte values an EVM wallet needs in order to produce an EIP-712 signature.Builds a
Web3jWalletfrom an EVM private key resolved from environment variables.Thrown when a required env var is missing or blank.Test-onlyWalletthat never touches real cryptography.Settlement networks the x402 adapter can target.Signing-scheme family.One entry in theacceptsarray of an x402 HTTP 402 response.Builds the EIP-712 typed-data hash pair for an EIP-3009transferWithAuthorizationcall — the payload an x402 client signs to authorise a one-time USDC transfer without an on-chain approval round-trip.Builder forTransferAuthorization.Signing surface the x402 payment broker needs.Factory that turns aWalletSpecinto a liveWallet.Backend-agnostic configuration aWallet.Factoryconsumes to instantiate aWallet.Real secp256k1 EVM wallet backed by web3j-crypto'sECKeyPair.Configuration record for the upcoming x402 broker.Builder forX402Config.x402 implementation ofPaymentBroker.