Rust SDK

The official projectsilo crate provides an async client for the Project Silo REST API.

Install

Cargo.tomltoml
[dependencies]
projectsilo = "0.1"
tokio = { version = "1", features = ["rt-multi-thread", "macros"] }

Create a client

main.rsrust
use projectsilo::ProjectSiloClient;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = ProjectSiloClient::new("project_silo_live_...");
    // or: ProjectSiloClient::with_base_url(key, "http://localhost:4001");

    Ok(())
}

Deposit accounts

deposit_accounts.rsrust
use projectsilo::types::{CreateDepositAccountInput, Destination};

let input = CreateDepositAccountInput {
    external_user_id: "user_123".into(),
    destination: Destination {
        chain_id: 137,
        address: "0x1111...".into(),
        token_address: "0x2791...".into(),
    },
    metadata: None,
};
let account = client.create_deposit_account(&input).await?;
println!("{:?}", account.deposit_addresses);

// List
let accounts = client.list_deposit_accounts(Some(50)).await?;

// Get
let acct = client.get_deposit_account("user_123").await?;

// Update destination
let updated = client.update_destination(&UpdateDestinationInput {
    external_user_id: "user_123".into(),
    destination: Destination { chain_id: 8453, /* ... */ },
}).await?;

Webhooks

webhooks.rsrust
// Verify webhook signatures (HMAC-SHA256 over "{timestamp}.{raw_body}")
use projectsilo::{verify_webhook_signature, DEFAULT_TOLERANCE_SECS};

let valid = verify_webhook_signature(
    body_bytes,        // &[u8]
    signature_header,  // &str — x-project-silo-signature (v1=<hex>)
    timestamp_header,  // &str — x-project-silo-timestamp (unix seconds)
    secret,            // &str
    DEFAULT_TOLERANCE_SECS, // max clock skew (300s)
);

// Create endpoint
let (endpoint, secret) = client.create_webhook_endpoint(
    &CreateWebhookEndpointInput {
        name: "Production".into(),
        url: "https://example.com/webhook".into(),
        event_types: vec!["deposit.credited".into()],
        enabled: Some(true),
    },
).await?;

Error handling

errors.rsrust
use projectsilo::ProjectSiloError;

match client.get_deposit_account("bad_id").await {
    Err(ProjectSiloError::Api { status, code, message }) => {
        eprintln!("API error {status}: {message} (code={code:?})");
    }
    Err(ProjectSiloError::Request(e)) => {
        eprintln!("Network error: {e}");
    }
    Ok(account) => println!("{:?}", account),
}