Configuration
Keep keys and server settings in the root .env file. Keep the public browser settings in web/.env.local. The file .env.example in the repository root shows the variable names.
Keys
Never put a private key in a NEXT_PUBLIC_ variable or in the web directory. Never copy private keys, seed phrases, authenticated RPC URLs, or .env contents into documentation.
How the variables load
The root scripts dev:services, keeper, testnet, and testnet:estimate-onchain load the root .env file if it exists. Node.js does not replace a variable that is already set. Thus a value on the command line has priority over the .env file.
The scripts local:deploy and demo do not load .env.
Services
Used by pnpm dev:services and pnpm keeper.
| Variable | Default | Use |
|---|---|---|
DEPLOYMENT_FILE | deployments/local.json | JSON deployment file, relative to the repository root |
RPC_URL | The URL in the deployment file, then http://127.0.0.1:8545 | RPC endpoint |
RELAYER_PRIVATE_KEY | None | Gas account of the relayer. Without it, the API is read-only. |
SERVICE_PORT | 3001 | HTTP port. The server binds to 127.0.0.1. |
WEB_ORIGIN | http://localhost:3000 | The permitted browser origin |
SHOCK_ENABLED | Not set | Set true to accept POST /demo/shock on a chain other than 31337. The deployment must use the test oracle. |
STATE_FILE | .local/indexer.json | Event index file, relative to the repository root |
INDEX_CONFIRMATIONS | 1 | Blocks behind the head for indexed history |
INDEX_BATCH_BLOCKS | 500 | Blocks for each log request. The public Monad testnet RPC limits this to 100. |
RELAYER_MAX_GAS | 5000000 | Largest sponsored gas limit |
KEEPER_PRIVATE_KEY | The relayer key | Signer of the keeper commands. The oracle commands need the owner of the test oracle. |
Absolute paths are also accepted for the two files.
Web application
Set these values in web/.env.local. After a change, stop the dev server, remove web/.next, and start the server again.
| Variable | Default | Use |
|---|---|---|
NEXT_PUBLIC_API_URL | http://127.0.0.1:3001 | URL of the API |
NEXT_PUBLIC_CHAIN_ID | 31337 | Chain of the wallet connection. 10143 selects Monad testnet. |
NEXT_PUBLIC_CHAIN_NAME | Monad Local Demo, or the Monad testnet name | Network name in the wallet |
NEXT_PUBLIC_RPC_URL | http://127.0.0.1:8545, or the Monad testnet RPC | RPC of the browser |
NEXT_PUBLIC_DOCS_URL | The repository page | Target of the Docs link in the top navigation |
The chain of the API deployment and the chain of the browser must agree.
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:8545NEXT_PUBLIC_API_URL=http://127.0.0.1:3001
NEXT_PUBLIC_CHAIN_ID=10143
NEXT_PUBLIC_CHAIN_NAME=Monad Testnet
NEXT_PUBLIC_RPC_URL=https://testnet-rpc.monad.xyzThe file web/.env.example holds the Monad testnet values.
Point the Docs link at this site
To open this documentation site from the Docs link of the terminal, add NEXT_PUBLIC_DOCS_URL=http://localhost:5173 to web/.env.local and run pnpm dev:docs.
Local scripts
Used by pnpm local:deploy and pnpm demo.
| Variable | Default | Use |
|---|---|---|
RPC_URL | http://127.0.0.1:8545 | Local Anvil endpoint. The chain ID must be 31337. |
LOCAL_OBSERVATION_SECONDS | 60 | Observation interval of a new deployment. The Hedging demo uses 10. |
LOCAL_MARKET_CONTRACT | Market | Market or QueuedMarket |
Testnet operator
Used by pnpm testnet.
| Variable | Default | Use |
|---|---|---|
TESTNET_RPC_URL | https://testnet-rpc.monad.xyz | RPC endpoint. The chain ID must be 10143. |
TESTNET_DEPLOYMENT_FILE | deployments/monad-testnet.json | Deployment file of the operator. The journal file has the same name with -journal. |
DEPLOYER_PRIVATE_KEY | None | Deployer, oracle signer, quoter, and first maker |
MAKER_PRIVATE_KEY | None | Second maker and random taker. It must be a different account. |
REQUOTE_SECONDS | 300 | Seconds between quotes in serve. From 30 to 1190. |
TAKER_SECONDS | 240 | Seconds between taker orders for each market in serve. 0 stops the taker. If not 0, the minimum is 60. |
FAST_SECONDS | 15 | Interval of serve-fast, from 5 to 60 seconds |
FAST_BUDGET_FILE | .local/fast-budget.json | Saved transactions and cost records of serve-fast |
FORGE_BIN | ~/.foundry/bin/forge | Foundry executable for testnet:estimate-onchain |
Set TESTNET_DEPLOYMENT_FILE for the operator and DEPLOYMENT_FILE for the services to the same file.
Files
| Path | Content | In Git |
|---|---|---|
deployments/local.json | Addresses of the local deployment | No |
deployments/monad-testnet.json | Addresses of the standard testnet deployment | No |
deployments/monad-testnet-journal.json | Transaction hashes of that deployment, for receipt recovery | No |
.local/indexer.json, .local/local-indexer.json | Event index files | No |
.local/demo-shock.json | A pending local price shock | No |
.local/testnet-shock.json | A pending testnet price shock | No |
.local/fast-budget.json | Transactions and cost records of serve-fast | No |
.local/onchain-gas-estimate.json | Report of the gas estimate script | No |
.env, web/.env.local | Keys and settings | No |
Deployment file format
The shared package exports the format as deploymentSchema.
{
"chainId": 31337,
"rpcUrl": "http://127.0.0.1:8545",
"deploymentBlock": 0,
"isTestOracle": true,
"contracts": { "registry": "0x...", "oracle": "0x...", "usdc": "0x..." },
"markets": [{ "symbol": "MON", "address": "0x...", "feedId": "0x..." }]
}The services start the event index at deploymentBlock. GET /deployment returns this object.