Skip to main content

Rust SDK

Crates.io License: MIT Official Rust SDK for the Paratro MPC Wallet Gateway.

Installation

Add to your Cargo.toml:
[dependencies]
paratro-sdk = "1.1"
tokio = { version = "1", features = ["full"] }
Requirements: Rust 1.70+ with async runtime (Tokio). New wallets are created asynchronously. Wait until both status and key_status are ACTIVE before creating accounts or transfers. The gateway derives account network automatically from the selected chain.

Quick Start

use paratro_sdk::{MpcClient, Config, CreateWalletRequest, CreateAccountRequest};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = MpcClient::new(
        "your-api-key",
        "your-api-secret",
        Config::production(),
    );

    // Create wallet
    let wallet = client.create_wallet(&CreateWalletRequest {
        wallet_name: "My Wallet".into(),
        description: "Primary wallet".into(),
    }).await?;
    println!("Wallet ID: {}", wallet.wallet_id);

    // Create account
    let account = client.create_account(&CreateAccountRequest {
        wallet_id: wallet.wallet_id.clone(),
        chain: "ethereum".into(),
        account_type: None,
        label: Some("Deposit Account".into()),
    }).await?;
    println!("Account: {} ({})", account.account_id, account.address);

    // Add asset
    let asset = client.create_asset(&CreateAssetRequest {
        account_id: account.account_id.clone(),
        symbol: "USDT".into(),
        chain: Some("ethereum".into()),
    }).await?;
    println!("Asset: {} ({})", asset.asset_id, asset.symbol);

    // Create transfer
    let transfer = client.create_transfer(&CreateTransferRequest {
        from_address: account.address.clone(),
        to_address: "0xbbbb...".into(),
        chain: "ethereum".into(),
        token_symbol: "USDT".into(),
        amount: "10.5".into(),
        memo: None,
    }).await?;
    println!("Transfer: {} ({})", transfer.tx_id, transfer.status);
    Ok(())
}

Configuration

// Sandbox: https://api-sandbox.paratro.com
let client = MpcClient::new(api_key, api_secret, Config::sandbox());

Methods

All methods are async and return Result<T, Error>:
CategoryMethods
Walletcreate_wallet, get_wallet, list_wallets
Accountcreate_account, get_account, list_accounts
Assetcreate_asset, get_asset, list_assets
Transactionget_transaction, list_transactions
Transfercreate_transfer

Error Handling

The SDK returns structured Error for API failures:
use paratro_sdk::Error;

match client.get_wallet("wallet_id").await {
    Ok(wallet) => println!("Found: {}", wallet.wallet_name),
    Err(Error::Api { status, code, message, .. }) => {
        println!("API error {}: [{}] {}", status, code, message);
    }
    Err(e) => println!("Other error: {}", e),
}

Pagination

List methods return a paginated response with items, total, and has_more:
let resp = client.list_transactions(&ListTransactionsRequest {
    wallet_id: Some(wallet.wallet_id.clone()),
    page: Some(1),
    page_size: Some(20),
    ..Default::default()
}).await?;

for tx in &resp.items {
    println!("TX: {} {} {} ({})", tx.tx_hash, tx.amount, tx.token_symbol, tx.status);
}

if resp.has_more {
    // Fetch next page
}

Project Structure

paratro-sdk-rust/
├── src/
│   ├── lib.rs          # Public API exports
│   ├── client.rs       # MpcClient with HTTP and token management
│   ├── config.rs       # Environment configuration
│   ├── error.rs        # Error types
│   ├── wallet.rs       # Wallet API
│   ├── account.rs      # Account API
│   ├── asset.rs        # Asset API
│   └── transaction.rs  # Transaction & Transfer API
├── Cargo.toml          # Package metadata
└── README.md