> ## Documentation Index
> Fetch the complete documentation index at: https://docs.circuit.org/llms.txt
> Use this file to discover all available pages before exploring further.

# SDK Quick Reference

> Network identifiers, native tokens, amounts, conventions, and all SDK methods at a glance with TypeScript and Python signatures.

### Network Identifiers

All methods use consistent network identifiers:

* **EVM networks**: `"ethereum:{chainId}"`
* **Solana**: `"solana"`
* **Hyperliquid Perps**: `"hypercore:perp"`
* **Hyperliquid Spot**: `"hypercore:spot"`

#### Supported EVM Chains

| Network ID         | Chain           |
| ------------------ | --------------- |
| `ethereum:1`       | Ethereum        |
| `ethereum:42161`   | Arbitrum        |
| `ethereum:137`     | Polygon         |
| `ethereum:10`      | Optimism        |
| `ethereum:8453`    | Base            |
| `ethereum:324`     | ZKsync Era      |
| `ethereum:7777777` | Zora            |
| `ethereum:56`      | BNB Smart Chain |
| `ethereum:43114`   | Avalanche       |
| `ethereum:480`     | World Chain     |
| `ethereum:81457`   | Blast           |
| `ethereum:42220`   | Celo            |
| `ethereum:2741`    | Abstract        |
| `ethereum:999`     | HyperEVM        |
| `ethereum:4663`    | Robinhood Chain |

***

### Native Tokens

Native tokens are handled slightly differently depending on the surface:

* **In some SDK methods** (e.g., Swap quoting/executing), you **omit** `fromToken` / `toToken` for native tokens.
* **In config and position data**, native assets are represented by a canonical "null address" per network.

#### Common Native Tokens

| Network          | Token                | Address                                                                           |
| ---------------- | -------------------- | --------------------------------------------------------------------------------- |
| `ethereum:1`     | ETH                  | `0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee`                                      |
| `ethereum:10`    | ETH                  | `0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee`                                      |
| `ethereum:56`    | BNB                  | `0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee`                                      |
| `ethereum:137`   | POL (formerly MATIC) | `0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee`                                      |
| `ethereum:8453`  | ETH                  | `0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee`                                      |
| `ethereum:42161` | ETH                  | `0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee`                                      |
| `ethereum:43114` | AVAX                 | `0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee`                                      |
| `solana`         | SOL                  | `11111111111111111111111111111111`                                                |
| `hypercore:perp` | USDC (Perps)         | `USDC` (startingAsset) / `0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee` (positions) |

**Note:** EVM native tokens use the EIP-7528 canonical address (`0xeeee...eeee`). Allocation balances use these addresses. Some SDK methods (e.g., swap quoting) let you omit the token address for native tokens instead.

***

### Amounts and Units

* Amounts are typically **strings** and in the **smallest unit** for the given network
  * wei (EVM), lamports (Solana), etc.
  * **Hyperliquid Exception**: When placing orders or fetching data from Hyperliquid's API, amounts will be formatted (e.g. \$1.5 USDC would be "1.5"). You will also need to consider Hyperliquid's restrictions on [tick and lot sizing](https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/tick-and-lot-size) when placing orders.
* Keep them as strings to preserve precision for large values.

***

### Agent Context Properties

| Property (TS)          | Property (Python)        | Type                                         | Description                                                                                                                                                                                                             |
| ---------------------- | ------------------------ | -------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `sessionId`            | `session_id`             | number                                       | Unique session identifier                                                                                                                                                                                               |
| `sessionWalletAddress` | `session_wallet_address` | string                                       | Wallet address for this session                                                                                                                                                                                         |
| `executionMode`        | `execution_mode`         | string                                       | `"auto"` or `"manual"`                                                                                                                                                                                                  |
| `settings`             | `settings`               | Record\<string, string \| boolean \| number> | Resolved [settings](./settings) (defaults + overrides). All settings are guaranteed present at runtime - optional settings fall back to their default, and required settings block execution until a value is provided. |

### Core Methods

| Method (TS)                    | Method (Python)                          | Description                                                                      |
| ------------------------------ | ---------------------------------------- | -------------------------------------------------------------------------------- |
| `log(message, options?)`       | `log(message, error=False, debug=False)` | Send log messages. `error: true` for error logs, `debug: true` for console-only. |
| `transactions()`               | `transactions()`                         | Get transaction history for the session                                          |
| `clearSuggestedTransactions()` | `clear_suggested_transactions()`         | Clear pending manual mode suggestions                                            |
| `allocation`                   | `allocation`                             | Invocation-start virtual allocation field                                        |

