Configuration

Every backend environment variable, with its default.

The backend reads its settings from environment variables. When it starts it also loads a .env file from its working directory, so backend/.env works. Defaults below are the values in the code. The sample backend/.env.example overrides a few of them, and those overrides are marked.

Service

VariableDefaultPurpose
QB2_ENVIRONMENTdevelopmentLabel shown in health output.
QB2_SERVICE_NAMEquantum-backendService name in logs and health output.
QB2_API_HOST0.0.0.0Bind address.
QB2_API_PORT8081Bind port.
QB2_LOG_LEVELINFOStandard Python log level.
QB2_JSON_LOGStrueStructured JSON logs. Set false for simpler local logs.

Authentication

VariableDefaultPurpose
QB2_AUTH_REQUIREDtrueWhen false, every request is treated as a local administrator. .env.example sets false. Never disable this in production.
QB2_ALLOW_DEV_BEARER_TOKENSfalseAccept Bearer dev-<user_id> tokens even when authentication is required. For controlled local testing only.

MongoDB

VariableDefaultPurpose
QB2_MONGODB_TARGETlocallocal uses QB2_MONGODB_LOCAL_URI; remote uses QB2_MONGODB_REMOTE_URI.
QB2_MONGODB_LOCAL_URInoneFor example mongodb://127.0.0.1:27017.
QB2_MONGODB_REMOTE_URInoneFor example an Atlas mongodb+srv:// URI.
QB2_MONGODB_DATABASEquantum_backend_v2Database name. .env.example sets qds.
QB2_MONGODB_SERVER_SELECTION_TIMEOUT_MS5000How long to wait for a server.

Peer log

VariableDefaultPurpose
QB2_PEER_IDlocal-dev-peerIdentity written into the peer log.
QB2_PEER_LOG_DIRunder the backend folderWhere the append-only log is written.
QB2_PEER_LOG_FSYNCtrueFlush every write to disk.

libp2p

VariableDefaultPurpose
QB2_LIBP2P_ENABLEDtrueRun the libp2p host.
QB2_LIBP2P_PEER_IDqb2-dev-peerPeer name.
QB2_LIBP2P_LISTEN_MULTIADDRS/ip4/0.0.0.0/tcp/4011Comma-separated listen addresses.
QB2_LIBP2P_ADVERTISE_MULTIADDRSemptyAddresses to advertise, if different.
QB2_LIBP2P_BOOTSTRAP_PEERSemptyComma-separated peers to connect to first.
QB2_LIBP2P_RENDEZVOUS_NAMESPACEquantum-backendPrefix for the discovery topics and protocol ids.
QB2_LIBP2P_PEERSTORE_PATHunder the backend folderSQLite peerstore file.
QB2_LIBP2P_ACTIVATE_LISTENERStrueStart the listeners.
QB2_LIBP2P_HEARTBEAT_INTERVAL_SECONDS60Heartbeat period (minimum 5).
QB2_LIBP2P_STALE_PEER_TTL_SECONDS300Time without a message before a peer is stale (minimum 30).
QB2_LIBP2P_DEV_SERVICE_PEER_COUNT0Embedded worker peers to start in this process (0 to 32). .env.example sets 4.
QB2_LIBP2P_DEV_SERVICE_BASE_PORT4021First port used by embedded workers.

Credits and payments

VariableDefaultPurpose
QB2_CIRCUIT_JOB_CREDIT_COST0Credits held per circuit job. 0 turns metering off.
QB2_X402_GATEWAY_SECRETnoneEnables the hidden internal routes used by the x402 gateway. Must equal the console's X402_GATEWAY_SECRET.
QB2_BILLING_INTERNAL_SECRETnoneShared secret for the console's billing calls.
QB2_PAYMENT_RECONCILE_INTERVAL_SECONDS300How often the payment reconciliation sweep runs.

Content node and provenance

VariableDefaultPurpose
KUBO_RPC_URLhttp://kubo:5001The private RPC address of the Kubo node.
KUBO_RPC_SECRETnonePrivate token shared with Kubo. Setting it turns on bundle publishing.
KUBO_RPC_TIMEOUT_SECONDS30Maximum 300.
KUBO_RPC_MAX_RESPONSE_BYTES4194304Maximum 64 MiB.
IPFS_GATEWAY_URLhttp://kubo:8080Private gateway used to read content.
IPFS_PUBLIC_GATEWAY_URLnoneBrowser-facing gateway origin, used to build "open evidence" links.
IPFS_GATEWAY_TIMEOUT_SECONDS30
IPFS_GATEWAY_MAX_RESPONSE_BYTES4194304
QB2_ANCHOR_NETWORKnoneTurns on anchor verification. A registry alias or CAIP-2 id of a test network with the anchor_root capability.
QB2_ANCHOR_SENDERnonePublic address of the anchor account.
QB2_ANCHOR_PAST_SENDERSemptyComma-separated earlier anchor accounts, kept so old anchors still verify.
QB2_ANCHOR_PRIVATE_KEYnoneA dedicated low-balance key. With it, the backend also sends anchors on a schedule.
QB2_ANCHOR_INTERVAL_SECONDS3600Scheduled anchoring period.
QB2_ANCHOR_MAX_BATCH10000Most bundles per batch.
QB2_ANCHOR_MAX_FEE_GWEI100Fee ceiling for anchor transactions.

