config.json
Overview
`config.json` is a configuration file that defines key runtime parameters and settings for a blockchain-related service or daemon, specifically tailored for the Optimism network (an Ethereum Layer 2 scaling solution). It primarily configures how the application connects to Ethereum-based nodes, handles fiat currency exchange rates, manages mempool transaction processing, and other operational settings.
The file is structured in JSON format and provides static configuration values used by the application during startup or runtime to control behavior such as RPC connections, rate providers, mempool worker counts, and currency settings.
Detailed Explanation of Config Properties
This file does not contain classes or functions since it’s a JSON configuration file. Instead, it consists of key-value pairs that the application reads to configure its environment.
Below is a detailed explanation of the main configuration properties:
Property | Type | Description | Example / Default Value |
|---|---|---|---|
`fiat_rates` | String | Specifies the source provider for fiat currency exchange rates. Here, ["coingecko"](/projects/291/69194) indicates the app uses the CoinGecko API for fiat rates. | |
`fiat_rates_vs_currencies` | String | Comma-separated list of currency codes (ISO 4217 and cryptocurrencies) against which fiat rates are fetched. Includes fiat (USD, EUR, etc.) and cryptos (BTC, ETH). | `"AED,ARS,AUD,BDT,BHD,BMD,BRL,CAD,CHF,CLP,CNY,CZK,DKK,EUR,GBP,HKD,HUF,IDR,ILS,INR,JPY,KRW,KWD,LKR,MMK,MXN,MYR,NGN,NOK,NZD,PHP,PKR,PLN,RUB,SAR,SEK,SGD,THB,TRY,TWD,UAH,USD,VEF,VND,ZAR,BTC,ETH"` |
`fiat_rates_params` | String | JSON string containing additional parameters for the fiat rates provider including API base URL, coin to track, platform identifier, and update period in seconds. | |
Number | Number of hours after which a transaction in the mempool is considered timed out and cleaned up. | `24` | |
Boolean | Determines if the backend should be queried again when mempool resynchronization occurs. | `false` | |
`coin_name` | String | Full name of the coin or blockchain network configured. | |
`coin_shortcut` | String | Abbreviation or ticker symbol for the coin. | `"ETH"` |
`coin_label` | String | Label used in UI or logs to represent the coin. | |
`rpc_url` | String | WebSocket URL of the Ethereum RPC node the application connects to for blockchain data. | `"ws://localhost:8546"` |
`rpc_user` | String | Username for authenticating RPC requests (if needed). Empty if no authentication is required. | `""` |
`rpc_pass` | String | Password for authenticating RPC requests (if needed). Empty if no authentication is required. | `""` |
`rpc_timeout` | Number | Timeout (in seconds) for the RPC calls to the Ethereum node. | `25` |
`parse` | Boolean | Flag to enable or disable parsing of blockchain data. | `true` |
`message_queue_binding` | String | Defines the message queue binding topic or exchange. Empty if not used. | `""` |
`subversion` | String | Version string or identifier for a subversion of the node or service. Empty if not specified. | `""` |
String | Format specification for blockchain addresses. Empty if default or unspecified. | `""` | |
`mempool_workers` | Number | Number of concurrent workers dedicated to processing mempool transactions. | `8` |
`mempool_sub_workers` | Number | Number of sub-workers (threads or processes) under each mempool worker. | `2` |
Number | Number of block addresses to retain for historical or processing purposes. | `300` |
Important Implementation Details
Fiat Rates Integration:
The application uses an external API (CoinGecko) to fetch current fiat currency rates against numerous fiat and crypto currencies. Thefiat_rates_paramsJSON string provides the necessary API endpoint and parameters to customize these queries. This allows the application to update currency conversions approximately every 15 minutes (900 seconds).Mempool Management:
The mempool transaction timeout setting (mempoolTxTimeoutHours) ensures stale transactions are pruned after 24 hours to prevent memory bloat. The use of multiple workers and sub-workers (mempool_workersandmempool_sub_workers) indicates a parallelized approach to mempool transaction processing for better throughput and responsiveness.RPC Connectivity:
The RPC connection uses WebSocket protocol connecting locally (ws://localhost:8546), which is typical for Ethereum nodes exposing WebSocket endpoints. Authentication parameters are left blank, suggesting either no authentication or it is configured elsewhere securely.Parsing Flag:
Theparseflag likely controls whether incoming blockchain data should be transformed or analyzed further by the application or just stored as-is.Modularity and Extensibility:
Many empty or defaulted fields (message_queue_binding,subversion, address_format) imply that this configuration can be extended or overridden based on environment or deployment needs.
Interaction With Other System Components
Blockchain Node (Ethereum RPC):
Therpc_url,rpc_user, andrpc_passparameters configure connectivity to the Ethereum-compatible node. This enables the system to receive blockchain data, listen to new blocks, and submit queries.Fiat Rate Service (External API):
The CoinGecko API URL and parameters connect the application to external financial data, enabling it to display or record values in various fiat currencies.Mempool Processing Subsystem:
Settings related to mempool workers configure internal concurrent processing modules responsible for managing unconfirmed transactions, resyncing, and pruning.Message Queue (Potentially):
Although currently empty, themessage_queue_bindingsuggests potential integration with messaging systems (e.g., RabbitMQ, Kafka) for asynchronous communication or event-driven architecture.UI or Reporting Components:
The coin name, label, and shortcut are likely used in user interface components or logs to identify the current blockchain network context.
Usage Example
Since this is a static JSON configuration, it is typically loaded by the application at startup. For example, in a Node.js environment:
const fs = require('fs');
const config = JSON.parse(fs.readFileSync('config.json', 'utf8'));
console.log(`Connecting to ${config.coin_name} node at ${config.rpc_url}`);
console.log(`Using fiat rates provider: ${config.fiat_rates}`);
This configuration file can be customized per deployment by changing values such as RPC endpoints, coin names, or worker counts without modifying the application code.
Visual Diagram: Configuration Structure Flowchart
The following Mermaid flowchart illustrates how the main configuration groups relate and their roles within the system:
flowchart TD
A[config.json]
A --> B[Fiat Rates Configuration]
B --> B1[Provider: coingecko]
B --> B2[Currency List]
B --> B3[API Params]
A --> C[Blockchain Node RPC]
C --> C1[RPC URL]
C --> C2[RPC Auth]
C --> C3[RPC Timeout]
A --> D[Mempool Settings]
D --> D1[Timeout Hours]
D --> D2[Workers & Sub-workers]
D --> D3[Resync Query Flag]
A --> E[Coin Info]
E --> E1[Coin Name]
E --> E2[Shortcut]
E --> E3[Label]
A --> F[Miscellaneous]
F --> F1[Parse Flag]
F --> F2[Message Queue Binding]
F --> F3[Subversion]
F --> F4[Address Format]
F --> F5[Block Addresses to Keep]
Summary
config.jsonis a pivotal configuration file for a blockchain application focused on the Optimism network.It configures RPC connection details, fiat currency rate providers, mempool transaction handling, and coin metadata.
The file allows flexible customization for different environments and deployment scenarios.
Its parameters enable integration with external APIs, concurrency control, and operational tuning.
The simple JSON format ensures ease of use, modification, and integration into the software’s initialization process.
This file acts as the foundational configuration cornerstone, influencing how the system connects, processes, and presents blockchain data.