remitmd - Rust SDK
Skill MD · Docs · Agent Spec
Rust SDK for the remit.md universal AI payment protocol. Send and receive USDC payments from AI agents on Base using Tokio async.
Install
# Cargo.toml
[]
= "0.1"
= { = "1", = ["rt-multi-thread", "macros"] }
= "1" # optional: dec!() macro for literals
3-line integration
use Wallet;
use dec;
let wallet = from_env?; // REMITMD_KEY env var
let tx = wallet.pay.await?; // send USDC
println!;
Configuration
// From environment variables (recommended for agents)
let wallet = from_env?;
// REMITMD_KEY=0x... (required)
// REMITMD_CHAIN=base (optional, default: "base")
// REMITMD_TESTNET=true (optional)
// Builder pattern
let wallet = new
.chain // "base" (only supported chain)
.testnet // use testnet
.base_url // self-hosted
.build?;
// Custom signer (KMS, hardware wallet, etc.)
let wallet = with_signer
.chain
.build?;
All payment methods (pay, create_escrow, create_tab, create_stream, create_bounty, lock_deposit) automatically sign an EIP-2612 permit for gasless USDC approval. No manual permit handling needed.
Local Signer (Recommended)
The local signer delegates key management to remit signer, a localhost HTTP server that holds your encrypted key. Your agent only needs a URL and token - no private key in the environment.
// Explicit
let signer = new?;
let wallet = with_signer.build?;
// Or auto-detect from env (recommended)
let wallet = from_env?; // detects REMIT_SIGNER_URL automatically
Wallet::from_env() detects signer credentials automatically. Priority: REMIT_SIGNER_URL > REMITMD_KEY.
Payment Models
Direct Payment
// One-way transfer, no escrow
let tx = wallet.pay.await?;
let tx = wallet.pay_with_memo.await?;
Escrow
// Lock funds until work is verified
let escrow = wallet.create_escrow.await?;
// Optional: with milestones, splits, expiry
let escrow = wallet.create_escrow_full.await?;
wallet.release_escrow.await?; // release all
wallet.release_escrow.await?; // release milestone
wallet.cancel_escrow.await?; // cancel, refund payer
let state = wallet.get_escrow.await?; // check status
Tab (Payment Channel)
// Batch micro-payments off-chain, settle once on-chain
let tab = wallet.create_tab.await?;
// Provider charges the tab (with EIP-712 signature)
wallet.charge_tab.await?;
// Close when done - unused funds return
wallet.close_tab.await?;
Stream
// Per-second payment flow (subscriptions, uptime billing)
let stream = wallet.create_stream.await?;
wallet.withdraw_stream.await?; // recipient claims vested funds
Bounty
// Open reward for task completion
let bounty = wallet.create_bounty.await?;
wallet.award_bounty.await?;
Deposit
// Security collateral (lock, forfeit, or return)
let deposit = wallet.lock_deposit.await?;
Analytics & Reputation
// On-chain reputation (0-1000 score)
let rep = wallet.reputation.await?;
println!;
// Spending analytics
let summary = wallet.spending_summary.await?; // "day", "week", "month", "all"
println!;
// Operator spending limits
let budget = wallet.remaining_budget.await?;
println!;
// Transaction history
let history = wallet.history.await?;
Testing with MockRemit
MockRemit is an in-memory mock with zero network dependencies. It's the fastest way to test agents that send payments.
use MockRemit;
use dec;
async
async
async
Additional Methods
// Contract discovery (cached per session)
let contracts = wallet.get_contracts.await?;
// Webhooks
wallet.register_webhook.await?;
// Operator links (_with_options variant accepts messages + agent_name)
let link = wallet.create_fund_link.await?;
let link = wallet.create_withdraw_link_with_options.await?;
// Testnet funding
let result = wallet.mint.await?; // $100 testnet USDC
Error Handling
All errors are typed RemitError with a stable code, an actionable message, and a doc_url. Enriched errors include actual numbers:
use codes;
match wallet.pay.await
Advanced: Manual Permits
By default, all payment methods auto-sign EIP-2612 permits. If you need manual control:
// Sign a permit yourself
let permit = wallet.sign_permit.await?;
// Pass it explicitly to any _with_permit or _full variant
let tx = wallet.pay_with_permit.await?;
let tx = wallet.pay_full.await?;
Manual permit variants: pay_with_permit, create_escrow_with_permit, create_tab_with_permit, create_stream_with_permit, create_bounty_with_permit, lock_deposit_with_permit.
License
MIT - remit.md