Java SDK
The T402 Java SDK provides a complete implementation of the t402 payment protocol for Java applications, with first-class support for Spring Boot, multiple HTTP frameworks, and multi-chain payments across 10 blockchain families.
Installation
<dependency>
<groupId>io.t402</groupId>
<artifactId>t402</artifactId>
<version>1.12.1</version>
</dependency>Features
| Feature | Status |
|---|---|
| Core Client | ✅ |
| Core Server | ✅ |
| Facilitator Client | ✅ |
| EVM Mechanism | ✅ |
| SVM Mechanism (Solana) | ✅ |
| TON Mechanism | ✅ |
| TRON Mechanism | ✅ |
| NEAR Mechanism | ✅ |
| Aptos Mechanism | ✅ |
| Tezos Mechanism | ✅ |
| Polkadot Mechanism | ✅ |
| Stacks Mechanism | ✅ |
| Cosmos/Noble Mechanism | ✅ |
| Up-To Scheme (EVM, SVM, TON, TRON, NEAR) | ✅ |
| ERC-4337 Account Abstraction | ✅ |
| USDT0 Cross-Chain Bridge | ✅ |
| Multi-sig (Safe) | ✅ |
| WDK Integration | ✅ |
| MCP Server (6 tools) | ✅ |
| CLI Tool | ✅ |
| A2A Transport | ✅ |
| Spring Boot / Spring MVC | ✅ |
| Spring WebFlux (Reactive) | ✅ |
| Jakarta Servlet Filter | ✅ |
| Micronaut Filter | ✅ |
| Quarkus / JAX-RS Filter | ✅ |
| Bitcoin (PSBT + Lightning) | ✅ |
Quick Start
Spring Boot (Recommended)
1. Add configuration to application.yml:
t402:
enabled: true
facilitator-url: https://facilitator.t402.io
network: eip155:8453
pay-to: "0xYourReceiverAddress"
asset: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
token-name: "USD Coin"
token-version: "2"2. Create a protected endpoint:
@RestController
public class ApiController {
@GetMapping("/api/premium")
public Map<String, String> premiumContent() {
return Map.of("data", "Premium content!");
}
}The PaymentFilter is automatically registered for /api/* endpoints.
Client Usage
import io.t402.client.T402HttpClient;
import io.t402.crypto.EvmSigner;
// Create signer
EvmSigner signer = EvmSigner.fromPrivateKey(
"0xYourPrivateKey",
8453,
"USD Coin",
"2",
"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
);
// Create HTTP client
T402HttpClient client = new T402HttpClient(signer);
// Make payment request
HttpResponse<String> response = client.get(
URI.create("https://api.example.com/premium"),
BigInteger.valueOf(1_000_000),
"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
"0xReceiverAddress"
);Package Structure
Documentation
Supported Networks
EVM Networks
| Network | Chain ID | CAIP-2 |
|---|---|---|
| Ethereum Mainnet | 1 | eip155:1 |
| Base | 8453 | eip155:8453 |
| Arbitrum One | 42161 | eip155:42161 |
| Optimism | 10 | eip155:10 |
| Ink | 57073 | eip155:57073 |
| Berachain | 80094 | eip155:80094 |
| Unichain | 130 | eip155:130 |
Other Networks
| Network | Identifier |
|---|---|
| Solana Mainnet | solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp |
| TON Mainnet | ton:mainnet |
| TRON Mainnet | tron:mainnet |
| NEAR Mainnet | near:mainnet |
| Aptos Mainnet | aptos:1 |
| Tezos Mainnet | tezos:NetXdQprcVkpaWU |
| Polkadot Asset Hub | polkadot:68d56f15f85d3136970ec16946040bc1 |
| Stacks Mainnet | stacks:1 |
| Cosmos/Noble Mainnet | cosmos:noble-1 |
| Bitcoin Mainnet | bip122:000000000019d6689c085ae165831e93 |
| Lightning Mainnet | lightning:mainnet |
Packages
| Package | Description |
|---|---|
io.t402 | Core types, client, server, facilitator |
io.t402.crypto | Multi-chain signers (EVM, SVM, TON, TRON) |
io.t402.schemes.evm | EVM exact and upto schemes |
io.t402.schemes.svm | Solana exact and upto schemes |
io.t402.schemes.ton | TON exact and upto schemes |
io.t402.schemes.tron | TRON exact and upto schemes |
io.t402.schemes.near | NEAR exact-direct and upto schemes |
io.t402.schemes.aptos | Aptos exact-direct scheme |
io.t402.schemes.tezos | Tezos exact-direct scheme |
io.t402.schemes.polkadot | Polkadot exact-direct scheme |
io.t402.schemes.stacks | Stacks exact-direct scheme |
io.t402.schemes.cosmos | Cosmos/Noble exact-direct scheme |
io.t402.schemes.btc | Bitcoin PSBT and Lightning BOLT11 schemes |
io.t402.erc4337 | ERC-4337 account abstraction |
io.t402.bridge | USDT0 cross-chain bridge |
io.t402.multisig | Safe multi-sig support |
io.t402.wdk | Tether WDK integration |
io.t402.mcp | MCP server for AI agents |
io.t402.a2a | A2A transport helpers |
io.t402.spring | Spring Boot auto-configuration |
io.t402.micronaut | Micronaut payment filter |
io.t402.quarkus | Quarkus / JAX-RS payment filter |
io.t402.cli | Command-line tools |
Requirements
- Java 17+
- Jakarta Servlet API 6.0+ (for servlet filter)
- Spring Boot 3.x (for auto-configuration)
- Kotlin 1.9+ (for Kotlin support)
Dependencies
The SDK includes:
- Web3j - Ethereum library for EIP-712 signing
- Jackson - JSON processing
- BouncyCastle - Ed25519, ECDSA, and cryptographic primitives
- SolanaJ (optional) - Solana RPC integration
- Spring Boot (optional) - Auto-configuration support