Quickstart

1. Create a React + Typescript Project

Let's create a simple vite project with React and Typescript:

npm create vite@latest sdk-test -- --template react-ts

2. Install Dependencies

Install shielder-sdk and additional dependencies:

npm install @cardinal-cryptography/[email protected]
npm install @cardinal-cryptography/[email protected]
npm install @cardinal-cryptography/[email protected]
npm install viem @types/node @vitejs/plugin-react

3. Configure Vite

Add following code to vite.config.ts :

vite.config.ts
import * as path from "path";
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";

function crossOriginIsolationMiddleware(_, res, next) {
  res.setHeader("Cross-Origin-Opener-Policy", "same-origin");
  res.setHeader("Cross-Origin-Embedder-Policy", "require-corp");
  next();
}

const setCors = () => ({
  name: "configure-server",
  configureServer: (server) => {
    server.middlewares.use(crossOriginIsolationMiddleware);
  },
  configurePreviewServer: (server) => {
    server.middlewares.use(crossOriginIsolationMiddleware);
  },
});

// https://vite.dev/config/
export default defineConfig({
  plugins: [react(), setCors()],
  resolve: {
    alias: {
      "@": path.resolve(__dirname, "./src"),
    },
  },
  optimizeDeps: {
    exclude: ["@cardinal-cryptography/shielder-sdk-crypto-wasm"],
  },
});

4. Set Up WASM Cryptography Client

Create a file src/shielderWasm.ts , where we'll set up the wasm engine loading

5. Initialize the Shielder SDK Client

Create src/shielder.ts:

6. Verify the Setup

In your main file (e.g. src/main.tsx or src/App.tsx):

At this point, your app is connected to the Shielder network, has synced the private account, and can query its state.

Next steps:

Both operations require working with token approvals, gas fees, and relayer coordination.

We recommend you handle those through user-facing components in your app UI.

Explore the guides to implement full privacy flow.

Last updated