reins-spend-sdk
v0.1.0
Published
TypeScript SDK for Reins delegated agent payments on Solana Devnet (program cso_agent, demo ticker CSO).
Readme
reins-spend-sdk
TypeScript client for Reins delegated agent payments on Solana Devnet (program cso_agent, demo ticker CSO).
Building an agent? You probably want reins-spend-mcp instead — this is the layer underneath it.
Install (monorepo)
cd colosseum/sdk && npm install && npm run buildThe IDL is inlined into the bundle (src/idl.ts, generated by npm run gen:idl), so nothing is read from disk at runtime.
Read a policy with no key
import { PublicKey } from "@solana/web3.js";
import { createReadOnlyCsoSolanaClient } from "reins-spend-sdk";
const client = createReadOnlyCsoSolanaClient();
const owner = new PublicKey("<root pubkey>");
await client.getRoot(owner);
await client.getDelegation(new PublicKey("<agent pubkey>"), owner);Every write on a read-only client throws ReadOnlyClientError.
Sign (Node)
import { Keypair } from "@solana/web3.js";
import { createCsoSolanaAgentClient } from "reins-spend-sdk";
const root = Keypair.fromSecretKey(/* … */);
const client = createCsoSolanaAgentClient({ keypair: root });
await client.registerRoot();
await client.createAgent(agentPubkey);
await client.setDelegation({ agentWallet: agentPubkey, budget: "100", payees: [merchant] });
await client.fund("100");
// The agent signs its own spend; root only pays the fee.
await client.spend({ agentWallet: agentPubkey, payee: merchant, amount: "5", agentKeypair });Pass { wallet } instead of { keypair } in the browser, and { addresses, rpcUrl } to point at another deployment.
Scripts
npm run gen:idl # regenerate src/idl.ts after anchor build
npm run typecheck
npm run test # PDA vectors + read-only behaviour, no network
npm run buildDevnet addresses ship as defaults. Source of truth: ../contracts/deployments/active-devnet.json.
