rocketContract 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 transparently, 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://gcp-1.seismictest.net/rpc"
export WS_URL="wss://gcp-1.seismictest.net/ws"

Cargo.toml:

[package]
name = "contract-deployment"
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"
alloy-rpc-types-eth = "1.1"
futures-util = "0.3"
hex-literal = "0.4"
tokio = { version = "1", features = ["full"] }

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 deployment.

circle-info

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 the Contract

Contract deployment always uses transparent transactions because Create transactions cannot be seismic.

Step 3: Verify Deployment

After deployment, verify the contract exists at the expected address by checking the deployed bytecode:

Step 4: Interact with Shielded Calls

Once deployed, interact with the contract using shielded writes and signed reads:

Step 5: Subscribe to Events (WebSocket)

Event subscription requires a WebSocket connection. Use SeismicUnsignedProvider with new_ws():

circle-info

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

Common Patterns

Deploy with Constructor Arguments

If your contract has a constructor that takes arguments, append the ABI-encoded constructor arguments to the bytecode:

Multiple Contract Deployments

Next Steps

See Also

Last updated