Demo of using the typescript zk-email sdk
This project requires Node.js version 20 or above. We recommend using nvm (Node Version Manager) to manage your Node.js versions.
-
Install nvm:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash -
Restart your terminal and verify nvm installation:
nvm --version
-
Install and use Node.js v20:
nvm install 20 nvm use 20
Before running any demo, you need to:
- Add your EML file: Place your
.emlemail file in theemls/directory at the root of this project - Update the file path: In each project you want to run, update the EML file path to point to your email file (e.g.,
../emls/your-email.eml)
This demo requires bun to run:
# Navigate to the Node.js demo directory
cd node_js
# Install dependencies
bun i
# Run the demo
bun src/shortest-example.tsMake sure you have Deno installed.
# Navigate to the Deno demo directory
cd deno
# Run the development server
deno task dev# Navigate to the NextJS demo directory
cd nextjs
# Install dependencies
pnpm i
# Start the development server
pnpm run dev# Navigate to the Vite demo directory
cd vite
# Install dependencies
pnpm i
# Start the development server
pnpm run devWhen using local (in-browser) proving with Noir blueprints, you need to initialize the Noir WASM modules.
import { initZkEmailSdk } from "@zk-email/sdk";
import { initNoirWasm } from "@zk-email/sdk/initNoirWasm";// Initialize NoirWasm before generating proof
const noirWasm = await initNoirWasm();
// Pass noirWasm to generateProof
const proof = await prover.generateProof(emailContent, [], { noirWasm });-
Each demo is contained in its own directory with its specific dependencies
-
Make sure to install the required package managers before running the respective demos:
Install bun:
curl -fsSL https://bun.sh/install | bashInstall pnpm:
npm install -g pnpm
-
For the best development experience, ensure you're using the latest stable versions of all tools