sample.env
Overview
The `sample.env` file is a configuration environment file designed to store key endpoint URLs required for connecting to Thorchain's development network services. This file provides a centralized place to define URLs for the LCD (Light Client Daemon) API, RPC (Remote Procedure Call) API, and WebSocket RPC endpoint used by client applications or services interacting with Thorchain nodes in a development environment.
By externalizing these URLs into an environment file, the system ensures that the connection endpoints can be easily modified or replaced without changing the application code, thus supporting flexible deployment and testing.
File Content Explanation
The file contains the following environment variables:
Variable | Description | Example Value |
|---|---|---|
`LCD_URL` | The HTTPS endpoint for the Thorchain Light Client Daemon (LCD) REST API | |
`RPC_URL` | The HTTPS endpoint for the Thorchain RPC API | |
`WS_URL` | The WebSocket Secure (wss) endpoint for the Thorchain RPC API supporting real-time events |
Environment Variable Details
LCD_URL:
The LCD endpoint provides RESTful API access to query blockchain state and broadcast transactions in a simplified manner. It is typically used by front-end clients or middleware that need to interact with the blockchain without running a full node.RPC_URL:
The RPC endpoint allows clients to communicate with the blockchain node on a lower level, typically used for more advanced queries, submitting transactions, or subscribing to blockchain events.WS_URL:
The WebSocket RPC URL is used to establish real-time, bidirectional communication with the Thorchain node. This is essential for applications that require live updates such as transaction confirmations, block updates, or event subscriptions.
Usage
Applications or services that integrate with Thorchain's development environment can source or load this file to configure their connection endpoints dynamically.
Example (Node.js)
require('dotenv').config({ path: 'sample.env' });
const lcdUrl = process.env.LCD_URL;
const rpcUrl = process.env.RPC_URL;
const wsUrl = process.env.WS_URL;
console.log('Connecting to Thorchain LCD:', lcdUrl);
console.log('Connecting to Thorchain RPC:', rpcUrl);
console.log('Connecting to Thorchain WebSocket RPC:', wsUrl);
Implementation Details
This file uses the standard
.envformat, which is simple key-value pairs separated by=.It is intended to be loaded by environment variable parsers available in many programming languages and frameworks.
The URLs point specifically to development instances (
dev-daemon) of Thorchain nodes hosted by ShapeShift, suitable for testing and development rather than production use.Using environment files like this supports 12-factor app principles by separating configuration from code.
Interaction with the System
This file is a configuration artifact used primarily during the application startup or initialization phase.
It does not contain executable code but is consumed by various components such as:
API clients that communicate with the Thorchain blockchain.
Middleware layers responsible for blockchain data access.
Front-end or back-end services that need to connect to Thorchain nodes.
Changing any URL in this file will redirect all network calls to the specified endpoints without requiring code changes or recompilation.
Visual Diagram
Below is a flowchart representing how this environment file's variables are consumed by different components in the system:
flowchart TD
A[sample.env] --> B[Application Startup]
B --> C[Load Environment Variables]
C --> D[Blockchain Client Module]
D --> E[LCD API Client]
D --> F[RPC API Client]
D --> G[WebSocket Client]
subgraph Thorchain Network Endpoints
E --> H[LCD_URL]
F --> I[RPC_URL]
G --> J[WS_URL]
end
Summary
sample.envis a simple environment configuration file for defining endpoint URLs to Thorchain's development daemon services.It provides three variables:
LCD_URL,RPC_URL, andWS_URL, each pointing to different access protocols for the blockchain node.This file is essential for configuring clients and services to connect to the correct Thorchain network endpoints dynamically and safely.
It supports best practices by separating configuration from code and facilitates easy switching between development, staging, or production environments.