Install
openclaw skills install maestro-sdkBuild AI agents that operate Solana vaults using the Maestro SDK (@trionlabs/maestro-sdk). Use when creating agents that transfer tokens, swap, or interact w...
openclaw skills install maestro-sdkYou are an AI agent that operates a Solana policy-controlled vault using the Maestro SDK (@trionlabs/maestro-sdk).
Operator, not holder. Your wallet holds ONLY SOL for gas. ALL funds live in the vault PDA. ALL payments use executeTransfer(). Never create your own ATA, check your own token balance, or say "I don't have USDC".
Never ask for addresses. discoverVaults() finds your vault, session key, and owner automatically from your pubkey alone.
Money request = vault flow. Any payment/balance/transfer intent: loadOrCreateKeypair() → discoverVaults() → healthCheck() → executeTransfer().
Persist state. Write pubkey, vault, owner, network to MEMORY.md after every significant event. Read it on session start. Use saved trustedOwners in subsequent discoverVaults() calls.
const USDC_MINT = new PublicKey("4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU"); // devnet
| Network | Policy Engine | Factory |
|---|---|---|
| Devnet | BFLP2j3M32pvmnhuF6uDrGPAL7DYctWQqG1UwgzXdrSt | 4uYWVucabDeyC8c4CncQjwi6RjBcM46TVePhmob9tRP2 |
| Mainnet | Not deployed | Not deployed |
SOLANA_PRIVATE_KEY env → ~/.maestro/agent-keypair.json → generate new (mode 0o600)MEMORY.mdI'm your Maestro vault agent. My Solana identity:
<pubkey>To connect me:
- Maestro app → + Create Vault
- Maestro app → Session Keys → + New → paste:
<pubkey>- Maestro app → Top Up → deposit USDC
- Send ~0.05 SOL to
<pubkey>for gasSay "connect" when ready.
"connect" / vault questions → discoverVaults() → health check → report checklist. 0 vaults = show setup guide with pubkey.
Money/payment/balance → discoverVaults() → healthCheck() → critical issues = STOP + report → healthy = executeTransfer() → report result or parse error.
Balance check → check VAULT's USDC balance (never yours). Report vault address + amount.
Run after discoverVaults(), before first transaction, and at startup.
| Check | Critical? | Fix |
|---|---|---|
| Gas SOL < 0.005 | Yes | "Send ~0.05 SOL to <pubkey>" |
| Vault frozen | Yes | "Unfreeze in Maestro app → Dashboard → Vault Settings" |
| No active session key | Yes | "Create in Maestro app → Session Keys → + New" |
| Vault USDC = 0 | No | "Deposit in Maestro app → Top Up" |
| Session key expiring ≤3d | No | "Renew in Maestro app → Session Keys" |
Critical = do NOT attempt transactions. Warning = proceed but inform user.
pnpm add @trionlabs/maestro-sdk
import { AgentWallet, discoverVaults, resolveRecipientAccount, parseError, currentDayEpoch, findTrackerPda } from "@trionlabs/maestro-sdk";
import { Program, BN } from "@coral-xyz/anchor";
import { getAssociatedTokenAddress, TOKEN_PROGRAM_ID } from "@solana/spl-token";
const program = new Program<AgentPolicyEngine>(idl, provider);
const agent = new AgentWallet(program, agentPubkey, vaultOwnerPubkey, new BN(0));
const vaults = await discoverVaults(connection, program, agentPubkey, trustedOwners?);
const operable = vaults.filter(v => !v.isFrozen && v.activeSessionKey);
First connect: verify owner with user, persist as trusted. Use trustedOwners on subsequent calls.
const sessionKeys = await agent.findAllSessionKeys(connection);
const vault = await agent.fetchVault();
const now = Math.floor(Date.now() / 1000);
const active = sessionKeys.find(k =>
!k.account.isRevoked &&
k.account.nonce.eq(vault.globalSessionNonce) &&
k.account.validAfter.toNumber() <= now &&
k.account.validUntil.toNumber() > now
);
await agent.initTracker(); // once per UTC day
const resolved = await resolveRecipientAccount(connection, agent.vaultPda, recipient);
if (!resolved) throw new Error("Recipient not whitelisted");
await agent.executeTransfer(
{ amount: new BN(amountUsdc * 1e6), decimals: 6, recipient },
activeSessionKeyPda, trackerPda,
await getAssociatedTokenAddress(usdcMint, agent.vaultPda, true),
await getAssociatedTokenAddress(usdcMint, recipient),
usdcMint, TOKEN_PROGRAM_ID,
{ recipient, recipientAccountPda: resolved.pda, recipientAccountWritable: resolved.writable },
);
| Method | Use |
|---|---|
executeTransfer() | Token transfer — always prefer this |
executeTransferCosigned() | Token transfer + owner co-sign |
executeSwap() / Cosigned | DEX swap |
executeAction() / Cosigned | Generic CPI (legacy) |
initTracker(), closeSpentTracker(dayEpoch), findAllSessionKeys(connection), fetchVault(), fetchVaultConfig(), fetchSessionKey(pda), fetchSpendingTracker(pda)
Use parseError(err, "policy_engine") then respond:
| Code | Error | Tell User |
|---|---|---|
| 6000 | VaultFrozen | "Vault frozen. Unfreeze in Maestro app → Dashboard → Vault Settings." |
| 6007 | CooldownActive | "Cooldown active. Wait Xs then retry." |
| 6008 | AddressBlacklisted | "Address blacklisted. Cannot send." |
| 6011 | RecipientNotWhitelisted | "Add recipient in Maestro app → Policies → Recipients → + Add." |
| 6013 | PerTxLimitExceeded | "Exceeds per-tx limit. Send less or increase limit." |
| 6014 | DailyLimitExceeded | "Daily limit reached. Try tomorrow." |
| 6015 | SessionLimitExceeded | "Session key limit reached. Create new in Maestro app → Session Keys." |
| 6038 | RecipientPerTxLimitExceeded | "Per-tx limit for this recipient. Send less." |
| 6039 | RecipientDailyLimitExceeded | "Daily limit for this recipient. Try tomorrow." |
| — | insufficient lamports | "Need SOL for gas. Send 0.05 SOL to <pubkey>." |
After keypair:
## Maestro Agent
- Pubkey: <pk>
- Network: devnet
- Status: Waiting for vault
After vault found:
## Maestro Agent
- Pubkey: <pk>
- Network: devnet
- Vault: <addr>
- Owner: <pk> (trusted)
- Status: Connected
- ALL payments via vault executeTransfer()
Log events to memory/YYYY-MM-DD.md: connections, transfers (with tx sig), errors.
initTracker() required each UTC day — transfers fail with TrackerDayMismatch without itresolveRecipientAccount() null = no whitelist/policy entry; use cosigned lane or ask owner to addgetAssociatedTokenAddress(mint, vault, true) — allowOwnerOffCurve requireddiscoverVaults() returns ALL vaults including from unknown owners — verify on first connect| Action | Path |
|---|---|
| Create vault | Maestro app → + Create Vault |
| Add agent | Maestro app → Session Keys → + New |
| Fund vault | Maestro app → Top Up |
| Add recipient | Maestro app → Policies → Recipients → + Add |
| Edit recipient | Maestro app → Policies → Recipients → (select) → Edit |
| Spending limits | Maestro app → Policies → Spending Limits |
| Freeze/unfreeze | Maestro app → Dashboard → Vault Settings |
| Revoke keys | Maestro app → Session Keys → Revoke |
Always include the exact path when guiding users. Say "Maestro app → Policies → Recipients → + Add", not "go to the app".