Skip to main content

Crate remitmd

Crate remitmd 

Source
Expand description

§remitmd - Rust SDK for the remit.md universal AI payment protocol

remit.md enables AI agents to send and receive USDC payments on Base (EVM L2) with support for direct payments, escrow, streaming, payment channels (tabs), bounties, and security deposits.

§Quick start

use remitmd::Wallet;
use rust_decimal_macros::dec;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // From environment: export REMITMD_KEY=0x...
    let wallet = Wallet::from_env()?;

    // Direct payment
    let tx = wallet.pay("0xRecipient...", dec!(1.50)).await?;
    println!("paid {:?} USDC in {}", tx.amount, tx.tx_hash);

    // Escrow for high-value work
    let escrow = wallet.create_escrow("0xAgent...", dec!(100.00)).await?;
    // ... agent completes work ...
    wallet.release_escrow(&escrow.id, None).await?;
    Ok(())
}

§Testing

Use MockRemit for unit tests - zero network, zero latency, deterministic:

use remitmd::MockRemit;
use rust_decimal_macros::dec;

#[tokio::test]
async fn agent_pays_for_service() {
    let mock = MockRemit::new();
    let wallet = mock.wallet();

    wallet.pay("0xService000000000000000000000000000000001", dec!(0.003)).await.unwrap();

    assert!(mock.was_paid("0xService000000000000000000000000000000001", dec!(0.003)).await);
}

§Error handling

All SDK methods return Result<T, RemitError>. Errors are structured with a stable machine-readable code, an actionable message, and a documentation link.

use remitmd::error::codes;

match wallet.pay(addr, amount).await {
    Ok(tx) => println!("paid: {}", tx.tx_hash),
    Err(e) if e.code == codes::INVALID_ADDRESS => {
        eprintln!("fix the address: {}", e.message);
    }
    Err(e) if e.code == codes::INSUFFICIENT_BALANCE => {
        eprintln!("top up your wallet: {}", e.message);
    }
    Err(e) => eprintln!("payment error: {e}"),
}

Re-exports§

pub use cli_signer::CliSigner;
pub use error::RemitError;

Modules§

a2a
A2A / AP2 - agent card discovery and A2A JSON-RPC task client.
cli_signer
CLI signer adapter for the remit sign subprocess.
error
x402
x402 client and paywall for HTTP 402 Payment Required flows.

Structs§

Balance
Current USDC balance of a wallet.
Bounty
A task with a USDC reward for completion.
BountySubmission
A bounty submission from a submitter.
Budget
Remaining spending capacity under operator-set limits.
ChainId
EVM chain IDs supported by remit.md.
ContractAddresses
On-chain contract addresses for the current deployment.
Deposit
Security deposit held as collateral.
Escrow
Holds USDC until conditions are met.
Intent
A proposed payment awaiting negotiation.
Milestone
A partial payment condition within an escrow.
MintResponse
Result of a testnet mint operation.
MockRemit
In-memory mock for testing agents that use remit.md.
PermitSignature
ERC-2612 permit signature for gasless USDC approvals.
PrivateKeySigner
Signs API requests using an in-memory ECDSA private key.
Reputation
An agent’s on-chain payment reputation score (0–1000).
SpendingSummary
Spending analytics for a wallet.
Split
Distributes an escrow payment among multiple recipients.
Stream
Time-based payment stream (pay-per-second).
Tab
Off-chain payment channel for batched micro-payments.
TabCharge
A charge against a Tab (on-chain signed by provider).
TabDebit
A single debit against a Tab (legacy).
TopRecipient
A top recipient entry within SpendingSummary.
Transaction
Result of any payment operation.
TransactionList
Paginated list of transactions.
Wallet
Primary remit.md client for AI agents that send and receive payments.
WalletBuilder
Builder for Wallet. Use Wallet::new(key) or Wallet::with_signer(signer).
WalletStatus
Wallet status returned by /api/v1/status/{address}.
WithKey
Typestate for WalletBuilder: key-based construction.
WithSigner
Typestate for WalletBuilder: custom signer construction.

Enums§

BountyStatus
Status of a bounty.
DepositStatus
Status of a security deposit.
EscrowStatus
Status of an escrow payment.
StreamStatus
Status of a payment stream.
TabStatus
Status of a payment channel (tab).

Traits§

Signer
Signs EIP-712 typed data for authenticating API requests.