Install
bash
bun add @cypher-zk/sdk @solana/web3.jsbash
npm install @cypher-zk/sdk @solana/web3.jsbash
yarn add @cypher-zk/sdk @solana/web3.jsbash
pnpm add @cypher-zk/sdk @solana/web3.jsWarning: Pin
@solana/web3.jsto^1.95.4. The SDK is not compatible with@solana/web3.jsv2 or@solana/kit.
Import paths
The package ships three entry points. Only import what you need.
| Path | Use for |
|---|---|
@cypher-zk/sdk |
Core client, actions, account types, utilities |
@cypher-zk/sdk/react |
React hooks (usePlaceBet, useMarkets, etc.) |
Never import @cypher-zk/sdk/react in a Node.js script - it pulls in React and TanStack Query which are browser-only.
Buffer polyfill (Next.js / Vite)
The SDK uses Node's Buffer internally. In browser bundlers, Buffer is not available by default.
Next.js (Turbopack)
Create src/lib/buffer-polyfill.ts and import it at the top of your root layout:
ts
// src/lib/buffer-polyfill.ts
import { Buffer } from "buffer";
if (typeof window !== "undefined") {
window.Buffer = window.Buffer ?? Buffer;
}ts
// src/app/layout.tsx
import "@/lib/buffer-polyfill";Then add to next.config.ts:
ts
const nextConfig = {
experimental: {
turbo: {
resolveAlias: {
buffer: "buffer",
},
},
},
};Next.js (Webpack)
ts
// next.config.ts
const nextConfig = {
webpack: (config) => {
config.resolve.fallback = {
...config.resolve.fallback,
fs: false,
buffer: require.resolve("buffer/"),
};
return config;
},
};Install the buffer package:
bash
bun add bufferbash
npm install bufferbash
yarn add bufferbash
pnpm add bufferVite
ts
// vite.config.ts
import { defineConfig } from "vite";
import { nodePolyfills } from "vite-plugin-node-polyfills";
export default defineConfig({
plugins: [nodePolyfills()],
});bash
bun add vite-plugin-node-polyfillsbash
npm install vite-plugin-node-polyfillsbash
yarn add vite-plugin-node-polyfillsbash
pnpm add vite-plugin-node-polyfillsWhat's next
- Quickstart - initialize the client and place your first bet
- React setup - wire up
CypherProviderin your app