file-lockShieldedContract

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

Parameter
Type
Required
Description

w3

Web3

Yes

Synchronous Web3 instance connected to Seismic RPC

encryption

Yes

Encryption state for shielded operations

private_key

Yes

32-byte secp256k1 private key for signing transactions

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)

Optional Parameters:

  • value: int - Wei to send (default: 0)

  • gas: int | None - Gas limit (default: estimated)

  • gas_price: int | None - Gas price in wei (default: network suggested)

  • security: SeismicSecurityParams | None - Security parameters for expiry

.read - Encrypted Read

Executes encrypted signed eth_call with encrypted calldata. Result is decrypted by the SDK.

Returns: HexBytes (decrypted result bytes)

Optional Parameters:

  • value: int - Wei for call context (default: 0)

  • gas: int - Gas limit (default: 30_000_000)

  • security: SeismicSecurityParams | None - Security parameters for expiry

.twrite - Transparent Write

Sends standard eth_sendTransaction with unencrypted calldata.

Returns: HexBytes (transaction hash)

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.

Returns: HexBytes (raw result bytes)

Optional Parameters: None (pass positional arguments only)

.dwrite - Debug Write

Like .write but returns debug information including plaintext and encrypted views. Transaction is actually broadcast.

Returns: DebugWriteResult

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__, so contract.write.myFunction() dynamically resolves to the ABI function

  • ABI remapping: Shielded types (suint256, sbool, saddress) are remapped to standard types for encoding while preserving original names for selector computation

  • Gas estimation: .write and .twrite estimate gas if not provided explicitly

  • Encryption overhead: Encrypted operations add ~16 bytes (AES-GCM auth tag) to calldata

  • EIP-712 vs raw: EIP-712 signing provides better wallet integration; raw signing is faster for automation

  • Use .write in production: .dwrite is for debugging only

See Also

Last updated