Two paths. Pick the one that’s you. Drop the snippet in. Done.
React + any Solana wallet adapter. Works the same on mainnet and devnet.
pnpm add @telaro/react-presignWraps the user's existing approve button. Shows the agent's Trust Card before any wallet sign request.
import { usePresignGate } from "@telaro/react-presign";
function DelegateButton({ agentPubkey }: { agentPubkey: string }) {
const gate = usePresignGate({
agentPubkey,
minBond: 100_000_000n, // require ≥ $100 USDC bond
minScore: 700, // require trust score ≥ 700
delegationLabel: "Swap via Jupiter",
delegationAmount: 1_000_000_000n,
onConfirm: () => actualSwap(),
});
return (
<>
<button onClick={gate.open}>Swap</button>
{gate.ConfirmModal()}
</>
);
}Same gate, enforced by the program itself. Use this when the gate is a hard policy, not a UI nudge.
use telaro::cpi::accounts::ViewBond;
use telaro::cpi::view_bond;
use telaro::program::Telaro;
#[derive(Accounts)]
pub struct DelegateCapital<'info> {
pub agent: Account<'info, telaro::Agent>,
pub bonded_agents_program: Program<'info, Telaro>,
// ... your accounts
}
pub fn delegate(ctx: Context<DelegateCapital>, amount: u64) -> Result<()> {
// view_bond is read-only and reverts the parent tx if any of:
// - agent.frozen == true
// - agent.current_bond < min_bond
// - agent.current_score < min_score
view_bond(
CpiContext::new(
ctx.accounts.bonded_agents_program.to_account_info(),
ViewBond { agent: ctx.accounts.agent.to_account_info() },
),
100_000_000, // min_bond (atomic, USDC)
700, // min_score (0..=1000)
)?;
// ... your delegation logic - only reached if policy clears
Ok(())
}Bond directly from the wallet UI. No CLI required.
Every action your agent takes (swaps, votes, lends) gets a row in the on-chain log. Score recomputes within ~60s.
import {
TelaroClient,
ActionKind,
ActionOutcome,
hashAction,
} from "@telaro/sdk";
import { Connection, Keypair } from "@solana/web3.js";
// Devnet RPC for testing; for mainnet swap to mainnet-beta or your Helius/Triton URL.
const client = new TelaroClient(
new Connection(process.env.SOLANA_RPC ?? "https://api.devnet.solana.com"),
controllerKeypair
);
// Right after your agent finishes a swap:
await client.recordAction({
kind: ActionKind.Swap,
outcome: ActionOutcome.Success,
valueAtomic: 25_000_000n, // $25 USDC handled
payload: { tx: swapSig, tokenIn, tokenOut }, // hashed → action_hash
});If you're using Sendai / Eliza / GOAT / LangChain etc., the adapter records actions automatically. No manual recordAction calls.
// Sendai Agent Kit
import { withTelaro } from "@telaro/sendai";
const agent = withTelaro(sendaiAgent, { controller: keypair });
// ElizaOS
import { telaroPlugin } from "@telaro/eliza";
new AgentRuntime({ plugins: [telaroPlugin({ controller: keypair })] });
// LangChain
import { telaroTool } from "@telaro/langchain";
new AgentExecutor({ tools: [telaroTool({ controller: keypair })] });view_bond.