sample.env
Overview
The `sample.env` file serves as a template for environment configuration variables required by the application. It defines both secret keys and public environment settings that the application depends on to connect to external services, configure logging, and specify network details.
This file is **not** meant to be used directly in production; rather, it provides a structured example for developers to create their own `.env` file with actual secret values and environment-specific configurations. Typically, this file is kept out of version control (e.g., via `.gitignore`) to avoid leaking sensitive credentials.
Detailed Explanation of Contents
The file is divided into two sections:
1. Secret Environment Variables
These variables store sensitive API keys used to authenticate requests with third-party services:
Variable Name | Description | Example Value |
|---|---|---|
`ETHERSCAN_API_KEY` | API key used to access the Etherscan blockchain explorer API for querying Ethereum network data. | (empty, to be filled) |
`INDEXER_API_KEY` | API key for the blockchain indexer service, enabling access to indexed blockchain data for efficient querying. | (empty, to be filled) |
`RPC_API_KEY` | API key used for RPC (Remote Procedure Call) endpoints, typically for blockchain node access. | (empty, to be filled) |
**Note:** These keys must be kept confidential and never committed to public repositories.
2. Environment Variables
These variables configure the operational environment and endpoints:
Variable Name | Description | Example Value |
|---|---|---|
`INDEXER_URL` | HTTP endpoint URL for the blockchain indexer API. | |
`INDEXER_WS_URL` | WebSocket URL for real-time blockchain indexer updates. | |
`LOG_LEVEL` | Logging verbosity level for the application (e.g., debug, info, warn, error). | `debug` |
`NETWORK` | Specifies the blockchain network to connect to (e.g., mainnet, testnet). | |
`RPC_URL` | HTTP RPC endpoint URL to interact with the blockchain node (e.g., for sending transactions). | `https://bsc.nownodes.io` |
Usage Example
Developers typically use this file as a starting point to create a `.env` file by copying it and filling in the secret keys:
cp sample.env .env
# Edit .env to add API keys and adjust environment variables
The application will then load the `.env` file using environment variable loaders (e.g., `dotenv` in Node.js or similar tools), making these variables accessible via process environment variables.
Implementation Details and Considerations
The file format follows the dotenv convention: simple
KEY=VALUEpairs without spaces around the equals sign.Secrets are intentionally left blank to prevent accidental exposure.
URLs provided target the Binance Smart Chain (BSC) network, indicating that the application interacts primarily with BSC.
Logging level set to
debugindicates verbose output useful during development or troubleshooting.The WebSocket URL allows subscribing to real-time blockchain events, critical for responsive dApps or analytics platforms.
Interaction with Other Parts of the System
API Clients: Modules that communicate with external blockchain APIs will read keys such as
ETHERSCAN_API_KEYandINDEXER_API_KEYfor authenticated requests.Blockchain Interaction Layer: The
RPC_URLandNETWORKvariables configure the blockchain node endpoints and network context used by smart contract interaction libraries.Logging Subsystem:
LOG_LEVELcontrols the verbosity of logs throughout the application, aiding debugging and monitoring.Event Handling:
INDEXER_WS_URLenables websocket connections for live updates, impacting components that rely on event-driven data flows.
Visual Diagram: Environment Variables Flowchart
flowchart TD
A[Start: Application Initialization] --> B[Load .env File]
B --> C{Parse Environment Variables}
C --> |Secret Keys| D[Set ETHERSCAN_API_KEY, INDEXER_API_KEY, RPC_API_KEY]
C --> |Public Configs| E[Set INDEXER_URL, INDEXER_WS_URL, LOG_LEVEL, NETWORK, RPC_URL]
D --> F[API Clients Use Secret Keys]
E --> G[Configure Network and Logging]
G --> H[Initialize Blockchain RPC and Indexer Connections]
H --> I[Application Ready]
Summary
sample.envis a template for environment configuration, essential for setting up API keys and network parameters.It helps separate sensitive data and environment-specific settings from code, enhancing security and flexibility.
This file plays a critical role in configuring blockchain connections and logging behavior across the application.
Developers should copy and customize it as
.envduring local setup or deployment.
*End of `sample.env` documentation.*