API Reference
Complete reference documentation for all Zeris SDK methods and types.
ZerisClient
Main client for interacting with the Zeris protocol.
Constructor
typescript
new ZerisClient(config?: ZerisConfig)Parameters
config(optional) - Configuration objectrpcEndpoint: string - Solana RPC endpointprogramId: PublicKey - Zeris program IDcommitment: Commitment - Transaction commitment level
generatePoWProof()
Generates a Proof-of-Work proof for transaction data.
typescript
async generatePoWProof(
data: Buffer,
config?: PoWConfig
): Promise<PoWProof>Parameters
data: Buffer - Transaction data to generate proof forconfig(optional): PoWConfig - PoW configuration
Returns
Promise<PoWProof> - Generated proof containing nonce, hash, and metadata
Example
typescript
const proof = await client.generatePoWProof(
Buffer.from('transaction data'),
{ difficulty: 20 }
);anchorToPoH()
Anchors transaction to Proof-of-History chain.
typescript
async anchorToPoH(
data: Buffer,
powProof: PoWProof
): Promise<PoHAnchor>collectValidatorSignatures()
Collects Proof-of-Stake validator signatures for finality.
typescript
async collectValidatorSignatures(
data: Buffer,
minValidators: number,
timeout?: number
): Promise<ValidatorSignature[]>generateTripleProof()
Convenience method to generate all three proofs in one call.
typescript
async generateTripleProof(
data: Buffer,
config?: TripleProofConfig
): Promise<ProofBundle>createVerifyInstruction()
Creates Solana instruction for onchain verification.
typescript
createVerifyInstruction(
payer: PublicKey,
data: Buffer,
proofBundle: ProofBundle
): TransactionInstructionTypes
PoWProof
typescript
interface PoWProof {
nonce: bigint; // Solution nonce
hash: Buffer; // Resulting hash
difficulty: number; // Difficulty level used
timestamp: number; // Generation timestamp
generationTimeMs: number; // Time taken to generate
}PoHAnchor
typescript
interface PoHAnchor {
pohHash: Buffer; // PoH chain hash
tickCount: bigint; // PoH tick number
merkleRoot: Buffer; // Merkle tree root
merkleProof: Buffer[]; // Merkle inclusion proof
txIndex: number; // Transaction index in tree
timestamp: number; // Anchor timestamp
}ValidatorSignature
typescript
interface ValidatorSignature {
pubkey: PublicKey; // Validator public key
signature: Buffer; // Ed25519 signature
weight: number; // Validator stake weight
timestamp: number; // Signature timestamp
}ProofBundle
typescript
interface ProofBundle {
powProof: PoWProof; // PoW proof
pohAnchor: PoHAnchor; // PoH anchor
posSignatures: ValidatorSignature[]; // PoS signatures
}PoWConfig
typescript
interface PoWConfig {
difficulty?: number; // Default: 20
workerThreads?: number; // Default: 4
timeoutMs?: number; // Default: 30000
onProgress?: (percent: number) => void;
}Validation Functions
validatePoW()
typescript
function validatePoW(
proof: PoWProof,
data: Buffer,
requiredDifficulty: number
): booleanvalidatePoH()
typescript
function validatePoH(
anchor: PoHAnchor,
txHash: Buffer
): booleanvalidatePoS()
typescript
function validatePoS(
signatures: ValidatorSignature[],
txHash: Buffer,
threshold: number // Default: 0.67
): booleanUtility Functions
calculateDifficulty()
typescript
function calculateDifficulty(
baselineLatency: number,
targetLatency: number
): numberserializeProofBundle()
typescript
function serializeProofBundle(
bundle: ProofBundle
): BufferdeserializeProofBundle()
typescript
function deserializeProofBundle(
data: Buffer
): ProofBundleError Types
typescript
class PoWError extends Error {
code: 'TIMEOUT' | 'INVALID_DIFFICULTY' | 'GENERATION_FAILED';
}
class PoHError extends Error {
code: 'ANCHOR_FAILED' | 'INVALID_PROOF' | 'CHAIN_MISMATCH';
}
class PoSError extends Error {
code: 'INSUFFICIENT_SIGNATURES' | 'INVALID_SIGNATURE' | 'TIMEOUT';
}
class ZerisError extends Error {
code: 'INITIALIZATION_FAILED' | 'RPC_ERROR' | 'UNKNOWN';
}Constants
typescript
export const ZERIS_PROGRAM_ID = new PublicKey(
'ZER1sPr0gr4m11111111111111111111111111111111'
);
export const DEFAULT_POW_DIFFICULTY = 20;
export const MIN_POW_DIFFICULTY = 16;
export const MAX_POW_DIFFICULTY = 32;
export const DEFAULT_POS_THRESHOLD = 0.67;
export const MIN_VALIDATOR_SIGNATURES = 7;
export const DEFAULT_TIMEOUT_MS = 30000;