Account Plugin
Status: Stable – available on Solana mainnet and devnet.
Import identifier in policy expressions:
@AccountPlugin.*
The Account Plugin lets Tarobase policies deterministically create Program‑Derived Accounts (PDAs) that act as secure vaults / escrows under the control of your Tarobase on‑chain program.
Once created, those accounts can hold SOL or SPL tokens and be referenced in other plugin calls (e.g. @TokenPlugin.transfer
).
Only one transactional function is exposed, keeping the API simple and safe.
Transactional functions
createAccount
@AccountPlugin.createAccount(accountId)
Creates (and allocates rent‑exempt lamports for) a new PDA derived from:
seed = [ "ACCOUNT", accountId ]
program_id = Tarobase on-chain program
accountId
– a unique string in your application namespace (often a path variable such as$agentId
or$lobbyId
).- The resulting PDA never changes and cannot sign; your program signs for it automatically inside Tarobase hooks.
- The function reverts if the PDA already exists.
Tip: store
accountId
in the parent document; you don’t need an extra field for the resulting address – just derive it when you need it with the sameaccountId
.
Quick‑start examples
1. Agent escrow vault
"agents/$agentId": {
"rules": { "create": "@user.address == @constants.ADMIN_ADDRESS" },
"hooks": {
"onchain": {
"create": "@AccountPlugin.createAccount($agentId) && @TokenPlugin.transfer(@user.address, $agentId, @TokenPlugin.SOL, 2_000_000_000)" // seed vault with 2 SOL
}
}
}
Creates a PDA escrow for each agent and immediately seeds it with SOL.
2. Game lobby pooled pot
"lobbies/$lobbyId": {
"hooks": { "onchain": { "create": "@AccountPlugin.createAccount($lobbyId)" } }
}
"lobbies/$lobbyId/members/$playerId": {
"hooks": {
"onchain": {
"create": "@TokenPlugin.transfer(@user.address, $lobbyId, @TokenPlugin.SOL, @constants.BUY_IN_LAMPORTS)"
}
}
}
Every lobby gets its own escrow PDA identified by $lobbyId
; members deposit directly into it.
Best practices
- One
accountId
= one PDA – avoid reusing IDs across unrelated contexts. - Use path parameters (
$agentId
,$lobbyId
, etc.) to guarantee uniqueness without extra fields. - Perform
createAccount
once (usually in the parent document’screate
hook). Subsequent calls will revert. - Treat the PDA as immutable; there is no "deleteAccount". Close the account manually with a custom program upgrade if absolutely required.
- Keep large SOL balances minimal; prefer holding value in tokens unless SOL is specifically needed for gas refunds.