AURA

Validation

Client-side input validation helpers — check arguments before sending transactions.

Pre-alpha — not production ready

@aura-protocol/sdk-ts targets Solana devnet only. APIs may change without notice. Do not use for real funds until a stable release and audit are published.

The SDK exports a set of lightweight validators that mirror the on-chain program's argument checks. Run them before building instructions to surface errors early without spending SOL on failed preflight transactions.

import {
  validateAgentId,
  validateDwalletId,
  validateAddress,
  validateAmountUsd,
  validateMultisigThreshold,
  validateGuardians,
  validateSwarmMembers,
  MAX_AGENT_ID_LEN,
  MAX_DWALLET_ID_LEN,
  MAX_ADDRESS_LEN,
  MAX_GUARDIANS,
  MAX_SWARM_MEMBERS,
} from '@aura-protocol/sdk-ts';

Constants

ConstantValueDescription
MAX_AGENT_ID_LEN64Maximum UTF-8 byte length of an agent ID
MAX_DWALLET_ID_LEN64Maximum UTF-8 byte length of a dWallet ID
MAX_ADDRESS_LEN128Maximum UTF-8 byte length of a chain address
MAX_GUARDIANS10Maximum number of guardians in a multisig
MAX_SWARM_MEMBERS16Maximum number of agents in a swarm

Validators

validateAgentId

Throws if agentId is empty or exceeds MAX_AGENT_ID_LEN bytes.

function validateAgentId(agentId: string): void
validateAgentId('agent-prod-1'); // ok
validateAgentId('');             // throws: "agentId must not be empty"

validateDwalletId

Throws if dwalletId is empty or exceeds MAX_DWALLET_ID_LEN bytes.

function validateDwalletId(dwalletId: string): void

validateAddress

Throws if address is empty or exceeds MAX_ADDRESS_LEN bytes.

function validateAddress(address: string): void
validateAddress('0xdeadbeef...'); // ok
validateAddress('');              // throws: "address must not be empty"

validateAmountUsd

Throws if amountUsd is zero or negative.

function validateAmountUsd(amountUsd: number | bigint): void
validateAmountUsd(250);  // ok
validateAmountUsd(0);    // throws: "amountUsd must be greater than zero"

validateMultisigThreshold

Throws if threshold is zero or exceeds guardianCount.

function validateMultisigThreshold(threshold: number, guardianCount: number): void
validateMultisigThreshold(2, 3); // ok — 2-of-3 multisig
validateMultisigThreshold(4, 3); // throws: threshold (4) must not exceed guardian count (3)
validateMultisigThreshold(0, 3); // throws: threshold must be greater than zero

validateGuardians

Throws if the guardian list is empty or exceeds MAX_GUARDIANS.

function validateGuardians(guardians: unknown[]): void
validateGuardians([g1, g2, g3]); // ok
validateGuardians([]);           // throws: "guardians list must not be empty"

validateSwarmMembers

Throws if the swarm member list is empty or exceeds MAX_SWARM_MEMBERS.

function validateSwarmMembers(members: unknown[]): void

Usage Pattern

Validate arguments before building instructions to fail fast and clearly:

import {
  AuraClient,
  validateAgentId,
  validateAmountUsd,
  validateGuardians,
  validateMultisigThreshold,
} from '@aura-protocol/sdk-ts';
import BN from 'bn.js';

const agentId = 'agent-prod-1';
const amountUsd = 250;
const guardians = [g1.publicKey, g2.publicKey, g3.publicKey];
const threshold = 2;

// Validate before any async RPC work
validateAgentId(agentId);
validateAmountUsd(amountUsd);
validateGuardians(guardians);
validateMultisigThreshold(threshold, guardians.length);

// Now safe to build instructions
const client = new AuraClient({ connection });
const now = new BN(Math.floor(Date.now() / 1000));

await client.configureMultisig(
  owner,
  { owner: owner.publicKey, treasury },
  { requiredSignatures: threshold, guardians, timestamp: now },
);

Simulation-Based Validation

For final confirmation before sending, simulate the transaction to surface any on-chain policy failures:

import { Transaction } from '@solana/web3.js';
import BN from 'bn.js';

const now = new BN(Math.floor(Date.now() / 1000));

const instruction = await client.proposeTransactionInstruction(
  { aiAuthority: aiAuthority.publicKey, treasury },
  {
    amountUsd: new BN(250),
    targetChain: 2,
    txType: 0,
    protocolId: null,
    currentTimestamp: now,
    expectedOutputUsd: null,
    actualOutputUsd: null,
    quoteAgeSecs: null,
    counterpartyRiskScore: 15,
    recipientOrContract: '0xdeadbeef...',
    sanctionsProof: [],
  },
);

const tx = new Transaction().add(instruction);
tx.feePayer = aiAuthority.publicKey;
const { blockhash } = await client.connection.getLatestBlockhash();
tx.recentBlockhash = blockhash;

const sim = await client.connection.simulateTransaction(tx);
if (sim.value.err) {
  throw new Error(`Simulation failed: ${JSON.stringify(sim.value.logs)}`);
}

return client.sendInstructions(aiAuthority, [instruction]);

On this page