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

Contract Deployment

Deploy and interact with a shielded contract

This example demonstrates the full contract lifecycle: compile a contract (with notes on sfoundry/ssolc), deploy it, verify the deployment, interact with it using shielded calls, and subscribe to events via WebSocket.

Prerequisites

# Install Seismic Foundry tools
# See Seismic Foundry documentation for installation

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

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

[package]
name = "contract-deployment"
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" }
alloy-provider         = "1.1"
alloy-signer-local     = "1.1"
alloy-primitives       = "1.1"
alloy-sol-types        = "1.1"
alloy-network          = "1.1"
alloy-rpc-types-eth    = "1.1"
futures-util           = "0.3"
tokio                  = { version = "1", features = ["full"] }
reqwest                = "0.12"

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

Step 1: Compile the Contract

Seismic contracts use ssolc (Seismic Solidity Compiler) and sfoundry (Seismic Foundry) for compilation. A typical contract:

Compile with sfoundry:

The compiled bytecode is in out/SeismicCounter.sol/SeismicCounter.json. Extract the bytecode.object field for the #[sol(rpc, bytecode = "...")] attribute.

ssolc extends the standard Solidity compiler with support for shielded types (suint256, sbool, saddress, etc.). These types use encrypted storage (CSTORE/CLOAD) under the hood but are ABI-compatible with their standard counterparts.

Step 2: Deploy and Interact

Use #[sol(rpc, bytecode = "...")] to generate a deploy() method and type-safe call builders:

Step 3: Shielded Interactions

Once deployed, interact with the contract using shielded calls:

Step 4: Subscribe to Events (WebSocket)

Event subscription requires a WebSocket connection. Use an unsigned provider:

Event data emitted by emit is public and visible on-chain. Event subscription does not require a signed provider. If you need to keep event data private, avoid emitting sensitive values.

Full Working Example

Combining all steps into one program:

Expected Output

Next Steps

See Also

Last updated