codeExamples

Complete runnable examples

Complete, runnable code examples demonstrating common Seismic Alloy (Rust) SDK patterns.

Available Examples

Getting Started

Example
Description

Create providers, verify connection, check balance, and fetch the TEE public key -- both signed and unsigned variants

Core Workflows

Example
Description

Full lifecycle: deploy a contract, send a shielded write, verify with a signed read, and inspect the receipt type

Authenticated read pattern with comparison between seismic_call() (encrypted) and call() (transparent)

Deploy and interact with a shielded contract, including compilation notes, verification, and event subscription

Example Template

Each example follows this structure:

use seismic_prelude::foundry::*;
use alloy_signer_local::PrivateKeySigner;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // 1. Set up provider
    let signer: PrivateKeySigner = std::env::var("PRIVATE_KEY")?.parse()?;
    let wallet = SeismicWallet::from(signer);
    let url: reqwest::Url = std::env::var("RPC_URL")?.parse()?;
    let provider = SeismicSignedProvider::<SeismicReth>::new(wallet, url).await?;

    // 2. Build transaction
    let tx: SeismicTransactionRequest = seismic_foundry_tx_builder()
        .with_input(calldata.into())
        .with_kind(TxKind::Call(contract_address))
        .into()
        .seismic();

    // 3. Send and verify
    let receipt = provider.send_transaction(tx.into()).await?
        .get_receipt().await?;
    assert!(receipt.status());

    Ok(())
}

Running Examples

All examples assume you have:

And your Cargo.toml includes:

See Also

Last updated