sample.env


Overview

The `sample.env` file serves as a template for environment configuration in the project. It defines a set of environment variables necessary for the application to interact with external services such as blockchain indexers, RPC endpoints, and logging configurations. This file primarily stores API keys and URLs used by various components for network communication and debugging.

Since this file contains sensitive information (such as API keys), the actual values are left empty or set to example URLs. It acts as a reference for developers to set up their own `.env` files with real credentials and endpoints.

This file does **not** contain executable code but is critical for configuring the runtime environment of the application.


Environment Variables Explained

Secret Environment Variables

These variables hold API keys required for authenticated requests:

Variable Name

Description

Example Value

`ETHERSCAN_API_KEY`

API key for accessing Etherscan services (Ethereum blockchain).

(empty, to be filled by user)

`INDEXER_API_KEY`

API key for the blockchain indexer service.

(empty, to be filled by user)

`RPC_API_KEY`

API key for the RPC provider service.

(empty, to be filled by user)

General Environment Variables

These variables configure endpoints and settings for network communication and logging:

Variable Name

Description

Default / Example Value

`INDEXER_URL`

HTTP URL for the blockchain indexer service that provides blockchain data via REST API.

`https://avax-blockbook.nownodes.io`

`INDEXER_WS_URL`

WebSocket URL for real-time blockchain data subscription from the indexer.

`wss://avax-blockbook.nownodes.io/wss`

`LOG_LEVEL`

Specifies the verbosity of logs generated by the application; useful for debugging and monitoring.

[debug](/projects/291/69098) (other levels might be `info`, `warn`, `error`)

`NETWORK`

Indicates the blockchain network environment the application connects to.

`mainnet`

`RPC_URL`

RPC endpoint URL for sending smart contract and blockchain calls.

`https://avax.nownodes.io/ext/bc/C/rpc`


Usage

  1. Setup: Developers copy this sample.env file to .env in the project root.

  2. Fill API keys: Populate the secret variables with actual API keys obtained from the respective service providers.

  3. Configure URLs: Adjust URLs if using different endpoints (e.g., testnet or custom nodes).

  4. Run application: The application reads these variables at runtime to configure network connections and logging.

Example `.env` after customization:

ETHERSCAN_API_KEY=YOUR_ETHERSCAN_API_KEY_HERE
INDEXER_API_KEY=YOUR_INDEXER_API_KEY_HERE
RPC_API_KEY=YOUR_RPC_API_KEY_HERE

INDEXER_URL=https://avax-blockbook.nownodes.io
INDEXER_WS_URL=wss://avax-blockbook.nownodes.io/wss
LOG_LEVEL=info
NETWORK=mainnet
RPC_URL=https://avax.nownodes.io/ext/bc/C/rpc

Important Details


Interaction with Other System Components

These environment variables are typically loaded at application startup by configuration or environment libraries (e.g., `dotenv` in Node.js). They provide centralized control over external integrations and runtime behavior.


Visual Diagram: Environment Variable Utilization Flowchart

flowchart TD
    A[Application Startup] --> B[Load sample.env / .env]
    B --> C{Environment Variables}
    C -->|ETHERSCAN_API_KEY| D[Blockchain Explorer Module]
    C -->|INDEXER_API_KEY, INDEXER_URL, INDEXER_WS_URL| E[Blockchain Indexer Module]
    C -->|RPC_API_KEY, RPC_URL| F[RPC Client Module]
    C -->|LOG_LEVEL| G[Logging Framework]
    C -->|NETWORK| H[Network Configuration Module]

    D --> I[External Etherscan API]
    E --> J[External Indexer Service]
    F --> K[RPC Node Provider]
    G --> L[Log Output (Console/File)]

Summary

The `sample.env` file is a foundational configuration template essential for setting up environment-specific variables critical to the application's interaction with blockchain services, logging, and network configuration. Properly populating and securing this file is vital for the correct and secure operation of the system.


If you need further guidance on setting up environment variables or integrating with specific services, please refer to the project’s main documentation or configuration guides.