### Memory

All memory methods default to session scope. Pass `{ shared: true }` options object (TS) or `shared=True` (Python) to use agent-wide shared storage accessible across all sessions.

| Method (TS)                        | Method (Python)                          | Description                                                                                     |
| ---------------------------------- | ---------------------------------------- | ----------------------------------------------------------------------------------------------- |
| `memory.set(key, value, options?)` | `memory.set(key, value, shared=False)`   | Store a string value                                                                            |
| `memory.get(key, options?)`        | `memory.get(key, shared=False)`          | Retrieve a value (`data.value` is `null`/`None` if the key is not set - a miss is not an error) |
| `memory.delete(key, options?)`     | `memory.delete(key, shared=False)`       | Delete a key                                                                                    |
| `memory.list(options?)`            | `memory.list(prefix=None, shared=False)` | List keys in the current scope (returns `items[{key, updatedAt}]`, capped at 1000)              |

### Swap (`agent.swap`)

| Method (TS)               | Method (Python)            | Description                          |
| ------------------------- | -------------------------- | ------------------------------------ |
| `swap.quote(request)`     | `swap.quote(request)`      | Get swap/bridge quote with routing   |
| `swap.execute(quoteData)` | `swap.execute(quote_data)` | Execute a quote (or array of quotes) |

**Quote request fields**: `from`, `to`, `amount`, `fromToken?`, `toToken?`, `slippage?`, `engines?`

**Execute fields**: `quoteData`, `expiresAt?`

### Custom Transactions

| Method (TS)            | Method (Python)          | Description                            |
| ---------------------- | ------------------------ | -------------------------------------- |
| `signAndSend(request)` | `sign_and_send(request)` | Sign and broadcast a transaction       |
| `signMessage(request)` | `sign_message(request)`  | Sign a message (EVM only, EIP-191/712) |

**signAndSend fields (EVM)**: `network`, `request.toAddress`, `request.data`, `request.value`

**signAndSend fields (Solana)**: `network`, `request.hexTransaction`

### Hyperliquid (`agent.platforms.hyperliquid`)

| Method (TS)                                   | Method (Python)                                      | Description                                         |
| --------------------------------------------- | ---------------------------------------------------- | --------------------------------------------------- |
| `placeOrder(request)`                         | `place_order(request)`                               | Place an immediate perp or spot market order        |
| `deleteOrder(orderId, coin, idempotencyKey?)` | `delete_order(order_id, coin, idempotency_key=None)` | Cancel an order                                     |
| `midpointPrice(coin, dex?)`                   | `midpoint_price(coin, dex=None)`                     | Get current midpoint price(s) for one or more coins |

**placeOrder fields**: `coin`, `side`, `size`, `price`, `market`, `type: "market"`, `reduceOnly?`, `postOnly?: false`, `message?`, `idempotencyKey?`, `expiresAt?`. Agent orders are immediate only; resting and trigger orders are rejected.

**positions fields**: `dex?` to filter positions for a specific builder DEX (for example `"xyz"`, `"cash"`, or `"vntl"`). Omit it to fetch positions across the default venue and supported builder DEXes. The currently supported builder DEX set is `"xyz"`, `"cash"`, and `"vntl"`, and unsupported builder DEX names are rejected.

**Coins**: Perps use `"BTC"`, builder DEX perps use `"xyz:GOLD"`, `"cash:GOLD"`, or `"vntl:MAG7"` (currently `xyz`, `cash`, and `vntl` are supported; unsupported builder DEX prefixes are rejected), spot uses the live listing pair name - bridged majors are Unit assets with a `U` prefix (`"UBTC/USDC"`, `"UETH/USDC"`, `"USOL/USDC"`; Hyperliquid-native tokens are plain: `"HYPE/USDC"`) - never `"BTC/USDC"`, which does not exist.

**Account model**: Circuit Hyperliquid accounts are unified - one USDC balance collateralizes spot and perp trading alike, so there is no spot↔perp balance transfer. Deposited USDC is immediately usable for both; just place orders. The allocation's collateral balance is **total** collateral (includes locked margin, excludes unrealized PnL); equity = collateral + Σ positions' `unrealizedPnlUsd`; free margin ≈ equity − Σ `marginUsed`.

### Polymarket (`agent.platforms.polymarket`)

