Before You Start
Two things are required before any code gets written: 1. Client ID — identifies your application with Monaco. It routes all user activity — authentication, orders, fees, and data — to your specific application instance. 2. User Access — Public whitelist applications are closed. Existing approvals remain valid. Confirm access with the Monaco team before integrating.Email [email protected] to get your Client ID and confirm whitelist access before integrating.
Step 1: Install
@0xmonaco/react provides all React hooks. @0xmonaco/types exports TypeScript types for orders, events, and trading pairs. viem is required for wallet interactions and on-chain reads.
Step 2: Wrap Your App with MonacoProvider
MonacoProvider initialises the SDK, opens the WebSocket connection, and makes every hook available throughout your component tree. It should wrap your entire app, inside your wallet provider.
walletClient comes from your wallet connection library of choice — wagmi, Thirdweb, or raw viem. The WebSocket connection opens automatically when the provider mounts, so public channels (orderbook, trades, OHLCV) are live immediately.
For production, source
seiRpcUrl from an environment variable rather than hardcoding it.Step 3: Connect Wallets & Authenticate
Monaco uses a challenge-response authentication flow. The user signs a short message with their wallet to authorize an ed25519 session key, which then signs every request. TheuseAuth hook handles the entire flow:
authenticationStatus will be AuthenticationStatus.AUTHENTICATED, AuthenticationStatus.AUTHENTICATING, or AuthenticationStatus.UNAUTHENTICATED. Use it to gate your trading UI and show a “Connect Wallet” button to unauthenticated users.
→ React authentication hook
Step 4: Deposits
Users need to move tokens into Monaco’s vault before they can trade. TheuseVault hook covers the full flow — ERC-20 approval, deposit, and withdrawal.
Token addresses and decimals should always be sourced from the trading pair object, not hardcoded:
useUserBalances to reflect deposit confirmation in your UI the moment it lands — it subscribes to real-time balance updates internally, no polling required.
→ Deposit guide · Account Vault · Withdraw
Step 5: Orderbook & Market Data
The orderbook streams via WebSocket — every update arrives in real time with no polling.calculateValidMagnitudes(midPrice) from @0xmonaco/core to compute which magnitude steps are meaningful at the current price, and expose them as a selector so traders can zoom in or out.
For the price chart, use useOHLCV with intervals of 1m, 5m, 15m, 1h, 4h, or 1d. For a live recent-trades ticker, use useTradeFeed(pair.id) — it keeps the last 50 trades in state and updates in real time.
→ WebSocket guide · OHLCV guide
Step 6: Place & Manage Orders
Before submission, call
useFees to show users a live fee estimate — this removes uncertainty and is one of the highest-impact UX improvements you can make.
For real-time order status, use useUserOrders — it fetches initial orders and subscribes to WebSocket updates automatically. You will receive lifecycle events — OrderPlaced, OrderPartiallyFilled, OrderFilled, OrderCancelled, OrderRejected — for every order the authenticated user places.
→ Order Management · useTrade
Step 7: Portfolio
The portfolio section ties together live balances, open orders, and a full activity history.useUserBalances subscribes to ws.balances() internally, so balances stay current across order placements, fills, deposits, and withdrawals without any extra wiring.
→ Account Vault · useUserOrders · useUserMovements
What to Build Next
Authentication
Deep-dive into the wallet challenge flow, session keys, and request signing
WebSocket Streams
All available channels — orders, orderbook, OHLCV, trades, balances, movements
React Hooks Reference
Complete reference for every hook in @0xmonaco/react
REST API
REST endpoints for use cases that go beyond the SDK

