sample.env


Overview

The `sample.env` file serves as a template for environment configuration variables required to run the application. It defines key-value pairs used to configure application settings such as API keys, network endpoints, logging levels, and network selection. This file is not intended to be used directly but rather copied and renamed (commonly to `.env`) with actual secret values filled in to prevent accidental exposure of sensitive information.

Environment variables from this file are loaded at runtime to configure the application's behavior, enabling it to connect to external services like blockchain indexers and RPC nodes, control logging verbosity, and select the network environment (e.g., mainnet).


Detailed Explanation of Variables

The file contains two main sections: **Secret Environment Variables** and **Environment Variables**.

Secret Environment Variables

These variables contain sensitive information such as API keys and should never be committed to public repositories or shared insecurely.

Variable Name

Description

Example Value

`INDEXER_API_KEY`

API key used to authenticate with the blockchain indexer service.

(empty, to be filled)

`RPC_API_KEY`

API key for accessing RPC endpoints securely.

(empty, to be filled)

Environment Variables

These variables configure non-secret runtime settings.

Variable Name

Description

Example Value

`INDEXER_URL`

The HTTPS URL endpoint of the blockchain indexer service.

`https://bchbook.nownodes.io`

`INDEXER_WS_URL`

The WebSocket URL endpoint for real-time indexer communication.

`wss:/bchbook.nownodes.io/wss` (note: likely typo, see Implementation Details)

`LOG_LEVEL`

Logging verbosity level for the application (e.g., `debug`, `info`, `warn`, `error`).

`debug`

`NETWORK`

Specifies the blockchain network environment (e.g., `mainnet`, `testnet`).

`mainnet`

`RPC_URL`

HTTPS URL endpoint for the blockchain RPC node.

`https://bch.nownodes.io`


Usage Example

  1. Copy the template:

    cp sample.env .env
    
  2. Fill in secret keys:

    Edit .env and add your actual API keys:

    INDEXER_API_KEY=your_real_indexer_api_key_here
    RPC_API_KEY=your_real_rpc_api_key_here
    
  3. Run the application:

    Depending on the application setup, environment variables from .env will be loaded automatically, or you may need to use a package such as dotenv in Node.js.


Implementation Details and Notes


Interaction with Other System Components

Because these variables are environment-level configuration, they are injected typically at process start time and consumed primarily by the configuration or service initialization layers in the application.


Visual Diagram

The following flowchart illustrates how the environment variables defined in `sample.env` are consumed by different parts of the system to support configuration and external service interaction.

flowchart TD
    ENV_VARS[Environment Variables<br/>(From sample.env)]
    CONFIG[Configuration Loader]
    AUTH[Authentication Module]
    INDEXER_CLIENT[Blockchain Indexer Client]
    RPC_CLIENT[Blockchain RPC Client]
    LOGGER[Logging Framework]
    NETWORK_LOGIC[Network Selection Logic]

    ENV_VARS --> CONFIG
    CONFIG --> AUTH
    CONFIG --> INDEXER_CLIENT
    CONFIG --> RPC_CLIENT
    CONFIG --> LOGGER
    CONFIG --> NETWORK_LOGIC

    AUTH -->|Uses API Keys| INDEXER_CLIENT
    AUTH -->|Uses API Keys| RPC_CLIENT

Summary


**End of `sample.env` documentation**