sample.env
Overview
`sample.env` is a configuration template file used to define environment variables for the application. It primarily serves as a reference for developers and deployment scripts, indicating which environment variables need to be set and their expected usage. This file includes both secret keys (which should be securely stored and never committed with actual values) and general environment settings that configure the behavior of the system.
The environment variables in `sample.env` enable the application to connect to external services such as blockchain APIs, logging systems, and indexers without hardcoding sensitive or environment-specific information in the source code. This mechanism supports flexibility, security, and portability across different deployment environments (e.g., development, staging, production).
Environment Variables Explained
The file separates variables into two categories: **Secret Environment Variables** and **General Environment Variables**.
Secret Environment Variables
These variables hold sensitive credentials required to authenticate with external APIs. They should be set securely in the deployment environment and **never committed with actual values**.
Variable Name | Description | Example Value |
|---|---|---|
`ETHERSCAN_API_KEY` | API key for accessing the Etherscan service, which provides blockchain data and analytics. | |
`INDEXER_API_KEY` | API key used to authenticate requests to the indexer service that aggregates blockchain data. | |
`RPC_API_KEY` | API key for connecting to remote procedure call (RPC) endpoints on the blockchain network. |
General Environment Variables
These variables configure the runtime behavior of the application, including network endpoints, logging, and blockchain network selection.
Variable Name | Description | Example Value |
|---|---|---|
`INDEXER_URL` | HTTP endpoint URL for the indexer service to fetch blockchain or application data. | `https://gateway.liquify.com` |
`INDEXER_WS_URL` | WebSocket URL for the indexer service, enabling real-time communication. | `wss://gateway.liquify.com` |
`LOG_LEVEL` | Sets the verbosity of application logging. Common values: `debug`, `info`, `warn`, `error`. | `debug` |
Specifies the blockchain network to connect to (e.g., `mainnet`, `testnet`). | `mainnet` | |
`RPC_URL` | HTTP endpoint URL for the blockchain RPC service to send commands and queries. | `https://gateway.liquify.com` |
Usage and Best Practices
Setting Environment Variables:
Before running the application, copysample.envto.env, and fill in the secret keys with actual values provided by the respective service providers.cp sample.env .env nano .env # then add the secret API keysSecurity:
Never commit.envfiles containing real secrets to version control. Use environment-specific secret management solutions (e.g., Vault, AWS Secrets Manager).Overriding Variables:
Environment variables can be overridden in the deployment environment or CI/CD pipelines to adapt to different environments without changing the source code.Accessing Variables in Code:
In typical Node.js or other runtime environments, environment variables are accessed viaprocess.env.VARIABLE_NAME.
Interaction with the Application
The variables defined here are consumed primarily by the network and blockchain-related modules of the system. For example:
The RPC_URL and RPC_API_KEY configure blockchain RPC client libraries for sending transactions and querying blockchain state.
The INDEXER_URL and INDEXER_API_KEY are used by indexer client components to fetch aggregated data efficiently.
ETHERSCAN_API_KEY allows the system to retrieve analytics or transaction details from the Etherscan API.
LOG_LEVEL configures the logging framework to control output verbosity for debugging or production runs.
These environment variables provide a layer of abstraction, enabling the same codebase to run seamlessly across different networks (e.g., mainnet, testnet) or different service endpoints.
Implementation Details
This file follows the conventional
.envformat with key-value pairs separated by the equals sign=.Lines starting with
#are comments used to categorize variables and provide context.Empty values indicate placeholders where real secrets must be inserted.
The WebSocket URL (
INDEXER_WS_URL) suggests that the application may use event-driven or real-time features via the indexer service.
Visual Diagram
Below is a **flowchart** illustrating the role of the environment variables in configuring connections between the main application and the external services it integrates with:
flowchart TD
A[Application] -->|Reads from sample.env| B[Environment Variables]
B --> C[Blockchain Network]
B --> D[Indexer Service]
B --> E[Etherscan API]
B --> F[Logging System]
C -->|RPC_URL & RPC_API_KEY| G[RPC Endpoint]
D -->|INDEXER_URL & INDEXER_API_KEY| H[Indexer HTTP API]
D -->|INDEXER_WS_URL| I[Indexer WebSocket API]
E -->|ETHERSCAN_API_KEY| J[Etherscan API Endpoint]
F -->|LOG_LEVEL| K[Logger Configuration]
style B fill:#f9f,stroke:#333,stroke-width:2px
Summary
`sample.env` is a critical configuration template that defines the interface between the application and its execution environment. It ensures sensitive credentials and environment-specific settings are managed securely and flexibly, thereby enabling smooth integration with blockchain networks, indexers, and logging systems. This file is foundational for deployment, environment management, and secure operation of the overall system.