magnifying-glassSigned Read Pattern

Authenticated read pattern with encrypted request and response

This example demonstrates the authenticated read pattern: create a signed provider, deploy a contract, write shielded data, read it back with a signed read, and compare with a transparent read to show the difference.

Prerequisites

export PRIVATE_KEY="0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"
export RPC_URL="https://gcp-1.seismictest.net/rpc"

Cargo.toml:

[package]
name = "signed-read-pattern"
version = "0.1.0"
edition = "2021"
rust-version = "1.82"

[dependencies]
seismic-alloy = { git = "https://github.com/SeismicSystems/seismic-alloy" }
alloy-signer-local = "1.1"
alloy-primitives = "1.1"
hex-literal = "0.4"
tokio = { version = "1", features = ["full"] }

Complete Example

When Results Differ

The example above uses isOdd(), which does not depend on msg.sender. Both reads return the same value. To see a real difference, consider a contract where the view function uses msg.sender:

Key Differences at a Glance

Aspect

seismic_call() (Signed Read)

call() (Transparent Read)

Method

provider.seismic_call(SendableTx::Builder(tx.into()))

provider.call(tx)

msg.sender

Your wallet address

Zero address (0x0)

Calldata

Encrypted with AES-GCM

Plaintext

Response

Encrypted by TEE, decrypted by provider

Plaintext

Transaction marker

.seismic() required

No .seismic()

Provider

SeismicSignedProvider only

Any provider

Privacy

Full (observers see nothing)

None (calldata and result visible)

Multiple Signed Reads

You can execute multiple signed reads in sequence:

Expected Output

Next Steps

See Also

Last updated