Skip to content

Types

TypeScript type definitions exported by the SDK.

Import Types

typescript
import type {
  PrivacyClientConfig,
  ConnectOptions,
  TransferRequest,
  UnshieldRequest,
  TrackedNote,
  SyncProgress,
  NetworkName,
} from '@zkprivacy/sdk';

Client Types

PrivacyClientConfig

Configuration for PrivacyClient constructor.

typescript
interface PrivacyClientConfig {
  /** Ethereum JSON-RPC endpoint */
  rpcUrl: string;
  
  /** UTXOPool contract address */
  poolAddress: Address;
  
  /** Chain ID (auto-detected if not provided) */
  chainId?: number;
  
  /** Relayer URL for gasless transactions */
  relayerUrl?: string;
  
  /** QuickSync service URL for fast sync */
  quickSyncUrl?: string;
  
  /** Prover instance (uses global if not provided) */
  prover?: Prover;
  
  /** Use Anvil test account for gas (development) */
  devMode?: boolean;
  
  /** Enable IndexedDB caching (default: true) */
  enableCache?: boolean;
  
  /** Market maker URL for swaps */
  makerUrl?: string;
}

ConnectOptions

Options for client.connect().

typescript
interface ConnectOptions {
  /** Connection mode */
  mode: 'standalone' | 'linked';
  
  /** BIP-39 mnemonic (standalone mode) */
  mnemonic?: string;
  
  /** Raw spending key (standalone mode) */
  spendingKey?: bigint;
  
  /** Wallet client for EIP-712 signature (linked mode) */
  walletClient?: WalletClient;
  
  /** Account index for multi-account (default: 0) */
  accountIndex?: number;
}

Transaction Types

TransferRequest

Request for private transfer.

typescript
interface TransferRequest {
  /** Recipient ZK address (zks1...) */
  recipient: string;
  
  /** Amount to send (wei or human-readable) */
  amount: string | bigint;
  
  /** Token ID (0n for ETH) */
  tokenId?: bigint;
  
  /** Specific notes to spend (overrides auto-selection) */
  inputNotes?: TrackedNote[];
}

UnshieldRequest

Request for withdrawal to EOA.

typescript
interface UnshieldRequest {
  /** Recipient EOA address (0x...) */
  recipient: Address;
  
  /** Amount to withdraw */
  amount: string | bigint;
  
  /** Token ID (0n for ETH) */
  tokenId?: bigint;
}

ConsolidateRequest

Request to merge notes.

typescript
interface ConsolidateRequest {
  /** Notes to consolidate (max 2) */
  notes: TrackedNote[];
  
  /** Token ID */
  tokenId?: bigint;
}

Note Types

TrackedNote

A decrypted note with metadata.

typescript
interface TrackedNote {
  /** The note contents */
  note: Note;
  
  /** Commitment hash */
  commitment: bigint;
  
  /** Position in Merkle tree */
  leafIndex: number;
  
  /** Nullifier (spend tag) */
  nullifier: bigint;
  
  /** Whether note has been spent */
  spent: boolean;
  
  /** Transaction that created this note */
  txHash?: Hash;
  
  /** Block number when created */
  blockNumber?: bigint;
  
  /** Token ID */
  tokenId: bigint;
  
  /** Sender's ZK address (if available) */
  senderAddress?: string;
}

Note

Core note structure.

typescript
interface Note {
  /** Nullifier public key */
  npk: bigint;
  
  /** Amount in smallest units */
  amount: bigint;
  
  /** Random blinding factor */
  random: bigint;
}

Sync Types

SyncProgress

Progress callback data for sync.

typescript
interface SyncProgress {
  /** Current sync phase */
  phase: 'commitments' | 'notes' | 'nullifiers';
  
  /** Items processed */
  current: number;
  
  /** Total items */
  total: number;
  
  /** Human-readable status */
  message: string;
}

Prover Types

ProverConfig

Configuration for prover creation.

typescript
interface ProverConfig {
  /** Transfer circuit (URL or parsed JSON) */
  transferCircuit: CircuitSource;
  
  /** Unshield circuit (URL or parsed JSON) */
  unshieldCircuit: CircuitSource;
}

type CircuitSource = string | CompiledCircuit;

interface CompiledCircuit {
  noir_version: string;
  hash: number;
  abi: object;
  bytecode: string;
}

ProofResult

Result of proof generation.

typescript
interface ProofResult {
  /** ZK proof bytes */
  proof: Uint8Array;
  
  /** Public inputs for verification */
  publicInputs: bigint[];
}

Token Types

TokenInfo

Token metadata.

typescript
interface TokenInfo {
  /** Token symbol */
  symbol: TokenSymbol;
  
  /** Human-readable name */
  name: string;
  
  /** Decimal places */
  decimals: number;
  
  /** Token type */
  type: TokenType;
  
  /** Backing fiat currency */
  fiat: FiatCurrency;
  
  /** Addresses by network */
  address: {
    local: Address;
    remote: Address;
    testnet?: Address;
    mainnet?: Address;
  };
}

type TokenSymbol = 'zkUSD' | 'zkEUR' | 'zkPLN';
type TokenType = 'emt' | 'native';
type FiatCurrency = 'USD' | 'EUR' | 'PLN';

Network Types

NetworkName

Supported networks.

typescript
type NetworkName = 'local' | 'remote' | 'testnet' | 'mainnet';

Deployment

Network deployment configuration.

typescript
interface Deployment {
  pool: Address;
  chainId: number;
  rpcUrl: string;
  relayerUrl?: string;
  quickSyncUrl?: string;
  faucetUrl?: string;
  tokens: {
    zkUSD: Address;
    zkEUR: Address;
    zkPLN: Address;
  };
}

Utility Types

Address

Ethereum address (from viem).

typescript
type Address = `0x${string}`;

Hash

Transaction hash (from viem).

typescript
type Hash = `0x${string}`;

ECPoint

Elliptic curve point (from @zkprivacy/core).

typescript
interface ECPoint {
  x: bigint;
  y: bigint;
}

Released under the MIT License.