| Layer | Package | Best for |
|---|---|---|
| Protocol SDK | @loyal-labs/loyal-smart-accounts | Building raw Squads instructions, prepared operations, and low-level account queries |
| Vault adapter | @loyal-labs/smart-account-vaults | App UI flows for vaults, proposals, policy signers, and spending-limit actions |
Protocol SDK Shape
@loyal-labs/loyal-smart-accounts exports feature namespaces:
programConfigsmartAccountsproposalstransactionsbatchespoliciesspendingLimitsexecution
generatedPROGRAM_IDpdacodecserrorsaccounts
| API | What it does |
|---|---|
accounts | Generated account classes |
instructions | Raw instruction builders for exposed offline operations |
prepare | Prepared-operation builders |
queries | Account fetch helpers |
| client methods | Prepare, sign, send, and optionally confirm through the configured transport |
Vault Adapter Shape
@loyal-labs/smart-account-vaults wraps the protocol SDK for app-facing vault flows.
Read APIs:
fetchVaultlistVaultslistSpendingLimitPolicieslistSpendingLimitslistProposalsfetchOverview
prepareSolTransferProposalprepareSplTransferProposalprepareCustomInstructionProposalpreparePolicyCustomInstructionProposalprepareAddInitiateSignerprepareRemoveInitiateSignerprepareSetSpendingLimitPolicyprepareRemoveSpendingLimitPolicyprepareUseSolSpendingLimitPolicyprepareApproveProposalprepareRejectProposalprepareExecuteProposalprepareExecuteSettingsProposalprepareExecutePolicyProposal
sendPreparedWithWalletisWalletAdapterLike
Frontend Read Flow
The Loyal frontend uses server routes for the heavy read model:- Resolve the authenticated user session.
- Load the user’s
settingsPda. - Create a vault adapter client with the configured Solana RPC, smart-account program id, and wallet data client.
- Return
SmartAccountOverviewto the browser. - Load vault activity separately when a vault is opened.
SmartAccountOverview includes:
- program id
- settings PDA
- canonical vault address
- root signers
- policy signers
- spending-limit policies
- vault portfolio snapshots
- proposal snapshots
Frontend Write Flow
Browser actions prepare an operation with the vault adapter, then send it with the connected wallet.| Proposal payload | Helper |
|---|---|
transaction | prepareExecuteProposal |
settings_transaction | prepareExecuteSettingsProposal |
policy_transaction | prepareExecutePolicyProposal |
Agent Connection Flow
The Loyal agent CLI starts with:?connect=<agent_public_key>. The frontend asks the user to approve the connection and then adds the CLI key as an Initiate signer on a spending-limit policy.
After approval, the CLI watches or scans Squads policy accounts until it finds a policy where:
- the policy belongs to the user’s settings account
- the CLI public key is in
Policy.signers[] - the signer has
Initiatepermission
Spending Limit Behavior
For new user-facing flows, preferSpendingLimitPolicy over legacy spending-limit accounts.
When editing an existing spending-limit policy, Loyal updates the policy with PolicyUpdate. The update is built from the fetched existing policy so unchanged fields stay unchanged. That protects mint, destinations, period, expiration, accumulation, exact-quantity behavior, usage state, threshold, and time lock.
Top-ups use synchronous policy payload execution for SOL spending-limit policies. The connected wallet only needs to be a valid signer on that policy; it does not need to be the root authenticated settings signer.
Logs And Diagnostics
The frontend extracts Solana logs from wallet errors when spending-limit sends fail and turns common failures into actionable messages:- vault SOL is insufficient for a top-up
- fee payer SOL is insufficient for rent or fees
- the top-up exceeds the remaining spending limit
- a policy update failed during account reallocation

