sample.env
Overview
The `sample.env` file serves as a template for environment configuration in the application. It defines key environment variables required to connect to external services (such as APIs and RPC endpoints), configure network settings, and control application behavior (like logging verbosity). This file is meant to be copied and customized by users or deployment scripts to provide actual secret keys and service URLs, which the application reads at runtime to configure its operational parameters.
Environment variables stored in `.env`-style files such as `sample.env` are crucial for separating configuration from code, enabling secure management of secrets (e.g., API keys), and allowing different configurations for development, testing, and production environments without modifying source code.
Detailed Explanation of Contents
The `sample.env` file contains two main sections:
1. Secret Environment Variables
These variables hold sensitive information, such as API keys, which are necessary for authenticating with third-party services. They should never be committed with actual values to public repositories.
Variable Name | Description | Example Value (placeholder) |
|---|---|---|
`INDEXER_API_KEY` | API key for accessing the Indexer service. | (empty, to be filled) |
`RPC_API_KEY` | API key for RPC (Remote Procedure Call) service access. | (empty, to be filled) |
2. Environment Variables
These variables configure URLs, logging level, network selection, and RPC endpoints.
Variable Name | Description | Example Value |
|---|---|---|
`INDEXER_URL` | HTTP URL for the Indexer service endpoint. | `https://gateway.liquify.com` |
`INDEXER_WS_URL` | WebSocket URL for the Indexer service, used for real-time updates. | `wss://gateway.liquify.com` |
`LOG_LEVEL` | Sets the logging verbosity level (e.g., debug, info, warn, error). | `debug` |
`NETWORK` | Specifies the blockchain network environment (e.g., mainnet, testnet). | `mainnet` |
`RPC_URL` | HTTP URL for the RPC service endpoint. | `https://gateway.liquify.com` |
Usage
How to Use This File
Copy to
.env
Copysample.envto a new file named.envin the root of your project:cp sample.env .envFill in Secrets
Populate the secret variables (INDEXER_API_KEYandRPC_API_KEY) with your actual API keys.Modify Other Variables as Needed
Adjust URLs, network, and log level according to your environment needs (development, staging, production).Load Environment Variables
When the application starts, it typically uses a library likedotenv(in Node.js) or equivalent to load these variables into the process environment.
Example
INDEXER_API_KEY=abcd1234efgh5678
RPC_API_KEY=wxyz9876mnop5432
INDEXER_URL=https://gateway.liquify.com
INDEXER_WS_URL=wss://gateway.liquify.com
LOG_LEVEL=info
NETWORK=mainnet
RPC_URL=https://gateway.liquify.com
Important Implementation Details
Security:
Secrets such as API keys should never be committed to version control. Thesample.envfile provides a safe template without actual secret values.Configuration Flexibility:
By centralizing configuration in environment variables, this approach supports multiple deployment targets and seamless environment switching.Service Integration:
The URLs and keys indicate integration with the Liquify gateway services, suggesting this environment file configures connectivity for blockchain-related operations (indexing, RPC calls).
Interaction with Other System Components
Application Startup:
The main application reads these environment variables on startup to configure connections to external services and set runtime parameters.API Clients:
Internal modules that communicate with the indexer or RPC services consumeINDEXER_API_KEY,RPC_API_KEY, and corresponding URLs to authenticate and send requests.Logging System:
TheLOG_LEVELvariable controls how verbose the log output is, allowing developers to toggle between detailed debug information or less verbose production logging.Network Selection:
TheNETWORKvariable is used to select the blockchain network context, influencing how transactions and queries are constructed and routed.
Visual Diagram: Environment Variable Configuration Flow
flowchart TD
A[sample.env file] --> B[Application Startup]
B --> C{Load Environment Variables}
C -->|INDEXER_API_KEY, RPC_API_KEY| D[Authentication Modules]
C -->|INDEXER_URL, INDEXER_WS_URL| E[Indexer API Client]
C -->|RPC_URL| F[RPC Client]
C -->|LOG_LEVEL| G[Logging Configuration]
C -->|NETWORK| H[Network Context Setup]
D --> I[Secure API Requests]
E --> I
F --> I
*Diagram Explanation:*
The
sample.envfile provides environment variables at application startup.These variables configure authentication, API clients, logging, and network context.
Authenticated clients send requests to external services securely according to the configured environment.
Summary
The `sample.env` file is a crucial configuration template that defines the secrets and environment-specific variables required by the application to connect to external blockchain-related services, set logging verbosity, and select the operating network. Proper setup and management of this file ensure secure and flexible deployment configurations across multiple environments.