For the complete documentation index, see llms.txt. This page is also available as Markdown.

Shielded Write Complete

Full shielded write lifecycle from deployment to receipt verification

This example demonstrates the full lifecycle of a shielded write: deploy a contract, send a shielded write (encrypted setNumber), verify the result with a signed read (encrypted isOdd), and inspect the receipt type.

Prerequisites

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

Cargo.toml — see Installation for the full template including the required [patch.crates-io] block:

[package]
name = "shielded-write-complete"
version = "0.1.0"
edition = "2021"
rust-version = "1.82"

[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" }
seismic-alloy-consensus = { git = "https://github.com/SeismicSystems/seismic-alloy" }
alloy-provider          = "1.1"
alloy-signer-local      = "1.1"
alloy-primitives        = "1.1"
alloy-sol-types         = "1.1"
alloy-network           = "1.1"
tokio                   = { version = "1", features = ["full"] }
reqwest                 = "0.12"

# [patch.crates-io] block required — see Installation.

Complete Example

Step-by-Step Breakdown

1. Provider setup

The SeismicProviderBuilder creates a signed provider with a wallet and RPC URL. During construction, it generates a provider-scoped secp256k1 keypair and fetches the TEE public key from the node. Both are cached for all subsequent operations.

2. Contract deployment (transparent)

Contract deployment uses the generated deploy() method. Create transactions cannot be seismic — the Seismic protocol does not support encrypting deployment bytecode.

3. Shielded write

The setNumber call has a shielded parameter (suint256), so the sol! macro wraps it in a ShieldedCallBuilder that auto-encrypts. Just call .send() directly — no .seismic() needed. The filler pipeline encrypts the calldata before broadcast.

4. Receipt inspection

Seismic transactions produce a SeismicReceiptEnvelope::Seismic receipt. You can pattern-match on the receipt's inner envelope to confirm the transaction was processed as a shielded (type 0x4A) transaction.

5. Signed read

The isOdd() view function is called via .seismic().call(), which encrypts the calldata, sends a signed eth_call, decrypts the response, and returns the decoded result.

Expected Output

Next Steps

See Also

Last updated