tempo-x402-0.2.0 has been yanked.
tempo-x402
Pay-per-request APIs on the Tempo blockchain.
Live Demo · Documentation · crates.io
How It Works
┌────────┐ ┌────────┐ ┌─────────────┐ ┌───────┐
│ Client │ │ Server │ │ Facilitator │ │ Chain │
└───┬────┘ └───┬────┘ └──────┬──────┘ └───┬───┘
│ │ │ │
│ GET /resource │ │ │
│─────────────────>│ │ │
│ │ │ │
│ 402 + payment │ │ │
│ requirements │ │ │
│<─────────────────│ │ │
│ │ │ │
│ [sign EIP-712] │ │ │
│ │ │ │
│ GET /resource │ │ │
│ + X-PAYMENT hdr │ │ │
│─────────────────>│ │ │
│ │ │ │
│ │ verify + settle │ │
│ │────────────────────>│ │
│ │ │ transferFrom() │
│ │ │───────────────────>│
│ │ │<───────────────────│
│ │<────────────────────│ │
│ │ │ │
│ 200 + content │ │ │
│<─────────────────│ │ │
Client requests a paid endpoint. Server returns 402 with price info. Client signs an EIP-712 payment authorization and retries. Server forwards to Facilitator, which verifies the signature and calls transferFrom on-chain to settle the payment. Server returns the content.
Architecture
Three services, one chain:
| Component | What it does | Stack |
|---|---|---|
| Client | Signs payments, makes requests | Rust (tempo-x402 crate) or any language with EIP-712 |
| Server | Gates endpoints, returns 402, forwards payments | Rust, actix-web |
| Facilitator | Verifies signatures, settles on-chain | Rust, actix-web, alloy |
| Chain | Tempo Moderato (testnet), pathUSD token | EVM, TIP-20 |
The facilitator holds no funds — it just has approval to call transferFrom on behalf of clients who have pre-approved it.
Install
Usage
use PrivateKeySigner;
use ;
async
Crates
| Crate | Purpose |
|---|---|
tempo-x402 |
Core library — types, signing, HTTP client |
tempo-x402-server |
Resource server with payment middleware |
tempo-x402-facilitator |
Payment verification and settlement |
Network
- Chain: Tempo Moderato (testnet)
- Chain ID: 42431
- Token: pathUSD
0x20c0000000000000000000000000000000000000(6 decimals) - RPC: https://rpc.moderato.tempo.xyz
License
MIT