For the complete documentation index, see llms.txt. This page is also available as Markdown.

Shielded Wallet Client

Full-featured client with encryption, shielded writes, and signed reads

Full-featured client for Seismic that handles encryption, shielded writes, and signed reads. Extends viem's wallet client with an ECDH-derived AES encryption pipeline. On construction, it fetches the TEE public key from the node and derives a shared AES key for encrypting calldata.

Import

import { createShieldedWalletClient } from "seismic-viem";

Constructor

const walletClient = await createShieldedWalletClient({
  chain: seismicTestnet,
  transport: http(),
  account: privateKeyToAccount("0x..."),
});

createShieldedWalletClient is async -- it fetches the TEE public key from the node during construction and derives the AES encryption key. Always await the result.

Parameters

Parameter
Type
Required
Description

chain

Chain

Yes

Chain configuration (e.g., seismicTestnet)

transport

Transport

Yes

viem transport (e.g., http())

account

Account

Yes

viem account (from privateKeyToAccount or custom)

encryptionSk

Hex

No

Custom encryption private key. If not provided, generates a random secp256k1 key

publicClient

ShieldedPublicClient

No

Reuse an existing ShieldedPublicClient instead of creating a new one

Return Type

Promise<ShieldedWalletClient>

A viem Client extended with PublicActions, WalletActions, EncryptionActions, ShieldedPublicActions, ShieldedWalletActions, DepositContractPublicActions, DepositContractWalletActions, and SRC20WalletActions.

Usage

Initialization Lifecycle

When you call createShieldedWalletClient(), the following steps happen:

  1. Creates a ShieldedPublicClient (or reuses the one provided via publicClient)

  2. Fetches the TEE public key from the node via seismic_getTeePublicKey RPC

  3. Generates an ephemeral secp256k1 keypair (or uses the provided encryptionSk)

  4. Derives an AES-256 key via ECDH between the client's private key and the TEE's public key

  5. Composes all action layers (PublicActions, WalletActions, EncryptionActions, ShieldedPublicActions, ShieldedWalletActions, DepositContractPublicActions, DepositContractWalletActions, SRC20WalletActions) onto a single viem client

Actions

Shielded Wallet Actions

Action
Description

writeContract(params)

Smart write -- inspects ABI for shielded params; encrypts if shielded, sends transparent otherwise

swriteContract(params)

Force shielded write -- always encrypts calldata with the AES key before sending

twriteContract(params)

Transparent write -- always sends with plaintext calldata (unencrypted)

dwriteContract(params)

Send + inspect write -- broadcasts a real shielded tx and returns the plaintext tx, shielded tx, and txHash

readContract(params)

Smart read -- inspects ABI for shielded params; uses signed read if shielded, transparent read otherwise

sreadContract(params)

Force signed read -- always authenticated eth_call that proves the caller's identity

treadContract(params)

Transparent read -- always standard unsigned call. Rejects account (Seismic zeroes out from on transparent eth_call); use sreadContract for sender-aware reads

signedCall(params)

Low-level signed eth_call

sendShieldedTransaction(params)

Low-level shielded transaction send

Encryption Actions

Action
Description

getEncryption()

Returns the AES encryption key used for shielded operations

getEncryptionPublicKey()

Returns the client's encryption public key (the ephemeral secp256k1 public key)

encrypt(plaintext, metadata)

Manual AES-GCM encryption using the derived key

decrypt(ciphertext, metadata)

Manual AES-GCM decryption using the derived key

Inherited Actions

The wallet client also includes all actions from ShieldedPublicClient:

  • Shielded public actions -- getTeePublicKey(), explorerUrl(), etc.

  • Precompile actions -- rng(), ecdh(), aesGcmEncryption(), aesGcmDecryption(), hdfk(), secp256k1Signature()

  • SRC20 actions -- watchSRC20Events(), watchSRC20EventsWithKey()

  • Deposit contract actions -- getDepositRoot(), getDepositCount()

  • Standard viem public actions -- getBlockNumber(), getBalance(), getBlock(), etc.

  • Standard viem wallet actions -- sendTransaction(), signMessage(), signTypedData(), etc.

The wallet client automatically includes all public client actions -- you can call getBlockNumber(), getBalance(), etc. directly on it.

Examples

Shielded Write

Signed Read

Reusing a Public Client

Send + Inspect Write

Custom Encryption Key

getEncryption() Standalone Function

The encryption derivation logic is also available as a standalone function, separate from any client:

Parameter
Type
Required
Description

networkPk

Hex

Yes

The TEE's secp256k1 public key

clientSk

Hex

No

Client's encryption private key. If not provided, generates a random one

Returns { aesKey: Hex, encryptionPrivateKey: Hex, encryptionPublicKey: Hex }.

This is useful when you need the encryption key material without constructing a full wallet client -- for example, to manually encrypt or decrypt data outside of the client's lifecycle.

See Also

Last updated