code-branchNamespaces

Contract interaction namespaces for shielded and transparent operations

Seismic contracts expose five namespaces for different types of operations. Each namespace provides a different combination of encryption, authentication, and transaction behavior.


Overview

When you instantiate a contract:

contract = w3.seismic.contract(address="0x...", abi=ABI)

You get access to five namespaces:

Namespace

Operation

Encryption

msg.sender

Broadcasts

Use Case

Write

Yes

Your address

Yes

Privacy-sensitive writes

Read

Yes

Your address

No

Access-controlled reads

Write

No

Your address

Yes

Public writes

Read

No

0x0

No

Public reads

Write

Yes

Your address

Yes

Debug/testing


Quick Comparison

Encrypted vs Transparent

Encrypted (.write, .read, .dwrite):

  • Calldata is encrypted using AES-GCM

  • Only you and the TEE can see plaintext

  • Requires ECDH key exchange with node

  • Includes security metadata (nonce, block hash, expiry)

  • Higher gas cost (encryption overhead)

Transparent (.twrite, .tread):

  • Calldata is visible on-chain

  • Standard Ethereum transactions/calls

  • No encryption or security metadata

  • Lower gas cost (no overhead)

  • Faster (no encryption computation)

Write vs Read

Write (.write, .twrite, .dwrite):

  • Broadcasts a transaction

  • Consumes gas

  • Modifies contract state

  • Returns transaction hash

  • Must wait for confirmation

Read (.read, .tread):

  • Executes an eth_call

  • Free (no gas cost)

  • Does not modify state

  • Returns result immediately

  • No confirmation needed


Usage Patterns

Encrypted Write (.write)

When to use:

  • Amounts, addresses, or arguments should be private

  • Privacy compliance required

  • Trading, voting, auctions, confidential transfers

Signed Read (.read)

When to use:

  • Contract checks msg.sender for access control

  • Caller-specific data (e.g., "my balance")

  • Privacy required for queries

  • Result should be encrypted

Transparent Write (.twrite)

When to use:

  • Data is public anyway

  • Lower gas cost matters

  • No privacy requirements

  • Standard Ethereum behavior

Transparent Read (.tread)

When to use:

  • Function is public (doesn't check msg.sender)

  • No authentication needed

  • Data is public

Debug Write (.dwrite)

When to use:

  • Development and testing

  • Debugging encryption issues

  • Verifying calldata encoding

  • Auditing transaction parameters


Common Pitfalls

Using .tread for Access-Controlled Functions

Problem:

Solution:

Using .write for Public Data

Unnecessary overhead:

Better:


See Also

Last updated