Skip to content

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.

VariableDefaultUse
DEPLOYMENT_FILEdeployments/local.jsonJSON deployment file, relative to the repository root
RPC_URLThe URL in the deployment file, then http://127.0.0.1:8545RPC endpoint
RELAYER_PRIVATE_KEYNoneGas account of the relayer. Without it, the API is read-only.
SERVICE_PORT3001HTTP port. The server binds to 127.0.0.1.
WEB_ORIGINhttp://localhost:3000The permitted browser origin
SHOCK_ENABLEDNot setSet true to accept POST /demo/shock on a chain other than 31337. The deployment must use the test oracle.
STATE_FILE.local/indexer.jsonEvent index file, relative to the repository root
INDEX_CONFIRMATIONS1Blocks behind the head for indexed history
INDEX_BATCH_BLOCKS500Blocks for each log request. The public Monad testnet RPC limits this to 100.
RELAYER_MAX_GAS5000000Largest sponsored gas limit
KEEPER_PRIVATE_KEYThe relayer keySigner 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.

VariableDefaultUse
NEXT_PUBLIC_API_URLhttp://127.0.0.1:3001URL of the API
NEXT_PUBLIC_CHAIN_ID31337Chain of the wallet connection. 10143 selects Monad testnet.
NEXT_PUBLIC_CHAIN_NAMEMonad Local Demo, or the Monad testnet nameNetwork name in the wallet
NEXT_PUBLIC_RPC_URLhttp://127.0.0.1:8545, or the Monad testnet RPCRPC of the browser
NEXT_PUBLIC_DOCS_URLThe repository pageTarget of the Docs link in the top navigation

The chain of the API deployment and the chain of the browser must agree.

dotenv
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:8545
dotenv
NEXT_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.xyz

The 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.

VariableDefaultUse
RPC_URLhttp://127.0.0.1:8545Local Anvil endpoint. The chain ID must be 31337.
LOCAL_OBSERVATION_SECONDS60Observation interval of a new deployment. The Hedging demo uses 10.
LOCAL_MARKET_CONTRACTMarketMarket or QueuedMarket

Testnet operator ​

Used by pnpm testnet.

VariableDefaultUse
TESTNET_RPC_URLhttps://testnet-rpc.monad.xyzRPC endpoint. The chain ID must be 10143.
TESTNET_DEPLOYMENT_FILEdeployments/monad-testnet.jsonDeployment file of the operator. The journal file has the same name with -journal.
DEPLOYER_PRIVATE_KEYNoneDeployer, oracle signer, quoter, and first maker
MAKER_PRIVATE_KEYNoneSecond maker and random taker. It must be a different account.
REQUOTE_SECONDS300Seconds between quotes in serve. From 30 to 1190.
TAKER_SECONDS240Seconds between taker orders for each market in serve. 0 stops the taker. If not 0, the minimum is 60.
FAST_SECONDS15Interval of serve-fast, from 5 to 60 seconds
FAST_BUDGET_FILE.local/fast-budget.jsonSaved transactions and cost records of serve-fast
FORGE_BIN~/.foundry/bin/forgeFoundry executable for testnet:estimate-onchain

Set TESTNET_DEPLOYMENT_FILE for the operator and DEPLOYMENT_FILE for the services to the same file.

Files ​

PathContentIn Git
deployments/local.jsonAddresses of the local deploymentNo
deployments/monad-testnet.jsonAddresses of the standard testnet deploymentNo
deployments/monad-testnet-journal.jsonTransaction hashes of that deployment, for receipt recoveryNo
.local/indexer.json, .local/local-indexer.jsonEvent index filesNo
.local/demo-shock.jsonA pending local price shockNo
.local/testnet-shock.jsonA pending testnet price shockNo
.local/fast-budget.jsonTransactions and cost records of serve-fastNo
.local/onchain-gas-estimate.jsonReport of the gas estimate scriptNo
.env, web/.env.localKeys and settingsNo

Deployment file format ​

The shared package exports the format as deploymentSchema.

json
{
  "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.

Deployed on Monad testnet.