Self-Custodial Model
Circuit never takes custody of user funds. Private keys live in a secure enclave (KMS) completely separate from agent code. Agents can only request transactions - signing happens outside the agent sandbox. Agent code never sees private keys, users can export their wallet at any time, and all transactions are visible onchain.Wallet VM Families
Agents declare their required wallet VM family incircuit.toml:
"evm"- EVM-compatible networks (Ethereum, Polygon, Arbitrum, Base, Hyperliquid, etc.)"svm"- SVM-compatible networks (currently Solana)
walletVmFamily.
Starting Asset
Every agent defines astartingAsset in circuit.toml - the token a user must hold to start a session:
network- The chain where the asset lives (Network Identifiers)address- Token contract address. For native tokens:"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"(EVM) or"11111111111111111111111111111111"(Solana)minimumAmount- Minimum balance required in raw units (wei, lamports, etc.). Hyperliquidhypercore:perp+USDCuses 8 decimal places in Circuit (not EVM USDC’s 6); see Hyperliquid.
How Allocation Works
When a user starts a session:- The user chooses an exact starting-asset quantity (
minimumAmountis the agent’s recommended minimum) - Circuit requires that quantity to exist in recorded wallet money after other unreleased session allocations, then appends the session allocation in the start transaction
- Each claimed invocation builds
agent.allocationfrom that session’s allocation and recorded transaction/venue events
Positions
The invocation allocation contains:allocation.balances- fungible inventory the session holds outright: cash, spot tokens, staking, Polymarket pUSD cash, and Kraken’s synthetic available cash plus base-asset inventory.allocation.positions- open market exposures: Hyperliquid perps (signed sizes) and Polymarket outcome-token positions (enriched withpolymarketMetadata). Tell them apart by whetherpolymarketMetadatais present.
agent.allocation.balances entry carrying hyperliquidMetadata.collateral, and its open perps are in agent.allocation.positions (with leverage / liquidation price / margin used under hyperliquidMetadata). The cash amount includes locked margin and excludes unrealized PnL; session collateral = cash + Σ positions’ unrealizedPnlUsd, and free margin ≈ session collateral − Σ marginUsed. Size from the allocation - never a whole-wallet read, which on a shared wallet would overspend the other sessions sharing it. See Hyperliquid.
Kraken note: Match a base-inventory balance by tokenAddress and size sells from its exact krakenMetadata.availableBaseVolume. The same fungible base inventory backs either supported quote pair. The credential-wide balance includes other sessions and is never ownership authority. No matching allocation entry means zero inventory for that base. See Kraken.
Units
- Onchain transaction, swap, and allocation amounts are strings in smallest units (wei/token base units for EVM, lamports for Solana). Keep them as strings to preserve precision.
- Never size an amount through float math (
parseFloat,Math.round(usd * 1e6),Number(amountRaw) / 10 ** decimals). Use the SDK’s exact converter pair —decimalToBaseUnits(decimal, decimals)/baseUnitsToDecimal(raw, decimals)(decimal_to_base_units/base_units_to_decimalin Python) — andbigint/intarithmetic on raw units. Spend-all is the allocation entry’samountRaw, verbatim. - The engine rejects an agent swap or transfer whose amount exceeds the session’s attributed inventory for that asset, so sizing from anything other than
agent.allocationfails at admission. - Hyperliquid order sizes and prices are formatted numbers; its allocation fields remain raw string amounts.
- Kraken amounts are decimal strings in venue units. Polymarket orders use unit-explicit numbers:
spendUsdfor buys andsharesfor sells.
See Also
- Positions - Read the invocation-start allocation snapshot
- Hyperliquid - Platform-specific balance methods
- circuit.toml Reference - Configure
startingAssetandwalletVmFamily