# Rust — seismic-alloy

Rust SDK for [Seismic](https://seismic.systems), built on [Alloy](https://github.com/alloy-rs/alloy) (v1.1.0). Requires **Rust 1.82+**.

```toml
[dependencies]
seismic-prelude        = { git = "https://github.com/SeismicSystems/seismic-alloy" }
seismic-alloy-network  = { git = "https://github.com/SeismicSystems/seismic-alloy" }
seismic-alloy-provider = { git = "https://github.com/SeismicSystems/seismic-alloy" }
alloy-provider         = "1.1"
# ... plus the [patch.crates-io] block documented in Installation
```

See [Installation](/clients/alloy/installation.md) for the full `Cargo.toml`, including the required `[patch.crates-io]` block.

## Quick Example

```rust
use seismic_prelude::client::*;
use seismic_alloy_network::reth::SeismicReth;
use alloy_provider::Provider;

sol! {
    #[sol(rpc)]
    contract SeismicCounter {
        function setNumber(suint256 newNumber) public;
        function isOdd() public view returns (bool);
    }
}

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let signer: PrivateKeySigner = "0xYOUR_PRIVATE_KEY".parse()?;
    let wallet = SeismicWallet::<SeismicReth>::from(signer);
    let url: reqwest::Url = "https://testnet-1.seismictest.net/rpc".parse()?;

    let provider = SeismicProviderBuilder::new()
        .wallet(wallet)
        .connect_http(url)
        .await?;

    let contract_address: Address = "0xYourContractAddress".parse()?;
    let contract = SeismicCounter::new(contract_address, &provider);

    // Shielded read (encrypted call + response decryption)
    let is_odd = contract.isOdd().seismic().call().await?;

    // Shielded write (encrypted transaction)
    // setNumber has a shielded param (suint256), so it auto-encrypts — no .seismic() needed
    contract.setNumber(alloy_primitives::aliases::SUInt(U256::from(42)))
        .send()
        .await?
        .get_receipt()
        .await?;

    Ok(())
}
```

```rust
// Unsigned provider — read-only (no private key needed)
// Note: connect_http is synchronous for unsigned providers (no .await)
let provider = SeismicProviderBuilder::new()
    .connect_http("https://testnet-1.seismictest.net/rpc".parse()?);

let block = provider.get_block_number().await?;
```

## Documentation Navigation

### Getting Started

| Section                                            | Description                                      |
| -------------------------------------------------- | ------------------------------------------------ |
| [**Installation**](/clients/alloy/installation.md) | Cargo setup, git dependencies, and feature flags |
| [**Provider**](/clients/alloy/provider.md)         | Signed and unsigned provider types               |

### Provider Reference

| Section                                                                             | Description                                                             |
| ----------------------------------------------------------------------------------- | ----------------------------------------------------------------------- |
| [**SeismicSignedProvider**](/clients/alloy/provider/seismic-signed-provider.md)     | Full-featured provider with wallet, encryption, and response decryption |
| [**SeismicUnsignedProvider**](/clients/alloy/provider/seismic-unsigned-provider.md) | Read-only provider for public operations                                |
| [**Encryption**](/clients/alloy/provider/encryption.md)                             | TEE key exchange, ECDH, AES-GCM calldata encryption                     |

## Workspace Layout

```
seismic-alloy (workspace)
├── consensus    — Seismic transaction types and consensus logic
├── network      — SeismicNetwork trait, SeismicReth, SeismicFoundry
├── provider     — SeismicProviderBuilder, fillers, precompile helpers
├── rpc-types    — Seismic-specific RPC request/response types
├── genesis      — Genesis configuration types
└── prelude      — Convenience re-exports from all crates
```

The provider wraps Alloy's provider with a filler pipeline that handles seismic-specific fields and calldata encryption. See [Provider](/clients/alloy/provider.md) for the full filler chain and per-trait API.

## Network Types

The SDK defines two network configurations:

| Network          | Type        | Description                              |
| ---------------- | ----------- | ---------------------------------------- |
| `SeismicReth`    | Production  | Seismic devnet/testnet/mainnet           |
| `SeismicFoundry` | Development | Local Seismic Foundry (sanvil) instances |

Both implement the `SeismicNetwork` trait and can be used as the generic parameter `N` in provider types.

## Guides & Examples

| Section                                                                           | Description                                             |
| --------------------------------------------------------------------------------- | ------------------------------------------------------- |
| [**Guides**](/clients/alloy/guides.md)                                            | Step-by-step tutorials for shielded writes and reads    |
| [**Shielded Write Guide**](/clients/alloy/guides/shielded-write.md)               | Encrypted transaction lifecycle and security parameters |
| [**Signed Reads Guide**](/clients/alloy/guides/signed-reads.md)                   | Encrypted eth\_call with identity proof                 |
| [**Examples**](/clients/alloy/examples.md)                                        | Complete, runnable code examples                        |
| [**Basic Setup**](/clients/alloy/examples/basic-setup.md)                         | Provider creation and connection verification           |
| [**Shielded Write Complete**](/clients/alloy/examples/shielded-write-complete.md) | Full lifecycle: deploy, write, read, inspect receipt    |
| [**Signed Read Pattern**](/clients/alloy/examples/signed-read-pattern.md)         | Comparing encrypted and transparent reads               |
| [**Contract Deployment**](/clients/alloy/examples/contract-deployment.md)         | Deploy, verify, interact, and subscribe to events       |

## Next Steps

1. [**Install seismic-alloy**](/clients/alloy/installation.md) — Add the crate to your project
2. [**Create a signed provider**](/clients/alloy/provider/seismic-signed-provider.md) — Connect with full capabilities
3. [**Understand encryption**](/clients/alloy/provider/encryption.md) — Learn how calldata encryption works
4. [**Explore unsigned providers**](/clients/alloy/provider/seismic-unsigned-provider.md) — Read-only access
5. [**Follow a guide**](/clients/alloy/guides.md) — Step-by-step shielded write or signed read tutorial
6. [**Run an example**](/clients/alloy/examples.md) — Complete, runnable code examples


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.seismic.systems/clients/alloy.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
