sample.env
Overview
The `sample.env` file is a configuration environment file used to define and store endpoint URLs for accessing various Thorchain daemon services in a development environment. It primarily provides connection strings for different API endpoints related to Thorchain nodes, including RESTful LCD (Light Client Daemon) endpoints, RPC (Remote Procedure Call) endpoints, and WebSocket endpoints. This file serves as a centralized place to manage environment-specific URLs for Thorchain services, enabling other parts of the system to dynamically load and use these URLs for network communication.
Purpose and Functionality
Purpose: To provide environment variables that specify the network endpoints of Thorchain daemon services in a development environment.
Functionality: Each line exports a key-value pair representing a named URL for a specific service endpoint. These variables are used by applications or scripts to configure network connections without hardcoding URLs in the source code.
Variables Explained
Variable Name | Description | Example Value |
|---|---|---|
`LCD_URL` | URL of the primary Thorchain LCD (Light Client Daemon) REST API endpoint for the dev environment. | |
`LCD_V1_URL` | URL of the Thorchain LCD REST API endpoint for version 1 of the daemon in the dev environment. | |
`RPC_URL` | URL of the primary Thorchain RPC endpoint for the dev environment. | |
`RPC_V1_URL` | URL of the Thorchain RPC endpoint for version 1 of the daemon in the dev environment. | |
`WS_URL` | WebSocket URL for real-time RPC communication with the Thorchain daemon in the dev environment. |
Usage
This file is typically loaded into the environment by tools or scripts before running applications that need to interact with Thorchain services. For example, in a Unix shell, you can load the variables by running:
source sample.env
Then your application or CLI tool can access these URLs via environment variables like `$LCD_URL`, `$RPC_URL`, etc.
Implementation Details
The file follows the standard
.envformat withKEY=VALUEpairs.All URLs point to the development (
dev) environment of Thorchain services hosted by ShapeShift.It includes endpoints for both the current daemon and a legacy version (
v1), allowing backward compatibility or testing across versions.The presence of both RESTful LCD URLs and RPC URLs supports different communication protocols — HTTP for REST APIs and WebSocket/RPC for real-time or synchronous interactions.
Interaction with Other System Components
Client Applications: Use these environment variables to configure API clients that query blockchain data, submit transactions, or listen for events.
Service Connectors: Middleware or adapters that bridge the application logic with external Thorchain nodes rely on these URLs for establishing connections.
Testing and Development Tools: Automated tests or local development environments source this file to simulate interactions with Thorchain daemons without hardcoding endpoints.
Version Management: By specifying
LCD_V1_URLandRPC_V1_URL, the system can switch or compare between different daemon versions, facilitating migration or regression testing.
Diagram
Since this file is a simple environment configuration file defining key URLs, a flowchart illustrating how these variables are used by different components in the system is most appropriate.
flowchart TD
subgraph sample.env
A[LCD_URL]
B[LCD_V1_URL]
C[RPC_URL]
D[RPC_V1_URL]
E[WS_URL]
end
ClientApp1[Client Application] -->|Reads URLs| sample.env
ClientApp2[Client Application (v1 Support)] -->|Reads URLs| sample.env
Middleware[Service Middleware] -->|Uses URLs| sample.env
TestSuite[Testing Framework] -->|Loads URLs| sample.env
A -->|REST API Calls| ThorchainLCD[Thorchain LCD API]
B -->|REST API Calls| ThorchainLCDv1[Thorchain LCD v1 API]
C -->|RPC Calls| ThorchainRPC[Thorchain RPC]
D -->|RPC Calls| ThorchainRPCv1[Thorchain RPC v1]
E -->|WebSocket RPC| ThorchainWS[Thorchain WebSocket RPC]
Summary
The `sample.env` file is a straightforward but essential configuration file that defines service endpoints for Thorchain daemon access in development environments. It enables flexibility and maintainability by externalizing critical URLs, supports multiple versions of the daemon, and facilitates different communication protocols (REST, RPC, WebSocket). This file acts as a foundational piece for connecting various system components to the Thorchain network in a consistent and environment-agnostic manner.