shield-halvedsend_shielded_transaction

Send a shielded transaction with encrypted calldata to the Seismic network

Send a shielded transaction with end-to-end encrypted calldata using Seismic's TxSeismic (type 0x4a) transaction format. The calldata is encrypted client-side and decrypted only inside the node's TEE.


Overview

This is the low-level method for sending encrypted transactions. It:

  1. Encrypts the provided plaintext calldata using AES-GCM

  2. Constructs a TxSeismic transaction with encryption metadata

  3. Signs the transaction with your private key

  4. Broadcasts it to the network via eth_sendRawTransaction

  5. Returns the transaction hash

For contract interactions, use contract.write.functionName(...) instead — it handles ABI encoding and encryption automatically.


Signatures

Sync
Async

Parameters

All parameters are keyword-only to prevent accidental misuse.

Parameter
Type
Default
Description

to

ChecksumAddress

Required

Recipient contract address

data

HexBytes

Required

Plaintext calldata (will be encrypted)

value

int

0

Wei to transfer with the transaction

gas

int | None

None

Gas limit (auto-estimated if None)

gas_price

int | None

None

Gas price in wei (uses network default if None)

security

None

Custom security parameters (block hash, nonce, expiry)

eip712

bool

False

Use EIP-712 typed data signing instead of raw signing


Returns

Type: HexBytes

The transaction hash returned by eth_sendRawTransaction.


Examples

Sync Usage

Async Usage

Sending ETH

Custom Security Parameters

With ABI Encoding

Using EIP-712 Signing


Implementation Details

Encryption Process

The SDK performs the following steps:

  1. Fetch security parameters (if not provided):

    • Get latest block hash for freshness proof

    • Generate random 12-byte AES-GCM nonce

    • Calculate expiry block (current + 100 blocks)

  2. Construct metadata:

    • Sender address

    • Chain ID, nonce, to, value

    • Block hash, expiry, encryption nonce

  3. Encrypt calldata:

    • Use ECDH-derived AES-GCM key

    • Bind ciphertext to metadata via AAD (Additional Authenticated Data)

  4. Build transaction:

    • Construct TxSeismic (type 0x4a)

    • Include Seismic elements (encryption metadata)

  5. Sign and broadcast:

    • Sign transaction with private key (raw or EIP-712)

    • Broadcast via eth_sendRawTransaction

Gas Estimation

If gas=None, the SDK:

  • Calls eth_estimateGas with the encrypted transaction

  • Adds a buffer for potential variations

  • Uses the estimated value

If the estimation fails, consider providing an explicit gas limit.

Gas Price

If gas_price=None, the SDK uses eth_gasPrice to fetch the current network gas price.


Privacy Guarantees

What Gets Encrypted

  • Function selector (4 bytes)

  • All function arguments

  • Encoding metadata

What Remains Visible

These fields are not encrypted:

  • from — Your wallet address

  • to — Contract address

  • value — ETH amount sent

  • gas and gas_price — Gas parameters

  • nonce — Transaction nonce

  • Encryption metadata (block hash, expiry, nonce)

An observer can see you sent a transaction to a contract, but cannot see which function you called or what arguments you passed.


Security Considerations

Block Hash Freshness

Every shielded transaction includes a recent block hash as a freshness proof. The node validates:

  1. The block hash corresponds to a real block

  2. The block is recent (within the chain's freshness window)

This prevents replay attacks and stale submissions.

Transaction Expiry

Transactions include an expiry block number (default: current + 100 blocks). After this block, the node rejects the transaction.

If your transaction doesn't get mined in time, you must create a new one with updated parameters.

Nonce Uniqueness

Each transaction uses a cryptographically random 12-byte encryption nonce. Never reuse nonces — this breaks AES-GCM security.

The SDK generates random nonces automatically. Only override if you know what you're doing (e.g., testing).


Error Handling


When to Use

Use send_shielded_transaction() When

  • You need low-level control over transaction construction

  • You have pre-encoded calldata

  • You're implementing custom encryption logic

  • You need to handle contract deployment (use to=None)

Use contract.write When

  • You're calling a contract function with known ABI

  • You want automatic ABI encoding

  • You prefer high-level, ergonomic API


Notes

Requires Wallet Client

This method is only available on wallet clients created with create_wallet_client(). It requires:

  • A private key for signing

  • Encryption state (derived from TEE public key)

Public clients (create_public_client) do not have this method.

Transaction Type

This method creates TxSeismic (type 0x4a) transactions. These are Seismic-specific and not compatible with standard Ethereum nodes.

Nonce Management

The SDK automatically fetches and increments the nonce using eth_getTransactionCount. You don't need to manage nonces manually.


See Also

Last updated