ShieldedContract
Sync contract wrapper with shielded and transparent namespaces
Synchronous contract wrapper providing encrypted and transparent interaction with Seismic contracts.
Overview
ShieldedContract is the primary sync interface for interacting with Seismic smart contracts. It provides five namespaces for different interaction modes: encrypted writes (.write), encrypted reads (.read), transparent writes (.twrite), transparent reads (.tread), and debug writes (.dwrite). Each namespace dynamically exposes contract methods based on the provided ABI.
Definition
class ShieldedContract:
def __init__(
self,
w3: Web3,
encryption: EncryptionState,
private_key: PrivateKey,
address: ChecksumAddress,
abi: list[dict[str, Any]],
eip712: bool = False,
) -> None:
...Constructor Parameters
w3
Web3
Yes
Synchronous Web3 instance connected to Seismic RPC
address
ChecksumAddress
Yes
Contract address (checksummed Ethereum address)
abi
list[dict[str, Any]]
Yes
Contract ABI (list of function entries)
eip712
bool
No
Use EIP-712 typed data signing (default: False)
Namespaces
.write - Encrypted Write
Sends encrypted transactions using TxSeismic (type 0x4a). Calldata is encrypted before broadcast.
Returns: HexBytes (transaction hash)
Positional Arguments: *args - ABI function arguments (e.g. contract.write.transfer(to, amount))
Optional Parameters:
value: int- Wei to send (default:0)gas: int | None- Gas limit (default:30_000_000when omitted)gas_price: int | None- Gas price in wei (default: network suggested)security: [SeismicSecurityParams](../api-reference/transaction-types/seismic-security-params.md) | None- Security parameters for expiry
.read - Encrypted Read
Executes encrypted signed eth_call with encrypted calldata. Result is decrypted and ABI-decoded by the SDK. Single-output functions return the value directly (e.g. int, bool); multi-output functions return a tuple.
Returns: Any (ABI-decoded Python value)
Positional Arguments: *args - ABI function arguments (e.g. contract.read.balanceOf(owner))
Optional Parameters:
value: int- Wei for call context (default:0)gas: int- Gas limit (default:30_000_000)security: [SeismicSecurityParams](../api-reference/transaction-types/seismic-security-params.md) | None- Security parameters for expiry
.twrite - Transparent Write
Sends standard eth_sendTransaction with unencrypted calldata.
Returns: HexBytes (transaction hash)
Positional Arguments: *args - ABI function arguments
Optional Parameters:
value: int- Wei to send (default:0)**tx_params: Any- Additional transaction parameters (gas, gasPrice, etc.)
.tread - Transparent Read
Executes standard eth_call with unencrypted calldata. Result is ABI-decoded by the SDK. Single-output functions return the value directly; multi-output functions return a tuple.
Returns: Any (ABI-decoded Python value)
Positional Arguments: *args - ABI function arguments
.dwrite - Debug Write
Like .write but returns debug information including plaintext and encrypted views. Transaction is actually broadcast.
Returns: DebugWriteResult
Positional Arguments: *args - ABI function arguments
Optional Parameters: Same as .write
Examples
Basic Encrypted Write
Encrypted Read
Transparent Operations
Debug Write
With Transaction Parameters
Using EIP-712 Signing
Instantiation via Client
Notes
Dynamic method access: Contract methods are accessed via
__getattr__, socontract.write.setNumber()dynamically resolves to the ABI functionABI remapping: Shielded types (
suint256,sbool,saddress) are remapped to standard types for encoding while preserving original names for selector computationGas defaults:
.writeuses30_000_000whengasis omitted;.twritefollows normalweb3.py/provider transaction behaviorEncryption overhead: Encrypted operations add ~16 bytes (AES-GCM auth tag) to calldata
EIP-712 vs raw: EIP-712 signing enables integration with browser extension wallets like Metamask; raw signing is faster for automation and likely what you want to use in this Python SDK
Use
.writein production:.dwriteis for debugging only
See Also
AsyncShieldedContract - Async version of this class
PublicContract - Read-only contract wrapper (no encryption)
EncryptionState - Manages encryption keys
DebugWriteResult - Debug write return type
SeismicSecurityParams - Transaction expiry parameters
Contract Namespaces - Detailed namespace documentation
Shielded Write Guide - Complete workflow guide
Last updated

