zkLabs Documentation
Comprehensive guides and API references for zkBound, zkTrading Vaults, and zkNFT Trait Reveal
zkBound enables developers to execute smart contract actions only when private conditions are proven true, without revealing the underlying data. Built on Solana for high-performance zero-knowledge proof verification.
Private Conditions
Keep sensitive data completely hidden
Fast Verification
Optimized for Solana's speed
Composable
Integrate with any Solana program
NPM
npm install @zklabs/zkboundYarn
yarn add @zklabs/zkbound1. Bound Actions
A bound action is an on-chain transaction that only executes when a zero-knowledge proof validates the specified conditions.
import { createBoundAction } from "@zklabs/zkbound";
const boundAction = await createBoundAction({
condition: zkGreaterThan(userBalance, 1000),
action: transferTokens(recipient, amount),
expiry: 3600, // seconds
});2. ZK Conditions
Conditions define when an action should execute. They can check balances, ownership, timestamps, or custom logic.
// Available condition operators
zkGreaterThan(value, threshold)
zkLessThan(value, threshold)
zkEquals(value, target)
zkBetween(value, min, max)
zkOwns(nftMint)
zkAnd(condition1, condition2)
zkOr(condition1, condition2)3. Proof Generation
Generate a zero-knowledge proof to verify conditions without revealing private data.
import { generateProof } from "@zklabs/zkbound";
const proof = await generateProof({
condition: boundAction.condition,
privateData: { balance: 5000 }, // Never revealed
publicInputs: { timestamp: Date.now() },
});4. Action Execution
Submit the proof to execute the bound action on-chain.
import { executeAction } from "@zklabs/zkbound";
const txSignature = await executeAction({
boundAction,
proof,
wallet: userWallet,
});
console.log("Action executed:", txSignature);Private DeFi Automation
Automate stop-loss orders, position management, and yield optimization without revealing your strategy or portfolio holdings.
// Auto stop-loss when price drops below threshold
createBoundAction({
condition: zkLessThan(tokenPrice, stopLossPrice),
action: sellTokens(amount),
});Private Access Control
Grant access based on private credentials without exposing user data or wallet contents.
// Verify membership without revealing identity
createBoundAction({
condition: zkOwns(membershipNFT),
action: grantAccess(resource),
});Institutional Compliance
Meet regulatory requirements with private proof of compliance while maintaining user privacy.
// KYC verification without data exposure
createBoundAction({
condition: zkAnd(zkEquals(kycStatus, "verified"), zkGreaterThan(age, 18)),
action: allowTrading(account),
});createBoundAction()
Creates a new conditional action on-chain
interface BoundActionParams {
condition: ZKCondition;
action: SolanaInstruction;
expiry?: number; // seconds
maxExecutions?: number;
}
async function createBoundAction(
params: BoundActionParams
): Promise<BoundAction>generateProof()
Generates zero-knowledge proof for conditions
interface ProofParams {
condition: ZKCondition;
privateData: Record<string, any>;
publicInputs?: Record<string, any>;
}
async function generateProof(
params: ProofParams
): Promise<ZKProof>executeAction()
Executes bound action with valid proof
interface ExecuteParams {
boundAction: BoundAction;
proof: ZKProof;
wallet: WalletAdapter;
}
async function executeAction(
params: ExecuteParams
): Promise<string> // Transaction signature