| Crates.io | mpay |
| lib.rs | mpay |
| version | 0.1.0 |
| created_at | 2026-01-24 20:16:37.121252+00 |
| updated_at | 2026-01-24 20:16:37.121252+00 |
| description | Micropayments Protocol - Rust library for Web Payment Auth (IETF draft-ietf-httpauth-payment) |
| homepage | https://github.com/tempoxyz/mpay-rs |
| repository | https://github.com/tempoxyz/mpay-rs |
| max_upload_size | |
| id | 2067403 |
| size | 245,362 |
Rust SDK for the Machine Payments Protocol (MPP) - an implementation of the "Payment" HTTP Authentication Scheme.
Challenge, Credential, Receipt) map directly to HTTP headersMethod and Intent are traits. Implement them for custom payment methods.use mpay::Challenge;
let header = r#"Payment realm="api.example.com", id="abc123", method="tempo", intent="charge", request="eyJhbW91bnQiOiIxMDAwIn0""#;
let challenge = Challenge::from_www_authenticate(header)?;
println!("Method: {}", challenge.method);
println!("Intent: {}", challenge.intent);
use mpay::Credential;
let credential = Credential {
id: challenge.id.clone(),
source: Some("did:pkh:eip155:8453:0x123...".into()),
payload: serde_json::json!({"hash": "0xabc..."}),
};
let auth_header = credential.to_authorization();
use mpay::Receipt;
let receipt = Receipt::from_payment_receipt(header)?;
assert_eq!(receipt.status, "success");
ChallengeA parsed payment challenge from a WWW-Authenticate header.
use mpay::Challenge;
let challenge = Challenge {
id: "challenge-id".into(),
method: "tempo".into(),
intent: "charge".into(),
request: serde_json::json!({"amount": "1000000", "asset": "0x...", "destination": "0x..."}),
};
let header = challenge.to_www_authenticate("api.example.com");
let parsed = Challenge::from_www_authenticate(&header)?;
CredentialThe credential sent in the Authorization header.
use mpay::Credential;
let credential = Credential {
id: "challenge-id".into(),
payload: serde_json::json!({"hash": "0x..."}),
source: Some("did:pkh:eip155:1:0x...".into()),
};
let header = credential.to_authorization();
let parsed = Credential::from_authorization(&header)?;
ReceiptPayment receipt returned after successful verification.
use mpay::Receipt;
let receipt = Receipt {
status: "success".into(),
timestamp: Some("2024-01-20T12:00:00Z".into()),
reference: Some("0x...".into()),
};
let header = receipt.to_payment_receipt();
let parsed = Receipt::from_payment_receipt(&header)?;
[dependencies]
mpay = "0.1"
| Feature | Description |
|---|---|
tempo |
Tempo blockchain support (default, includes evm) |
evm |
Shared EVM utilities (Address, U256, parsing) |
utils |
Encoding utilities (hex, base64) |
Network registries, currency formatting, keystore management, HTTP clients, and middleware are out of scope for this library.
See the examples/ directory for integration patterns with common HTTP libraries:
cargo build # Build with default features (tempo)
cargo test # Run tests
cargo doc --open # Generate and view documentation
MIT OR Apache-2.0