Rust SDK for the Machine Payments Protocol
MPP lets any client — agents, apps, or humans — pay for any service in the same HTTP request. It standardizes HTTP 402 with an open IETF specification, so servers can charge and clients can pay without API keys, billing accounts, or checkout flows.
You can get started today by reading the Rust SDK docs, exploring the protocol overview, or jumping straight to the quickstart.
cargo add mppuse mpp::server::{Mpp, tempo, TempoConfig};
let mpp = Mpp::create(tempo(TempoConfig {
recipient: "0x742d35Cc6634C0532925a3b844Bc9e7595f1B0F2",
}))?;
let challenge = mpp.charge("1")?;
let receipt = mpp.verify_credential(&credential).await?;use mpp::server::{Mpp, stripe, StripeConfig};
let mpp = Mpp::create_stripe(stripe(StripeConfig {
secret_key: "sk_test_...",
network_id: "internal",
payment_method_types: &["card"],
currency: "usd",
decimals: 2,
}))?;
let challenge = mpp.stripe_charge("1")?;
let receipt = mpp.verify_credential(&credential).await?;use mpp::client::{PaymentMiddleware, TempoProvider};
use reqwest_middleware::ClientBuilder;
let provider = TempoProvider::new(signer, "https://rpc.moderato.tempo.xyz")?;
let client = ClientBuilder::new(reqwest::Client::new())
.with(PaymentMiddleware::new(provider))
.build();
// Requests now handle 402 automatically
let resp = client.get("https://mpp.dev/api/ping/paid").send().await?;use mpp::client::{Fetch, StripeProvider};
use mpp::protocol::methods::stripe::CreateTokenResult;
let provider = StripeProvider::new(|params| {
Box::pin(async move {
// Proxy SPT creation through your backend (requires Stripe secret key)
let resp = reqwest::Client::new()
.post("https://my-server.com/api/create-spt")
.json(¶ms)
.send().await?.json::<serde_json::Value>().await?;
Ok(CreateTokenResult::from(resp["spt"].as_str().unwrap().to_string()))
})
});
let resp = reqwest::Client::new()
.get("https://api.example.com/paid")
.send_with_payment(&provider)
.await?;| Feature | Description |
|---|---|
client |
Client-side payment providers (PaymentProvider trait, Fetch extension) |
server |
Server-side payment verification (ChargeMethod trait) |
tempo |
Tempo blockchain support (includes evm) |
stripe |
Stripe payment support via SPTs |
evm |
Shared EVM utilities (Address, U256, parsing) |
middleware |
reqwest-middleware support with PaymentMiddleware (implies client) |
tower |
Tower middleware for server-side integration |
axum |
Axum extractor support for server-side convenience |
utils |
Hex/random utilities for development and testing |
MPP supports multiple payment methods through one protocol — Tempo, Stripe, Lightning, Card, and custom methods. The server advertises which methods it accepts, and the client chooses which one to pay with. This SDK implements Tempo (charge and session intents) and Stripe (charge intent via Shared Payment Tokens).
Built on the "Payment" HTTP Authentication Scheme, an open specification proposed to the IETF. See mpp.dev/protocol for the full protocol overview, or the IETF specification for the wire format.
git clone https://github.com/tempoxyz/mpp-rs
cd mpp-rs
cargo test
See SECURITY.md for reporting vulnerabilities.
Licensed under either of Apache License, Version 2.0 or MIT License at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in these crates by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.