Contract Interaction
Interacting with Seismic contracts using seismic-alloy
Patterns for calling and transacting with smart contracts on Seismic using the Rust SDK.
Overview
seismic-alloy uses Alloy's sol! macro with #[sol(rpc)] to define contract interfaces and generate type-safe call builders. Functions with shielded parameters (e.g., suint256, saddress, sbool) auto-encrypt via ShieldedCallBuilder — you can call .send() or .call() directly without .seismic(). For non-shielded functions that still need encryption, use .seismic() to opt in. Omit .seismic() entirely for transparent (unencrypted) operations.
Key Concepts
sol!macro with#[sol(rpc)]— Define contract interfaces with Solidity syntax, generate call builders and deploy methodsAuto-encryption for shielded params — Functions with shielded types in their arguments return a
ShieldedCallBuilderautomatically; call.send()or.call()directly.seismic()call builder — For non-shielded functions that need encryption; converts aSolCallBuilderinto aShieldedCallBuilderTwo traits —
SeismicCallExtadds.seismic()toSolCallBuilder;ShieldedCallExtadds.call(),.send(), and builder methods toShieldedCallBuilderSecurityParams — Per-call overrides for expiration, block hash, and encryption nonce
EIP-712 —
.eip712()onShieldedCallBuilderfor browser wallet compatibility
Shielded vs. Transparent Operations
Shielded Read
Function has shielded params
contract.method().call().await?
SeismicSignedProvider
Shielded Read
Function has no shielded params
contract.method().seismic().call().await?
SeismicSignedProvider
Shielded Write
Function has shielded params
contract.method().send().await?
SeismicSignedProvider
Shielded Write
Function has no shielded params
contract.method().seismic().send().await?
SeismicSignedProvider
Transparent Read
Any
contract.method().call().await?
Any provider
Transparent Write
Any
contract.method().send().await?
SeismicSignedProvider
Contract deployment (Create transactions) cannot be seismic. Deploy your contract with a standard transaction, then interact with it using shielded calls.
Defining Contract Interfaces
Use Alloy's sol! macro with #[sol(rpc)] to define your contract's interface. This generates type-safe call builders with .call() and .send() methods:
To also include deployment, add the bytecode attribute:
Quick Example
Navigation
Encrypted writes and signed reads using auto-encryption and .seismic()
Standard Ethereum calls without encryption
See Also
SeismicSignedProvider — Required for shielded operations
SeismicUnsignedProvider — Sufficient for transparent reads
Transaction Types — Underlying transaction structs
Encryption — How calldata encryption works
Last updated

