Skip to main content
@cypher-zk/sdk is the official TypeScript library for interacting with the Cyphers prediction market protocol on Solana. It wraps every on-chain instruction in a strongly-typed API, ships pre-built React hooks backed by TanStack Query, and exposes Arcium MPC encryption helpers so your users’ bet amounts and sides remain private end-to-end. The package is split into three import paths to keep bundle sizes lean. Most frontend applications only need the main entry point and the React subpath.
The SDK targets @solana/web3.js v1 (^1.95.x). It is not compatible with the web3.js v2 / @solana/kit API surface. Make sure your project resolves the v1 package.

Installation

Install the SDK and its required peer dependencies:
npm install @cypher-zk/sdk @solana/web3.js @solana/spl-token
If you plan to use the React hooks, you also need TanStack Query v5:
npm install @tanstack/react-query

Import subpaths

The package exposes three named subpaths. Import only what your environment needs.
SubpathWhat it providesUse in
@cypher-zk/sdkCypherClient, types, constants, PDA helpers, utilitiesAny JS/TS environment
@cypher-zk/sdk/reactCypherProvider, all React hooks, query-key factoriesBrowser / React apps
@cypher-zk/sdk/nodeReserved for future Node-only admin utilitiesDo not import in browser code
Never import @cypher-zk/sdk/node in browser or React Native code. It is a placeholder for future server-side helpers and will break any browser bundler that tries to resolve it.

Quick start

The minimal setup for a React application - create the client once and share it through the provider:
import { CypherClient } from '@cypher-zk/sdk';
import { CypherProvider } from '@cypher-zk/sdk/react';
import { Connection } from '@solana/web3.js';

// 1. Build the client (synchronous - no await)
const client = new CypherClient({
  connection: new Connection('https://api.devnet.solana.com', 'confirmed'),
  wallet: yourConnectedWallet,
  cluster: 'devnet',
});

// 2. Wrap your app
export function App() {
  return (
    <CypherProvider client={client}>
      <YourApp />
    </CypherProvider>
  );
}
From any component inside the provider you can now call hooks like useMarkets() or usePlaceBet(). See the React Hooks reference for a complete list.

What the SDK covers

CypherClient

The core client class. Exposes namespaced fetch methods, raw instruction builders, and high-level action helpers. Start here.

React Hooks

Fourteen hooks for reading market state and submitting transactions, all backed by TanStack Query with automatic cache invalidation.

Actions

High-level action functions - createMarket, placeBet, resolveMarket, claimPayout, and more. Each returns a progress-emitting promise.

Utilities

Fee calculators, market-phase helpers, question label parsers, Arcium encryption functions, and on-chain event parsers.

Key constants

A selection of the most commonly referenced constants exported from @cypher-zk/sdk:
ConstantValueDescription
PROGRAM_IDcyphPe923…oh2BDeployed Cyphers program address
MIN_BET_USDC1_000_000nMinimum bet ($1 USDC, 6 decimals)
MIN_CREATOR_BOND20_000_000nMinimum market creation bond ($20 USDC)
ODDS_SCALE1_000_000_000nFixed-point scale for odds values (1e9)
MAX_PROTOCOL_FEE_BPS100Maximum protocol fee (1%)
MAX_LP_FEE_BPS500Maximum LP fee (5%)
DEFAULT_RESOLUTION_WINDOW_SECS604_800Default resolution window (7 days)
Import them directly from the main package:
import { PROGRAM_ID, MIN_BET_USDC, ODDS_SCALE } from '@cypher-zk/sdk';