1 Configuration
Claude edited this page 2026-04-03 11:12:45 +01:00

Configuration

All configuration is via environment variables. When running locally, copy .env.example to .env and set the values.

Required Variables

The backend refuses to start if any of these are missing or set to CHANGE_ME.

Variable Description Example
JWT_SECRET Secret key for signing and verifying JWT tokens. Must be a strong random string. a1b2c3d4e5f6...
PGUSER PostgreSQL username postgres
PGPASSWORD PostgreSQL password strong-password
PGDATABASE PostgreSQL database name. Created automatically if it does not exist. lethean_trade

Optional Variables

Variable Description Default
PORT HTTP port the API listens on 3000
PGHOST PostgreSQL hostname 127.0.0.1
PGPORT PostgreSQL port 5432
DAEMON_RPC_URL Lethean daemon JSON-RPC endpoint. Used for asset discovery and chain queries. http://127.0.0.1:46941/json_rpc (testnet)
WALLET_RPC_URL Lethean wallet JSON-RPC endpoint. Used for signature verification and transfers. http://127.0.0.1:46944/json_rpc (testnet)
OWNER_ALIAS Alias of the user who is automatically granted admin privileges on startup. (unset)

RPC Port Reference

Network Daemon RPC Wallet RPC
Testnet 46941 46944
Mainnet 36941 36944

Example .env

PORT="3336"
PGUSER="postgres"
PGPASSWORD="strong-password-here"
PGHOST="127.0.0.1"
PGDATABASE="lethean_trade"
PGPORT="5432"
JWT_SECRET="replace-with-a-64-char-random-hex"
OWNER_ALIAS="admin"

# Testnet (default)
DAEMON_RPC_URL="http://127.0.0.1:46941/json_rpc"
WALLET_RPC_URL="http://127.0.0.1:46944/json_rpc"

# Mainnet (uncomment to use)
# DAEMON_RPC_URL="http://127.0.0.1:36941/json_rpc"
# WALLET_RPC_URL="http://127.0.0.1:36944/json_rpc"

Database

The backend uses Sequelize with the postgres dialect. On startup it:

  1. Connects to the postgres system database and creates PGDATABASE if absent
  2. Authenticates with the target database
  3. Runs sequelize.sync() to create/update tables

Connection pooling is configured at up to 80 connections with a 10-second idle timeout. Slow queries (over 1 second) are logged with a [slow sql] prefix.

External Services

The backend periodically fetches data from two external Lethean services:

Service URL Interval Purpose
Asset list https://explorer.lethean.io/api/get_assets/ 1 hour Import new assets and update metadata
Whitelist https://api.lethean.io/assets_whitelist.json 1 hour Mark trusted/verified assets
Price data https://explorer.lethean.io/api/get_historical_lethean_price Periodic LTHN/USD price for TVL calculations