SDKs
The TxFlow TypeScript SDK is the first supported client library for TxFlow. It provides typed access to the Info API, signs and submits Exchange API actions, streams the WebSocket API channels, and configures the correct network and EIP-712 domains for you.
Availability
| Language | Status | Scope |
|---|---|---|
| TypeScript | Beta | Info queries, signed exchange actions, Builder Codes, WebSocket subscriptions, wallet adapters, network presets |
| Python | Planned | Will be opened in a later release |
| Rust | Planned | Will be opened in a later release |
Python and Rust packages are not available yet. Examples in this section intentionally use TypeScript only.
What the TypeScript SDK handles
- Typed reads — query markets, books, balances, positions, orders, fees, and risk calculators through
sdk.info. - Signed writes — place and cancel orders, manage leverage and margin, authorize agents, and submit other named actions through
sdk.exchange. - Builder Codes — approve or revoke a builder fee, attach a builder to an order action, and claim accrued rewards.
- Real-time streams — subscribe to market, user, explorer, Outcome, and candle channels through
sdk.subscriptionsandsdk.apiSubscriptions, with reconnection and replay handled for you. - Signing details — builds nonces, MessagePack hashes, EIP-712 payloads, signatures, and request envelopes.
- Wallet adapters — accepts a private key, a viem local account, an ethers v6 signer, or an EIP-1193 provider.
- Network presets — configures
testnetormainnetwithout copying domain constants into your app. - Tree-shakable functions — every client method is also available as a standalone function for browser bundles.
Exchange methods sign and send in one step; there is no raw or build-only exchange escape hatch.
A first read-only call
Read methods do not require a wallet or private key:
import { TxFlow } from 'txflow-typescript-sdk'
const sdk = new TxFlow('testnet')
const meta = await sdk.info.perpMeta()
for (const market of meta.universe) {
console.log(market.index, market.name)
}For signed trading, TxFlow separates the account owner from an agent key:
- The owner authorizes an agent once with
approveAgent. - A backend service or bot uses the agent key for day-to-day trading.
- The agent can trade but cannot withdraw the owner's funds.
Start with Authentication before sending an exchange action.
Documentation
- Installation — requirements, package install, and initialization
- Quickstart — discover a market and submit a testnet order
- Authentication — owner wallets, agent keys, and supported signers
- Info API — typed read methods and common query patterns
- Exchange API — signed writes, responses, and order helpers
- Builder Codes — approvals, per-order fees, and reward claims
- Subscriptions — real-time channels over WebSocket
- Advanced usage — tree-shaking, custom transport, errors, and vault routing
Requirements
- Node.js 18 or later; streaming needs a global
WebSocket, so Node.js 22 or later unless you inject one - ESM or CommonJS
- Decimal values passed as strings, for example
"60000"and"0.001"
For the underlying signature scheme and test vectors, see Signing.