Quick start
This page starts the full exchange on a local Anvil chain. It uses public Anvil test accounts, test USDC, and a test oracle. For each step in detail, see Run the local exchange.
Before you start
Install these tools:
- Node.js 22.12 or later
- pnpm 11
- Foundry (
forgeandanvil)
Run all commands from the repository root. If Foundry is not on the shell path, add ~/.foundry/bin to PATH.
Ports
The local stack uses port 8545 (Anvil), port 3001 (API), and port 3000 (web application). The documentation site uses port 5173.
Start the exchange
Use one terminal for each long-running command.
Terminal 1. Start the chain. It mines one block each second.
pnpm install
pnpm local:chainTerminal 2. Build the contracts. Deploy them. Give the makers collateral. Start the quote loop.
forge build --root contracts
pnpm local:deploy
pnpm demo seed
pnpm demo serveTerminal 3. Start the API. The relayer key is the key of public Anvil account 9.
DEPLOYMENT_FILE=deployments/local.json RPC_URL=http://127.0.0.1:8545 \
STATE_FILE=.local/local-indexer.json INDEX_BATCH_BLOCKS=1000 INDEX_CONFIRMATIONS=0 \
RELAYER_PRIVATE_KEY=0x2a871d0798f97d79848a013d4936a73bf4cc922c825d33c1cf7073dff6d409c6 \
pnpm dev:servicesTerminal 4. Put the local values in web/.env.local, then start the web application.
NEXT_PUBLIC_API_URL=http://127.0.0.1:3001
NEXT_PUBLIC_CHAIN_ID=31337
NEXT_PUBLIC_CHAIN_NAME=Monad Local Demo
NEXT_PUBLIC_RPC_URL=http://127.0.0.1:8545pnpm dev:webOpen http://localhost:3000.
Make the first trade
- Import Anvil account 6 into MetaMask. Add a network with RPC
http://127.0.0.1:8545, chain ID 31337, and currency symbol MON. - Connect the wallet.
- Select
Faucetin the top bar. It mints 10,000 test USDC to the wallet. Confirm the wallet transaction. - Open the
Accountdialog. Select the market. Enter an amount in the deposit field, then selectApprove and deposit. Confirm the approval and the deposit in the wallet. - In the same dialog, select
Enableon the trading session row. The main wallet signs one authorization. - Place a small order. The session key signs it. The relayer submits it.
Move the oracle price
While pnpm demo serve runs, send a price shock from a fifth terminal:
pnpm demo shock MON -4The loop applies the percent at the next observation of that market. The squared return shows in the funding of that observation.
Next steps
| Goal | Page |
|---|---|
| Understand each local step, the accounts, and the options | Run the local exchange |
Run the LP hedge story from the Hedging demo page | Hedging demo |
| Use the public Monad testnet | Run on Monad testnet |
| Run the tests | Checks and troubleshooting |