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

Quick start

Get from zero to a working confidential transfer in under 5 minutes.

Looking for the legacy Relayer SDK?

This is the new default SDK for building on the Zama Protocol. The legacy @zama-fhe/relayer-sdk lives at github.com/zama-ai/relayer-sdk.

Pick your stack. Each tab gets you from install to a working confidential transfer.

The first three tabs are for browser apps (React dApp, vanilla viem, or ethers). The Node.js tabs are for backend services, scripts, and bots that operate on confidential tokens server-side — they use native worker threads instead of a Web Worker and store keys in memory.

In browser apps, prefix client-side variables with NEXT_PUBLIC_ (Next.js) or VITE_ (Vite) so the bundler exposes them.

Authentication

The sepolia testnet relayer needs no API key — the preset works as-is, so leave auth unset and move on. You only need a key for the Zama-hosted mainnet relayer; when you deploy there, see Authentication for the backend-proxy (browser) and direct-key (server) patterns.

Install

pnpm add @zama-fhe/sdk @zama-fhe/react-sdk @tanstack/react-query wagmi viem

Set up the SDK

import { WagmiProvider, createConfig, http } from "wagmi";
import { sepolia } from "wagmi/chains";
import { injected } from "wagmi/connectors";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { ZamaProvider } from "@zama-fhe/react-sdk";
import { web } from "@zama-fhe/sdk/web";
import { createConfig as createZamaConfig } from "@zama-fhe/react-sdk/wagmi";
import { sepolia as sepoliaFhe, type FheChain } from "@zama-fhe/sdk/chains";

const wagmiConfig = createConfig({
  chains: [sepolia],
  connectors: [injected()],
  transports: { [sepolia.id]: http("https://sepolia.infura.io/v3/YOUR_KEY") },
});

const mySepolia = {
  ...sepoliaFhe,
  relayerUrl: "https://your-app.com/api/relayer/11155111",
} as const satisfies FheChain;

const zamaConfig = createZamaConfig({
  chains: [mySepolia],
  wagmiConfig,
  relayers: { [mySepolia.id]: web() },
});

const queryClient = new QueryClient();

function App() {
  return (
    <WagmiProvider config={wagmiConfig}>
      <QueryClientProvider client={queryClient}>
        <ZamaProvider config={zamaConfig}>
          <MyTokenPage />
        </ZamaProvider>
      </QueryClientProvider>
    </WagmiProvider>
  );
}

FHE artifact caching — Both web() and node() relayers automatically cache the multi-MB FHE encryption key and parameters so they are not re-downloaded on every startup. Browser uses IndexedDB (persists across reloads), Node.js uses in-memory storage (lost on restart). The cache revalidates against the CDN every 24 hours. Configure it via the options passed to web() / node(). See FheArtifactCache for details.

Your first confidential transfer

The hooks and SDK methods handle FHE encryption, wallet signing, ERC-20 approvals, and cache invalidation automatically.

Next steps

  • Configuration -- chains, relayers, provider, signer, storage, and authentication setup

  • Shield Tokens -- move tokens into confidential form

  • Chain Objects -- pre-configured chain definitions for Sepolia, Mainnet, and more

  • React Hooks -- provider setup and all available hooks

  • Security Model -- understand the cryptography and trust assumptions

Last updated