SDK Reference
Client Setup
Creating and configuring SapClient and SapConnection for different environments. SDK v0.20.0 aligned.
Client Setup
SDK Version: v0.20.0
The SDK provides two main entry points: SapClient for direct Anchor provider usage and SapConnection for environment-based configuration.
SapClient
SapClient is the root object from which all modules and registries are accessed. It requires an AnchorProvider or an existing Anchor Program.
From Provider
import { SapClient } from "@oobe-protocol-labs/synapse-sap-sdk";
import { AnchorProvider } from "@coral-xyz/anchor";
// AnchorProvider.env() reads ANCHOR_PROVIDER_URL and ANCHOR_WALLET
// from process environment. Default commitment: "confirmed".
const client = SapClient.from(AnchorProvider.env());From Program
const client = SapClient.fromProgram(myAnchorProgram);Properties
| Property | Type | Description |
|---|---|---|
program | Program | Underlying Anchor program |
walletPubkey | PublicKey | Provider wallet (default authority and payer) |
SapConnection
SapConnection wraps Solana Connection with cluster-aware configuration and factory methods.
Factory Methods
| Method | Endpoint | Use Case |
|---|---|---|
SapConnection.devnet() | api.devnet.solana.com | Testing |
SapConnection.mainnet(rpcUrl?) | Custom or Solana default | Production |
SapConnection.localnet() | localhost:8899 | Local development |
SapConnection.fromKeypair(url, keypair) | Custom | Scripts, bots, CLIs |
Devnet
const conn = SapConnection.devnet();
const client = conn.fromKeypair(testKeypair);Mainnet with Synapse Gateway
const conn = SapConnection.mainnet("https://us-1-mainnet.oobeprotocol.ai/rpc?api_key=YOUR_KEY");
const client = conn.createClient(wallet);Custom Configuration
const conn = new SapConnection({
rpcUrl: "https://us-1-mainnet.oobeprotocol.ai/rpc?api_key=YOUR_KEY",
wsUrl: "wss://us-1-mainnet.oobeprotocol.ai/ws?api_key=YOUR_KEY",
commitment: "finalized",
cluster: "mainnet-beta",
});| Property | Type | Default | Description |
|---|---|---|---|
rpcUrl | string | Required | Solana JSON-RPC endpoint |
wsUrl | string | Auto-derived | WebSocket endpoint |
commitment | Commitment | "confirmed" | Default commitment level |
cluster | SapCluster | Auto-detected | Explicit cluster hint |
Environment-Based Setup
function createClient(env: "development" | "staging" | "production") {
const keypair = Keypair.fromSecretKey(/* load from env or vault */);
const rpcUrls: Record<string, string> = {
development: "http://localhost:8899",
staging: "https://api.devnet.solana.com",
production: "https://us-1-mainnet.oobeprotocol.ai/rpc?api_key=YOUR_KEY",
};
const { client } = SapConnection.fromKeypair(rpcUrls[env], keypair);
return client;
}Commitment Levels
| Level | Latency | Guarantee | When to Use |
|---|---|---|---|
processed | ~400 ms | Optimistic, may be rolled back | Debug only |
confirmed | ~400 ms | Supermajority voted | Reads, most writes |
finalized | ~6 to 12 s | Rooted, irreversible | Escrow, attestations, critical writes |
The SDK defaults to "confirmed" which is suitable for most operations.
Next Steps
- Quickstart — First agent registration
- Agent Builder — Fluent registration API
- Client Setup — Connection configuration
Last Updated: June 2026
SDK Version: 0.20.0