Chains

VariableDefaultPurpose
QB2_CHAIN_REGISTRY_PATHthe packaged registryPath to a chain registry file.
NETWORKnoneWallet network name, for example base-sepolia.

Agents and wallets

VariablePurpose
AGENT_AUTH_BRIDGE_SECRETShared secret (at least 32 characters) used to sign and check the identity assertions the console sends. Same value in the console and backend.
AGENT_LLM_PROVIDERgroq, openrouter or near. See Agent LLM providers.
GROQ_API_KEY, GROQ_MODELGroq. The default model is openai/gpt-oss-20b.
OPENROUTER_API_KEY, OPENROUTER_MODELOpenRouter, free models only.
NEARAI_API_KEY, NEAR_MODELNEAR AI Cloud. The model must support TEE attestation.
CDP_API_KEY_ID, CDP_API_KEY_SECRET, CDP_WALLET_SECRETCoinbase CDP server wallets.
WALLET_ENCRYPTION_KEYEncrypts stored session keys at rest.
TOJU_API_URL, TOJU_PAYMENT_RECIPIENT, TOJU_NODE_BINARYToju storage.
ENS_NETWORK, ENS_RPC_URLENS.

Starknet

VariablePurpose
STARKNET_POLICY_CONTRACTAddress of the deployed spending-policy contract.
STARKNET_SESSION_KEY_SPENDSet to 1 to use session-key spends.
STARKNET_RELAYER_ADDRESS, STARKNET_RELAYER_PRIVATE_KEYThe account that submits spends.
AVNU_PAYMASTER_API_KEYLets the AVNU paymaster sponsor register_session.
QB2_STARKNET_SEPOLIA_RPC_URLA live Starknet Sepolia RPC.

See Starknet session keys.

Chains and prices

VariablePurpose
QB2_BASE_SEPOLIA_RPC_URL, QB2_ETHEREUM_SEPOLIA_RPC_URL, QB2_ROBINHOOD_TESTNET_RPC_URL, QB2_STARKNET_SEPOLIA_RPC_URLRPC overrides. See Chain registry.
QB2_ROBINHOOD_MAINNET_RPC_URLRead-only RPC for tokenized-stock prices. See Chainlink.

Console (frontend)

These go in frontend/.env.local (see frontend/.env.example).

VariablePurpose
NEXT_PUBLIC_BACKEND_URLWhere the console reaches the coordinator.
NEXT_PUBLIC_TRIAL_DISABLEDtrue skips the one-hour trial gate locally.
MONGODB_URI, MONGODB_DB_NAMESign-in sessions.
BETTER_AUTH_URL, BETTER_AUTH_SECRETBetter Auth.
RESEND_API_KEY, OTP_EMAIL_FROMEmailed sign-in codes.
NEXT_PUBLIC_APP_DOMAINThe expected Sign-in with Ethereum domain, if different from the host.
X402_ENABLED, X402_NETWORK, X402_AVM_ADDRESS, X402_FACILITATOR_URL, X402_QUANTUM_RUN_PRICE, X402_GATEWAY_SECRETx402.
STRIPE_SECRET_KEY, STRIPE_PRICE_ID, STRIPE_WEBHOOK_SECRETSubscriptions. See Billing.
STRIPE_CREDIT_PACKS, BILLING_INTERNAL_SECRET, STRIPE_STABLECOIN_PAYMENTSCredit packs and USDC packs.
NEXT_PUBLIC_IPFS_TRUSTLESS_GATEWAYSGateways VAULT uses to open a CID.
NEXT_PUBLIC_PINATA_JWT, NEXT_PUBLIC_LIGHTHOUSE_KEYVAULT pinning. Exposed to the browser. See VAULT and IPFS.

Treat every variable above that holds a secret (QB2_X402_GATEWAY_SECRET, QB2_BILLING_INTERNAL_SECRET, KUBO_RPC_SECRET, QB2_ANCHOR_PRIVATE_KEY, WALLET_ENCRYPTION_KEY, STARKNET_RELAYER_PRIVATE_KEY, every API key) as private. Never expose one to a browser, and never commit a .env file.

On this page