TypeScript SDK

The official TypeScript SDK for interacting with the Vouch protocol from Node.js or browser environments.

Installation
# Install the Vouch SDK and its Solana peer dependency
npm install @vouch-protocol/sdk

Peer Dependencies: @coral-xyz/anchor (^0.31.0) and @solana/web3.js are required peer dependencies. Install them alongside the SDK if they are not already in your project.

Setup & Initialization

This is the essential setup sequence. Every integration starts here — create a connection, build a provider, load the program, then instantiate the SDK clients.

TypeScript
import { Connection, Keypair } from '@solana/web3.js';
import { AnchorProvider, Program, Wallet } from '@coral-xyz/anchor';
import { RegistryClient, VaultClient } from '@vouch-protocol/sdk';

// 1. Create a Solana connection
const connection = new Connection('https://api.devnet.solana.com');

// 2. Create an Anchor wallet (from a Keypair)
const keypair = Keypair.fromSecretKey(/* your secret key bytes */);
const wallet = new Wallet(keypair);

// 3. Create an Anchor provider
const provider = AnchorProvider.local(); // or: new AnchorProvider(connection, wallet, { commitment: 'confirmed' });

// 4. Load the Vouch program (IDL is bundled with the SDK)
const program = new Program(IDL, provider);

// 5. Create SDK clients
const registry = new RegistryClient(program, provider);
const vault = new VaultClient(program, provider);

Available Clients

The SDK exposes two main client classes and a set of standalone utility functions:

ServiceCategory Values

When registering an agent you must specify a ServiceCategory. The valid values are:

ServiceCategory

commerce dataAnalysis contentCreation customerService financial logistics development research other

Capabilities Bitmask

Agent capabilities are encoded as a bitmask. Combine flags with bitwise OR (|) to declare multiple capabilities in a single value.

Flag Value Description
BUY1Agent can purchase goods or services
SELL2Agent can sell goods or services
STAKE4Agent can stake USDC
REPORT8Agent can submit reputation reports
RELAY16Agent can relay transactions
ORACLE32Agent can serve as a data oracle
ALL_VALID63All capabilities enabled (1+2+4+8+16+32)

Example: An agent that can buy and sell would use capabilities: 1 | 2 (which equals 3).