sample.env


Overview

The `sample.env` file serves as a template for environment variable configuration in the project. It defines both secret keys and standard environment variables necessary for the application to connect to external services and control runtime behavior.

This file is intended to be copied and renamed (e.g., `.env`) where actual values for secrets and URLs can be securely stored, enabling the application to access configuration without hardcoding sensitive information in source code.


Purpose and Functionality

These variables collectively configure how the application interacts with external blockchain-related services, specifically those provided by Helius (a blockchain infrastructure provider).


Detailed Explanation of Variables

Variable Name

Description

Example Value

Usage Notes

`INDEXER_API_KEY`

API key for authenticating with the indexer service.

(empty in sample, to be filled)

Must be kept secret; used for authorized queries to the indexer API.

`RPC_API_KEY`

API key for RPC (Remote Procedure Call) service access.

(empty in sample, to be filled)

Used to authenticate RPC requests to blockchain nodes or proxy services.

`WS_API_KEY`

API key for WebSocket-based API access.

(empty in sample, to be filled)

Enables secure real-time communication over WebSocket protocol.

`INDEXER_URL`

Base URL for the indexer API endpoint.

https://api.helius.xyz

Endpoint for fetching indexed blockchain data.

`LOG_LEVEL`

Defines the logging verbosity level in the application.

debug

Controls the amount of runtime information logged; typical values: debug, info, warn, error.

`NETWORK`

Specifies the blockchain network environment.

`mainnet`

Typically `mainnet`, `testnet`, or `devnet`. Determines which blockchain environment is used.

`RPC_URL`

URL for the RPC service endpoint.

https://mainnet.helius-rpc.com

Used for sending RPC requests such as transactions or data queries.

`WS_URL`

WebSocket URL for real-time data and event streams.

wss://mainnet.helius-rpc.com

Endpoint used to establish WebSocket connections for event listening or streaming data.


Usage Example

To use this file in a project:

  1. Copy sample.env to .env:

    cp sample.env .env
    
  2. Fill in the secret API keys with your actual credentials:

    INDEXER_API_KEY=your_indexer_api_key_here
    RPC_API_KEY=your_rpc_api_key_here
    WS_API_KEY=your_ws_api_key_here
    
  3. Ensure your application loads environment variables from the .env file, commonly via packages like dotenv in Node.js or similar tools in other ecosystems.


Implementation Details and Considerations


Interaction with Other Parts of the System

This file is foundational for the application's configuration layer. It interacts primarily through:

Because environment variables are loaded at application startup, changes to this file require a restart to take effect.


Visual Diagram

The following flowchart illustrates how the environment variables defined in `sample.env` influence various components in the system:

flowchart TD
    ENV[sample.env (Environment Variables)]
    CONFIG[Configuration Loader]
    INDEXER_API[Indexer API Module]
    RPC_CLIENT[RPC Client Module]
    WS_CLIENT[WebSocket Client Module]
    LOGGER[Logger Module]
    NETWORK_CFG[Network Configuration Module]

    ENV --> CONFIG
    CONFIG --> INDEXER_API
    CONFIG --> RPC_CLIENT
    CONFIG --> WS_CLIENT
    CONFIG --> LOGGER
    CONFIG --> NETWORK_CFG

    subgraph External Services
        INDEXER_API -->|Uses INDEXER_URL & API_KEY| INDEXER[Indexer Service]
        RPC_CLIENT -->|Uses RPC_URL & API_KEY| RPC[RPC Service]
        WS_CLIENT -->|Uses WS_URL & API_KEY| WS[WebSocket Service]
    end

Summary