Tenzro Testnet is live. Get testnet TNZO

Payment Protocols

Multi-protocol payments — AP2 for autonomous agents, MPP, x402, and Tempo network integration

Tenzro supports four payment protocols for machine-to-machine commerce. AP2 (Agentic Payment Protocol) for fully autonomous agent payments, MPP (Machine Payments Protocol) for session-based streaming, x402 (Coinbase) for stateless micropayments, and direct Tempo network integration for stablecoin settlement. Identity-bound payments enforce delegation scopes.

AP2 enables AI agents to discover, negotiate, and settle payments autonomously within policy bounds. MPP and x402 use HTTP 402 (Payment Required) status codes. All four protocols are linked to TDIP identities with fine-grained permission controls.

Key Features

AP2 (Agentic Payment Protocol)

Autonomous agent payments. Agents discover services via A2A, negotiate terms, authorize within delegation scopes, and settle without human intervention

MPP (Machine Payments Protocol)

HTTP 402 challenge/credential/receipt flow. Session management for streaming payments

x402 Protocol

Coinbase's HTTP 402 payment standard. PaymentRequired/PaymentPayload types. Facilitator integration for settlement

Tempo Integration

Direct participation in Tempo network for stablecoin settlement. TIP-20 token support. Bridge adapter for cross-network transfers

Identity-Bound Payments

Link payments to TDIP identities. Delegation scope enforcement: max_transaction_value, allowed_operations, allowed_protocols

HTTP Middleware

Axum middleware for automatic challenge/verification. Add payment gates to any API endpoint

Payment Gateway

Multi-protocol routing. Create challenges, verify credentials, and settle across AP2, MPP, x402, and direct protocols

Protocol Comparison

ProtocolSettlement
AP2Policy-bound autonomous
MPPSession-based streaming
x402One-time per-request
TempoTIP-20 stablecoin on-chain

Code Examples

AP2: Autonomous Agent Payment (Rust)

use tenzro_agent::transactions::AgentTransactionExecutor;
use tenzro_agent::SpendingPolicy;

// Agent with spending policy
let policy = SpendingPolicy {
    max_per_transaction: 100_000_000_000_000_000_000, // 100 TNZO
    max_daily_total: 1_000_000_000_000_000_000_000,   // 1000 TNZO
    allowed_recipients: vec![provider_address],
    require_tee_attestation: true,
};

let executor = AgentTransactionExecutor::new(wallet, policy);

// Agent autonomously pays for inference
let receipt = executor.pay_for_service(
    provider_address,
    service_cost,
    "inference:gemma4-e4b",
).await?;

AP2: Autonomous Agent Payment (TypeScript)

import { TenzroClient } from "@tenzro/sdk";

const client = new TenzroClient("https://rpc.tenzro.network");

// Create AP2 payment session
const session = await client.createPaymentChallenge({
  protocol: "ap2",
  agentDid: "did:tenzro:machine:agent-001",
  amount: "50000000000000000000", // 50 TNZO
  service: "inference:gemma4-e4b",
  delegationProof: delegationCredential,
});

// Agent authorizes within spending policy
const receipt = await client.authorizeAndPay(session);

AP2: A2A Server Integration

// A2A Protocol Server (port 3002) exposes AP2 methods:
//   payments/create   — Create AP2 payment challenge
//   payments/authorize — Agent authorizes within spending policy
//   payments/execute  — Execute authorized payment
//   payments/cancel   — Cancel pending payment

// JSON-RPC 2.0 request via A2A server
let request = serde_json::json!({
    "jsonrpc": "2.0",
    "method": "payments/create",
    "params": {
        "agent_did": "did:tenzro:machine:agent-001",
        "provider_did": "did:tenzro:machine:provider-042",
        "amount": "50000000000000000000",
        "service": "inference:gemma4-e4b",
        "spending_policy": {
            "max_per_transaction": "100000000000000000000",
            "max_daily_total": "1000000000000000000000",
        }
    },
    "id": 1
});

let response = reqwest::Client::new()
    .post("https://a2a.tenzro.network/a2a")
    .json(&request)
    .send()
    .await?;

Create Payment Challenge (Server)

use tenzro_payments::mpp::{MppPaymentServer, MppChallenge};

let server = MppPaymentServer::new(config);

// Create HTTP 402 challenge
let challenge = server.create_challenge(
    resource_url,
    Amount::tnzo(0.001),
    Duration::from_secs(300),
)?;
// Returns 402 with challenge in response

Pay for Resource (Client)

use tenzro_payments::mpp::MppClient;

let client = MppClient::new(wallet);

// Receive 402 challenge
let credential = client.create_credential(&challenge)?;

// Retry request with credential
let response = client.pay(&url, &credential).await?;

x402 Payment Flow

use tenzro_payments::x402::{X402Client, X402PaymentServer};

// Server: return 402 with payment details
let payment_required = X402PaymentRequired {
    amount: Amount::usdc(1.50),
    recipient: server_address,
    expiration: now + Duration::from_secs(60),
};

// Client: create payment payload
let payload = client.create_payment(
    &payment_required,
    &wallet,
)?;

// Server: verify and settle
let receipt = server.verify_and_settle(&payload)?;

Identity-Bound Payment with Delegation Scope

use tenzro_payments::identity_binding::IdentityBoundPayment;
use tenzro_identity::DelegationScope;

let scope = DelegationScope {
    max_transaction_value: Some(Amount::tnzo(10.0)),
    allowed_protocols: vec![
        PaymentProtocolId::Mpp,
        PaymentProtocolId::X402,
    ],
    allowed_operations: vec!["inference".into()],
    ..Default::default()
};

// Machine identity makes payment within scope
let payment = IdentityBoundPayment::create(
    machine_did,
    &challenge,
    &wallet,
    &scope,
)?;

// Payment automatically rejected if outside scope

Tempo Network Integration

use tenzro_payments::tempo::{TempoBridgeAdapter, Tip20Token};

let tempo = TempoBridgeAdapter::new(config);

// Query TIP-20 token balance
let balance = tempo.get_tip20_balance(
    participant_id,
    Tip20Token::USDC,
).await?;

// Transfer via Tempo network
let tx_hash = tempo.transfer_tip20(
    Tip20Token::USDC,
    recipient_id,
    Amount::usdc(100.0),
).await?;

// Wait for finality
let status = tempo.get_transfer_status(&tx_hash).await?;

Payment Gateway (Multi-Protocol Routing)

use tenzro_payments::gateway::PaymentGateway;

let gateway = PaymentGateway::new(mpp_server, x402_server);

// Create challenge (auto-selects protocol)
let challenge = gateway.create_challenge(
    PaymentProtocolId::Mpp,  // or Ap2, X402, Direct
    resource_url,
    amount,
    expiration,
)?;

// Verify credential (protocol-agnostic)
let result = gateway.verify_credential(
    PaymentProtocolId::Mpp,
    &credential_data,
)?;

// Settle (routes to correct protocol)
let receipt = gateway.settle(
    PaymentProtocolId::Mpp,
    &settlement_data,
).await?;

Ready to integrate payment protocols?

Explore the Tenzro Payments module and start building machine commerce applications.