SDKsJavaOverview

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.

Maven Central

Installation

<dependency>
    <groupId>io.t402</groupId>
    <artifactId>t402</artifactId>
    <version>1.12.1</version>
</dependency>

Features

FeatureStatus
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

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

NetworkChain IDCAIP-2
Ethereum Mainnet1eip155:1
Base8453eip155:8453
Arbitrum One42161eip155:42161
Optimism10eip155:10
Ink57073eip155:57073
Berachain80094eip155:80094
Unichain130eip155:130

Other Networks

NetworkIdentifier
Solana Mainnetsolana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp
TON Mainnetton:mainnet
TRON Mainnettron:mainnet
NEAR Mainnetnear:mainnet
Aptos Mainnetaptos:1
Tezos Mainnettezos:NetXdQprcVkpaWU
Polkadot Asset Hubpolkadot:68d56f15f85d3136970ec16946040bc1
Stacks Mainnetstacks:1
Cosmos/Noble Mainnetcosmos:noble-1
Bitcoin Mainnetbip122:000000000019d6689c085ae165831e93
Lightning Mainnetlightning:mainnet

Packages

PackageDescription
io.t402Core types, client, server, facilitator
io.t402.cryptoMulti-chain signers (EVM, SVM, TON, TRON)
io.t402.schemes.evmEVM exact and upto schemes
io.t402.schemes.svmSolana exact and upto schemes
io.t402.schemes.tonTON exact and upto schemes
io.t402.schemes.tronTRON exact and upto schemes
io.t402.schemes.nearNEAR exact-direct and upto schemes
io.t402.schemes.aptosAptos exact-direct scheme
io.t402.schemes.tezosTezos exact-direct scheme
io.t402.schemes.polkadotPolkadot exact-direct scheme
io.t402.schemes.stacksStacks exact-direct scheme
io.t402.schemes.cosmosCosmos/Noble exact-direct scheme
io.t402.schemes.btcBitcoin PSBT and Lightning BOLT11 schemes
io.t402.erc4337ERC-4337 account abstraction
io.t402.bridgeUSDT0 cross-chain bridge
io.t402.multisigSafe multi-sig support
io.t402.wdkTether WDK integration
io.t402.mcpMCP server for AI agents
io.t402.a2aA2A transport helpers
io.t402.springSpring Boot auto-configuration
io.t402.micronautMicronaut payment filter
io.t402.quarkusQuarkus / JAX-RS payment filter
io.t402.cliCommand-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