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.
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:
Full Working Example
Combining all steps into one program:
Expected Output
Next Steps
Shielded Write Complete - Full shielded write lifecycle
Signed Read Pattern - Authenticated read examples
Basic Setup - Provider setup details
See Also
Transparent Calls - Deployment and transparent operations
Shielded Calls - Encrypted operations
Shielded Write Guide - Step-by-step guide
Signed Reads Guide - Signed read guide
Installation - Cargo setup and dependencies
Last updated

