> 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 examples

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

## Available Examples

### Getting Started

| Example                                                                           | Description                                                                                                          |
| --------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- |
| [Basic Setup](https://docs.seismic.systems/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](https://docs.seismic.systems/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](https://docs.seismic.systems/clients/alloy/examples/signed-read-pattern.md)         | Authenticated read pattern with comparison between `.seismic().call()` (encrypted) and `.call()` (transparent)    |
| [Contract Deployment](https://docs.seismic.systems/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](https://docs.seismic.systems/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](https://docs.seismic.systems/clients/alloy/guides.md) - Step-by-step tutorials
* [Contract Interaction](https://docs.seismic.systems/clients/alloy/contract-interaction.md) - Shielded and transparent call patterns
* [Provider](https://docs.seismic.systems/clients/alloy/provider.md) - Provider setup and configuration
* [Installation](https://docs.seismic.systems/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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