| Method (TS)                | Method (Python)             | Description                                             |
| -------------------------- | --------------------------- | ------------------------------------------------------- |
| `searchEvents(query)`      | `search_events(query)`      | Discover events by name (resolution step 1)             |
| `eventMarkets(slug)`       | `event_markets(slug)`       | One event's COMPLETE market catalog (resolution step 2) |
| `marketOrder(request)`     | `market_order(request)`     | Buy or sell prediction market shares                    |
| `redeemPositions(request)` | `redeem_positions(request)` | Redeem settled positions you hold (by tokenId)          |

**marketOrder fields**: `tokenId`, `side`, `spendUsd` (BUY) / `shares` (SELL), `idempotencyKey?`, `expiresAt?`

**redeemPositions fields**: `tokenIds` (required, non-empty - filter your positions for `isRedeemable` first), `idempotencyKey?`

**Amounts are unit-explicit**: a BUY takes `spendUsd` (USD to spend), a SELL takes `shares` (shares to sell) - the mismatched field fails validation.

**Finding the `tokenId`**: `searchEvents(query)` (specific names, not category words; check `moreEvents` for buried matches) → `eventMarkets(slug)` (the ONLY authority on which markets exist - search never shows totals/spreads/props) → pick the most liquid market matching the intent → the outcome's `tokenId`. Full guide: [Polymarket → Getting Token IDs](./polymarket#getting-token-ids).

### Kraken (`agent.platforms.kraken`)

Spot trading on the Kraken exchange, authorized by a connected **exchange credential** - never an API key/secret. The session's selected credential is `agent.credentials.kraken`, a ready-made `credentialRef = { kind: "exchange", id }`. See [Kraken](./kraken) for full detail.

| Method (TS)            | Method (Python)                                  | Tier   | Description                                       |
| ---------------------- | ------------------------------------------------ | ------ | ------------------------------------------------- |
| `placeOrder(request)`  | `place_order(request)`                           | write  | Place a spot order (`validate: true` for dry-run) |
| `cancelOrder(request)` | `cancel_order(request)`                          | write  | Cancel an order by id                             |
| `balances(request)`    | `balances(credential_ref=...)`                   | read   | Balances with `available` vs `hold`               |
| `openOrders(request)`  | `open_orders(credential_ref=..., pair=None)`     | read   | Open orders, optional pair filter                 |
| `orderStatus(request)` | `order_status(credential_ref=..., order_id=...)` | read   | Status of one order                               |
| `orderBook(query)`     | `order_book(pair=..., depth=None)`               | public | Order book (no credential)                        |
| `ticker(query)`        | `ticker(pair)`                                   | public | Ticker (no credential)                            |

**placeOrder fields**: `credentialRef`, `order` (`pair`, `side`, `type: "limit"`, `volume`, `price`), `validate?`, `idempotencyKey?`, `expiresAt?`. **Limit orders only** - market orders are rejected (allocation enforcement meters `volume x price`); use a marketable limit for immediate fills.

**Pairs**: venue-namespaced, e.g. `"KRAKEN:XBT/USD"` (the concatenated `"KRAKEN:XBTUSD"` also works; responses return the concatenated form). Enabled pairs: XBT/ETH/SOL x USD/USDC. Sell minimums are 0.0001 XBT / 0.01 ETH / 0.1 SOL; fee-safe buy minimums are 0.000102 XBT / 0.0102 ETH / 0.102 SOL. A per-order notional cap also applies. Amounts are strings. **Spot only** - margin/leverage/withdrawals are out of scope.

### Common Transaction Parameters

`expiresAt` is accepted by suggestion-producing manual-mode methods such as `swap.execute`, `placeOrder`, and `marketOrder`. Transaction confirmation is handled automatically server-side - the server waits for onchain confirmation and returns `success: false` with an error message if a transaction reverts.

`idempotencyKey` is accepted by Polymarket `marketOrder` and `redeemPositions` and Hyperliquid `placeOrder` and `deleteOrder` in auto mode. SDKs generate it automatically; provide a stable key only when retrying the same logical action after a process restart.

| Parameter        | Type           | Description                                                                                                                          |
| ---------------- | -------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
| `expiresAt`      | string \| null | ISO 8601 expiry for suggestions in manual mode. If omitted, no time-based expiry (suggestions are auto-cleared at each `run` start). |
| `idempotencyKey` | string         | Durable retry key for auto-mode Polymarket market orders / redeem attempts and Hyperliquid order and cancel actions.                 |

### Response Pattern

Every method returns:

```typescript theme={null}
{
  success: boolean;
  data?: any;       // present on success
  error?: string;   // present on failure
}
```

Always check `success` before using `data`. See [Error Handling](./error-handling) for patterns.
