> For the complete documentation index, see [llms.txt](https://docs.seismic.systems/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.seismic.systems/clients/alloy/examples.md).

# Examples

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

## Available Examples

### Getting Started

| Example                                               | Description                                                                                                          |
| ----------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- |
| [Basic Setup](/clients/alloy/examples/basic-setup.md) | Create providers, verify connection, check balance, and fetch the TEE public key — both signed and unsigned variants |

### Core Workflows

| Example                                                                       | Description                                                                                                       |
| ----------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- |
| [Shielded Write Complete](/clients/alloy/examples/shielded-write-complete.md) | Full lifecycle: deploy a contract, send a shielded write, verify with a signed read, and inspect the receipt type |
| [Signed Read Pattern](/clients/alloy/examples/signed-read-pattern.md)         | Authenticated read pattern with comparison between `.seismic().call()` (encrypted) and `.call()` (transparent)    |
| [Contract Deployment](/clients/alloy/examples/contract-deployment.md)         | Deploy and interact with a shielded contract, including compilation notes, verification, and event subscription   |

## Example Template

Each example follows this structure:

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

sol! {
    #[sol(rpc)]
    contract MyContract {
        function myMethod(uint256 value) public;
        function myView() public view returns (bool);
    }
}

#[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::<SeismicReth>::from(signer);
    let url: reqwest::Url = std::env::var("RPC_URL")?.parse()?;

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

    let contract_address: Address = std::env::var("CONTRACT_ADDRESS")?.parse()?;
    let contract = MyContract::new(contract_address, &provider);

    // 2. Shielded write
    contract.myMethod(U256::from(42))
        .seismic()
        .send()
        .await?
        .get_receipt()
        .await?;

    // 3. Signed read
    let result = contract.myView().seismic().call().await?;

    Ok(())
}
```

## Running Examples

All examples assume you have:

```bash
# Install Rust 1.82+
rustup update stable

# Set environment variables
export PRIVATE_KEY="0x..."
export RPC_URL="https://testnet-1.seismictest.net/rpc"
```

And your `Cargo.toml` follows the layout documented in [Installation](/clients/alloy/installation.md) — `seismic-prelude`, `seismic-alloy-network`, `seismic-alloy-provider` from git plus `alloy-provider`, `alloy-signer-local`, `alloy-primitives`, `alloy-sol-types`, `tokio`, `reqwest`, and the required `[patch.crates-io]` block.

## See Also

* [Guides](/clients/alloy/guides.md) - Step-by-step tutorials
* [Contract Interaction](/clients/alloy/contract-interaction.md) - Shielded and transparent call patterns
* [Provider](/clients/alloy/provider.md) - Provider setup and configuration
* [Installation](/clients/alloy/installation.md) - Full dependency setup


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
