tempo-x402 2.4.0

x402 payment protocol library for Tempo blockchain (EIP-712, TIP-20, wallet, client)
Documentation

tempo-x402

Core library for the x402 payment protocol on the Tempo blockchain.

Installation

[dependencies]
tempo-x402 = "1"

The crate is published as tempo-x402 but the library name is x402:

use x402::scheme::SchemeServer;
use x402::scheme_server::TempoSchemeServer;

Features

  • HTTP Client: Automatic 402 handling with payment signing
  • EIP-712 Signing: Payment authorization signatures
  • TIP-20 Utilities: Balance, allowance, transfer functions
  • Nonce Store: Replay protection (in-memory or SQLite)
  • HMAC Auth: Server-facilitator authentication

Usage

use alloy::signers::local::PrivateKeySigner;
use x402_client::{TempoSchemeClient, X402Client};

#[tokio::main]
async fn main() {
    let signer: PrivateKeySigner = "0xYOUR_KEY".parse().unwrap();
    let client = X402Client::new(TempoSchemeClient::new(signer));

    let (response, settlement) = client
        .fetch("https://api.example.com/paid", reqwest::Method::GET)
        .await
        .unwrap();

    println!("{}", response.text().await.unwrap());
}

Binaries

  • x402-client: CLI for making paid requests
  • x402-approve: CLI for approving the facilitator

Documentation

See the full documentation or llms.txt.

License

MIT