SRC20
Privacy-preserving ERC20 tokens with shielded balances
SRC20 is Seismic's privacy-preserving ERC20 standard. Balances and transfer amounts use shielded types (suint256), so they are hidden from external observers. The protocol ensures that only authorized parties — the token holder or those with a viewing key — can read balances and decode transfer events.
Contract Interface
Define the SRC20 interface using Alloy's sol! macro:
use seismic_prelude::client::*;
sol! {
#[sol(rpc)]
interface ISRC20 {
function name() public view returns (string);
function symbol() public view returns (string);
function decimals() public view returns (uint8);
function totalSupply() public view returns (uint256);
function balanceOf(address account) public view returns (suint256);
function transfer(address to, suint256 amount) public returns (bool);
function approve(address spender, suint256 amount) public returns (bool);
function allowance(address owner, address spender) public view returns (suint256);
function transferFrom(address from, address to, suint256 amount) public returns (bool);
event Transfer(address indexed from, address indexed to, suint256 value);
event Approval(address indexed owner, address indexed spender, suint256 value);
}
}Architecture
Quick Start
Navigation
Reading and writing SRC20 balances, signed reads, shielded writes
Shielded transfer patterns, approvals, and multi-step workflows
Decrypting encrypted Transfer and Approval events
Key Concepts
Signed Reads for Balances
Unlike ERC20 where balanceOf() is a simple public read, SRC20's balanceOf() uses msg.sender to authenticate the caller. This means you must use seismic_call() (a signed read) rather than a plain eth_call. A plain eth_call zeros out the from field, so the contract sees the zero address as the sender and returns its balance — which is almost certainly zero.
Shielded Writes
Transfers and approvals have shielded parameters (suint256), so the sol! macro wraps them in a ShieldedCallBuilder that auto-encrypts — just call .send() directly. The SeismicProviderBuilder-created provider's filler pipeline automatically handles the encryption before the transaction reaches the node.
Encrypted Events
SRC20 Transfer and Approval events contain encrypted suint256 values. To decode the actual transfer amounts, you need a viewing key registered with the Directory contract.
See Also
Contract Interaction — General shielded and transparent call patterns
SeismicSignedProvider — Required for shielded operations
Encryption — How calldata encryption works
Last updated

