playBasic dApp

Complete minimal dApp with shielded writes and signed reads

This example builds a complete minimal dApp that connects a wallet, sends a shielded write transaction, and performs a signed read -- all using seismic-react hooks.

What You'll Build

  1. Provider setup with RainbowKit + Seismic

  2. Wallet connection via RainbowKit's ConnectButton

  3. Shielded write to a contract (encrypted calldata)

  4. Signed read from a contract (authenticated query)

Prerequisites

Install dependencies:

npm install seismic-react seismic-viem wagmi viem @rainbow-me/rainbowkit @tanstack/react-query

Step 1: wagmi Config

Create the wagmi configuration with the Seismic testnet chain:

// config.ts
import { getDefaultConfig } from "@rainbow-me/rainbowkit";
import { seismicTestnet } from "seismic-react/rainbowkit";

export const config = getDefaultConfig({
  appName: "Seismic Basic dApp",
  projectId: "YOUR_WALLETCONNECT_PROJECT_ID",
  chains: [seismicTestnet],
});
circle-exclamation

Step 2: Provider Wrapper

Wrap your app with the required providers. ShieldedWalletProvider must be nested inside the wagmi and React Query providers:

Step 3: Contract Interaction Component

Create a component that uses useShieldedWriteContract and useSignedReadContract to interact with a shielded counter contract:

circle-info

Replace CONTRACT_ADDRESS with the address of a deployed shielded contract on Seismic testnet. The ABI above is for a simple counter -- adapt it to match your contract.

Step 4: App Component

Combine the wallet connection button with the counter component. The counter only renders once the shielded wallet is ready:

What's Happening

  1. RainbowKit handles wallet connection and chain switching

  2. ShieldedWalletProvider automatically creates shielded clients when a wallet connects, performing the ECDH key exchange with the TEE

  3. useShieldedWriteContract encrypts calldata before sending the transaction, ensuring on-chain privacy

  4. useSignedReadContract attaches a signature proving caller identity, allowing the contract to return private data only to authorized readers

Next Steps

See Also

Last updated