Accounts
Typed fetchers for every program account, plus the treasury input helper.
The accounts namespace decodes on-chain data into fully typed records. Every
one of the program's 32 account types has two fetchers:
import { accounts } from "@aura-protocol/sdk-ts";
// Throws if the account does not exist.
const treasury = await accounts.fetchTreasuryAccount(client, address);
// Returns null instead of throwing.
const maybe = await accounts.fetchTreasuryAccountNullable(client, address);The decoded record types are generated from the IDL (IdlAccounts<AuraCore>),
so fields like owner: PublicKey, agentId: string, and dailyLimitUsd: BN
are typed exactly as the program stores them.
Reading state
import { accounts, deriveTreasuryAddress } from "@aura-protocol/sdk-ts";
const [treasury] = deriveTreasuryAddress(owner.publicKey, "agent-prod-1");
const state = await accounts.fetchTreasuryAccount(client, treasury);
console.log(state.agentId, state.agentState, state.executionPaused);
console.log("daily limit:", state.policyConfig.dailyLimitUsd.toString());
// Sidecar accounts live at their own PDAs.
const [analytics] = pda.deriveTreasuryAnalyticsAddress(treasury);
const stats = await accounts.fetchTreasuryAnalyticsAccountNullable(client, analytics);The treasury input helper
createTreasuryInput is a convenience that derives the treasury PDA and shapes
the full create_treasury account set for you:
const { treasury, input } = accounts.createTreasuryInput({
owner: owner.publicKey,
args: createTreasuryArgs,
// treasury?: PublicKey — optional override; derived if omitted
});
await instructions.treasury.sendCreateTreasury(client, owner, input);It returns { treasury, input } where input is ready to pass straight to the
createTreasury builder.
Account → fetcher → PDA reference
Each account is fetched with fetch<Name> / fetch<Name>Nullable and its
address is derived with the linked PDA helper.
| Account | Fetcher | PDA helper |
|---|---|---|
TreasuryAccount | fetchTreasuryAccount | deriveTreasuryAddress(owner, agentId) |
TreasuryAnalyticsAccount | fetchTreasuryAnalyticsAccount | deriveTreasuryAnalyticsAddress(treasury) |
ConfidentialGuardrailsAccount | fetchConfidentialGuardrailsAccount | deriveConfidentialGuardrailsAddress(treasury) |
DWalletAccount | fetchDWalletAccount | deriveDwalletStateAddress(treasury, chain) |
ScheduledIntent | fetchScheduledIntent | deriveScheduledIntentAddress(treasury, intentId) |
ConditionalProposal | fetchConditionalProposal | deriveConditionalProposalAddress(treasury, proposalId) |
BatchProposalAccount | fetchBatchProposalAccount | deriveBatchProposalAddress(treasury, batchId) |
PolicyReceiptAccount | fetchPolicyReceiptAccount | derivePolicyReceiptAddress(treasury, proposalId) |
PolicySimulationResultAccount | fetchPolicySimulationResultAccount | derivePolicySimulationAddress(treasury, simulationId) |
PolicyAttestationAccount | fetchPolicyAttestationAccount | derivePolicyAttestationAddress(treasury, attester, policyVersion) |
PolicyHistoryAccount | fetchPolicyHistoryAccount | derivePolicyHistoryAddress(treasury) |
PolicyCanaryAccount | fetchPolicyCanaryAccount | derivePolicyCanaryAddress(treasury) |
PolicyCheckResult | fetchPolicyCheckResult | derivePolicyCheckAddress(treasury, caller) |
PolicyTemplate | fetchPolicyTemplate | derivePolicyTemplateAddress(owner, templateId) |
TrustIdentityAccount | fetchTrustIdentityAccount | deriveTrustIdentityAddress(treasury) |
InvariantReportAccount | fetchInvariantReportAccount | deriveInvariantReportAddress(treasury, reportId) |
BudgetEnvelopeAccount | fetchBudgetEnvelopeAccount | deriveBudgetEnvelopeAddress(treasury, envelopeId) |
ExposureGroupAccount | fetchExposureGroupAccount | deriveExposureGroupAddress(authority, groupId) |
OperatorRoleAccount | fetchOperatorRoleAccount | deriveOperatorRoleAddress(treasury, operator) |
SessionKeyAccount | fetchSessionKeyAccount | deriveSessionKeyAddress(treasury, sessionKey) |
ExternalLivenessAccount | fetchExternalLivenessAccount | deriveExternalLivenessAddress(treasury) |
HealthScoreAccount | fetchHealthScoreAccount | deriveHealthScoreAddress(treasury) |
SnapshotAccount | fetchSnapshotAccount | deriveSnapshotAddress(treasury, snapshotIndex) |
ActivityLogAccount | fetchActivityLogAccount | deriveActivityLogAddress(treasury) |
AddressListAccount | fetchAddressListAccount | deriveAddressListAddress(treasury) |
SwarmPoolAccount | fetchSwarmPoolAccount | deriveSwarmPoolAddress(swarmId) |
FeeVaultAccount | fetchFeeVaultAccount | deriveFeeVaultAddress(treasury) |
FeeScheduleAccount | fetchFeeScheduleAccount | deriveFeeScheduleAddress(treasury) |
BillingTemplate | fetchBillingTemplate | deriveBillingTemplateAddress(owner, templateId) |
ChainProfileAccount | fetchChainProfileAccount | deriveChainProfileAddress(chainCode) |
ProtocolConfigAccount | fetchProtocolConfigAccount | deriveProtocolConfigAddress() |
ComplianceOracleAccount | fetchComplianceOracleAccount | external oracle (address provided by integrator) |
Record types are exported too — e.g. import the AuraCore IDL type and use
IdlAccounts<AuraCore>["treasuryAccount"], or rely on the inferred return
type of each fetcher.