Skip to main content

Environment Variables

Environment variables are a powerful way to configure your EffectStream node.
They are used to configure the different components of your node, such as the blockchains, databases, and services. Setting them allows to have different runtime scripts for different environments.

System Environments

This is optional, but we recommend setting this pattern to allow for different runtime configurations for different environments.

  • EFFECTSTREAM_ENV sets the system environment.
  • node:start:${EFFECTSTREAM_ENV} should load the main.{env}.ts file.
  • .env.${EFFECTSTREAM_ENV} is loaded automatically.
  • Optionally config.{env}.ts can be created to load specific configuration for the environment, this file is imported by main.{env}.ts.

The main entry point for the node is located at: /packages/node/package.json.
For example, if you have 2 environments: local and testnet

{
"name": "@my-project-name/node",
"scripts": {
"node:start:local": "bun --inspect ./src/main.local.ts",
"node:start:testnet": "bun --inspect ./src/main.testnet.ts",

"local": "EFFECTSTREAM_ENV=local NODE_ENV=development bun ./scripts/start.local.ts",
"testnet": "EFFECTSTREAM_ENV=testnet bun ./scripts/start.testnet.ts"
}
}

By running bun run testnet:

  1. .env.testnet is loaded
  2. start.testnet.ts is launch all the processes, once completed it will call node:start:testnet

IMPORTANT: node:start:testnet must match the EFFECTSTREAM_ENV=testnet value.

Reading ENV values

System default ENV are read by using

import { ENV } from "@effectstream/utils/node-env";

// For system defaults:
const host=ENV.DB_HOST;

// For custom envs in your .env.${EFFECTSTREAM_ENV} file:
const myCustomEnv=ENV.getString("MY_CUSTOM_ENV");

Reference

Every variable below is registered in packages/effectstream-sdk/utils/src/config.ts and reachable as a typed getter on ENV. A dash in the Default column means the value is unset unless you provide it.

Environment and database

NameTypeDefaultDescription
EFFECTSTREAM_ENVstringThe system environment, e.g. local or testnet. Selects which .env.{env} file is loaded.
NODE_ENVstringNode environment, e.g. development or production.
DB_HOSTstringlocalhostPostgres host URL.
DB_NAMEstringpostgresPostgres database name.
DB_PORTnumber5432Postgres port.
DB_USERstringpostgresPostgres user.
DB_PWstringpostgresPostgres password. Secret.
PGLITEbooleantrueEnable single-connection mode and other PGLite-specific behaviour. Development only.
PGLITE_DATA_DIRstringmemory://PGLite data directory. memory:// for in-memory, or a file path for persistent storage.
DEBUG_PGLITEnumberEnable PGLite debug/verbose mode.
ALLOW_NO_PG_IVMbooleanfalseLet the engine start without the pg_ivm extension, falling back to plain SQL views. Dev/test and low-volume only — the fallback degrades sharply on high-cardinality data. See Database.

Ports and services

NameTypeDefaultDescription
EFFECTSTREAM_API_PORTnumber9999Main API port, serving your custom endpoints and the RPC endpoints.
EFFECTSTREAM_EXPLORER_PORTnumber10590Explorer port.
EFFECTSTREAM_CHAIN_IDnumber87401284021Chain ID for the EffectStream L2.
BATCHER_PORTnumber3334Batcher HTTP port.
OTEL_COLLECTOR_PORTnumber4318OpenTelemetry collector port.
DOCS_PORTnumber10600Docs server port.
ORCHESTRATOR_URLstringhttp://localhostOrchestrator URL.
ORCHESTRATOR_PORTnumber0Orchestrator port, used by the TUI to monitor processes.
TUI_LOG_URLstringhttp://localhostTUI log URL.

Events (MQTT)

NameTypeDefaultDescription
MQTT_BROKERbooleantrueWhether to run the MQTT broker.
MQTT_ENGINE_BROKER_URLstringmqtt://127.0.0.1:8883Engine broker TCP URL.
MQTT_ENGINE_BROKER_PORTnumber8883Engine broker TCP port.
MQTT_ENGINE_BROKER_WS_URLstringws://127.0.0.1:9883Engine broker WebSocket URL, for browser clients.
MQTT_ENGINE_BROKER_WS_PORTnumber9883Engine broker WebSocket port.
MQTT_BATCHER_BROKER_URLstringmqtt://127.0.0.1:8884Batcher broker TCP URL.
MQTT_BATCHER_BROKER_PORTnumber8884Batcher broker TCP port.
MQTT_BATCHER_BROKER_WS_URLstringws://127.0.0.1:9884Batcher broker WebSocket URL.
MQTT_BATCHER_BROKER_WS_PORTnumber9884Batcher broker WebSocket port.

Sync and performance

NameTypeDefaultDescription
STORE_HISTORICAL_GAME_INPUTSbooleantruePersist historical game inputs.
EFFECTSTREAM_COALESCE_EMPTY_BLOCKSbooleanfalseFold consecutive empty catch-up blocks into one DB transaction when behind the chain tip.
EFFECTSTREAM_LAG_THRESHOLD_MSnumberLag threshold (ms) gating empty-block coalescing and lag logging. Defaults to 20× the main clock's block time, or 60 s when no blockTimeMS is exposed.
EFFECTSTREAM_FINALIZED_STREAM_CAPnumber2048Backpressure cap on the in-memory finalized-block queue between the merge and the runtime apply loop, bounding memory during deep catch-up.

Snapshots

See Database Snapshots for the full retention model.

NameTypeDefaultDescription
EFFECTSTREAM_SNAPSHOT_INTERVAL_SECONDSnumberWall-clock seconds between automated pg_dump snapshots. Leaving this unset disables snapshots entirely.
EFFECTSTREAM_SNAPSHOT_PATHstring./snapshotsOutput directory for .dump files.
EFFECTSTREAM_SNAPSHOT_LAST_DAY_HOURLYbooleantrueRetention: keep one snapshot per hour for the last 24 hours.
EFFECTSTREAM_SNAPSHOT_LAST_3_DAYS_SIX_HOURLYbooleantrueRetention: keep one snapshot per 6-hour window for the last 3 days.
EFFECTSTREAM_SNAPSHOT_LAST_N_DAYSnumber7Retention: keep one snapshot per day for this many days; older snapshots are deleted.

Security and development

NameTypeDefaultDescription
ENABLE_DEV_AND_DEBUG_ENDPOINTSbooleanfalseRegister the developer/debug endpoints (/debug/sync-protocols, /config, /db_acquire_lock, /db_release_lock, /force-batch, /clear-inputs). Disable in production — when unset these routes do not exist at all.
API_KEY_OPEN_ENDPOINTS_EXPLORERstringeffectstream_api_explorer_endpoints_passwordAPI key guarding the open explorer endpoints (tables, primitives, addresses, scheduled-data). Secret — change this in production.
RECAPTCHA_V3_FRONTENDstringReCaptcha v3 frontend key, used by the batcher to verify requests. Leave empty to disable.
MIDNIGHT_STORAGE_PASSWORDstringYourPasswordMy1!Midnight storage password, used to run the node or deploy contracts on Midnight. Secret.

Set by the environment

These are read from the OS rather than configured by you.

NameTypeDefaultDescription
SHELLstringSystem shell path, set by the OS. Used to run TUI/tmux commands.
TMUXstringSet by tmux itself; used to detect whether the process runs inside a tmux session.
TUI_LOG_PORTnumber11033TUI log port.