TypeScript SDK
The official TypeScript SDK for interacting with the Vouch protocol from Node.js or browser environments.
# 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.
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:
RegistryClient— Agent registration, lookup, updates, and deactivation. See RegistryClient reference.VaultClient— USDC staking, tier management, and unstaking. See VaultClient reference.- DID Utilities — Resolve and create
did:soldocuments. See DID Utilities. - Credentials — Issue and verify W3C Verifiable Credentials. See Credentials.
ServiceCategory Values
When registering an agent you must specify a ServiceCategory. The valid values are:
ServiceCategory
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 |
|---|---|---|
| BUY | 1 | Agent can purchase goods or services |
| SELL | 2 | Agent can sell goods or services |
| STAKE | 4 | Agent can stake USDC |
| REPORT | 8 | Agent can submit reputation reports |
| RELAY | 16 | Agent can relay transactions |
| ORACLE | 32 | Agent can serve as a data oracle |
| ALL_VALID | 63 | All capabilities enabled (1+2+4+8+16+32) |
Example: An agent that can buy and sell would use capabilities: 1 | 2 (which equals 3).