config.json
Overview
`config.json` is a configuration file that defines key parameters and settings for the Avalanche blockchain integration module within the larger software project. This file primarily governs the behavior of blockchain data interfaces such as RPC connections, mempool processing, fiat currency rate sources, and coin metadata. It acts as a centralized source of truth for runtime parameters, enabling the application to adapt its blockchain interaction logic without hardcoding values.
The configurations include API endpoints, credentials (if any), currency conversion settings, mempool worker counts, timeout values, and coin identification details. This file is essential for controlling how the software communicates with Avalanche network nodes and external services (e.g., CoinGecko for fiat rates), how it handles unconfirmed transactions, and how it formats and processes blockchain data.
Detailed Explanation of Configuration Properties
This file consists of JSON key-value pairs, each representing a specific configuration setting. Below are detailed explanations of each property:
Property | Type | Description | Example / Notes |
|---|---|---|---|
`fiat_rates` | String | Specifies the source provider for fiat currency exchange rates. | ["coingecko"](/projects/291/69194) indicates rates are fetched from CoinGecko API. |
`fiat_rates_vs_currencies` | String | Comma-separated list of fiat and crypto currency codes for which conversion rates will be tracked. | `"AED,ARS,AUD,BDT,...,BTC,ETH"` — includes fiat currencies and cryptocurrencies. |
`fiat_rates_params` | String (JSON serialized) | JSON string with parameters to customize the fiat rates API requests. | Includes API URL, coin name, platform identifier, vs currency, and polling period. |
`mempoolTxTimeoutHours` | Number | Time in hours after which unconfirmed transactions in mempool are considered expired and no longer tracked. | `24` means transactions older than 24 hours in mempool will be discarded. |
`queryBackendOnMempoolResync` | Boolean | Flag indicating whether the backend should be queried to resync mempool data upon certain events. | `false` disables such queries, potentially improving performance. |
`coin_name` | String | The full name of the cryptocurrency coin this config targets. | |
`coin_shortcut` | String | The ticker symbol or shorthand for the coin. | `"AVAX"` |
`coin_label` | String | A human-readable label used in UI or logs to identify the coin. | |
`rpc_url` | String | WebSocket URL for connecting to the Avalanche node’s RPC interface. | |
`rpc_user` | String | Username for RPC authentication if required. Empty if no authentication is used. | `""` (empty string) |
`rpc_pass` | String | Password for RPC authentication. Empty if no authentication is used. | `""` (empty string) |
`rpc_timeout` | Number | Timeout (in seconds) for RPC calls before they are considered failed. | `25` |
`parse` | Boolean | Flag to enable or disable parsing of blockchain data fetched via RPC. | `true` enables parsing. |
`message_queue_binding` | String | Configuration string for message queue binding (e.g., RabbitMQ or Kafka). Empty if not used. | `""` |
`subversion` | String | Version string of the software or protocol subversion used in RPC or network communication. | `""` |
`address_format` | String | Specifies the format of blockchain addresses (e.g., bech32, base58). Empty if default or auto-detected. | `""` |
`mempool_workers` | Number | Number of primary worker threads/processes dedicated to mempool transaction processing. | `8` |
`mempool_sub_workers` | Number | Number of sub-workers handling finer-grained mempool tasks under the primary workers. | `2` |
`block_addresses_to_keep` | Number | The count of block addresses to retain in memory or cache for quick reference. | `300` |
Usage Example
This JSON file is loaded by the blockchain integration service at startup to configure its behavior. For example, a JavaScript or Python service might load the config as follows:
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}...`);
// Use config.rpc_timeout, config.mempool_workers, etc. to initialize services
Important Implementation Details
Fiat Rates Integration: The
fiat_rates_paramsis a JSON-encoded string containing parameters for the CoinGecko API. It specifies the polling period (periodSeconds), the coin identifier in CoinGecko (coin), and platform-specific info. This design allows easy extension to other providers by changingfiat_ratesand adjusting parameters. The system likely polls the CoinGecko API every 15 minutes (900 seconds) for current prices.Mempool Management: The mempool-related settings control concurrency (
mempool_workers,mempool_sub_workers) and transaction expiry (mempoolTxTimeoutHours). These parameters help balance performance and resource usage when processing unconfirmed transactions.RPC Connection: The WebSocket RPC URL points to a local Avalanche node. The empty
rpc_userandrpc_passsuggest no authentication is needed, but the fields exist to support authenticated RPCs if required.Address Format: The empty
address_formatimplies the system uses a default or auto-detected format for Avalanche addresses. This flexibility supports multi-format address handling if needed.Message Queue: The empty
message_queue_bindingindicates that message queueing (e.g., for event notifications) is currently disabled or not configured.
Interaction with Other Parts of the System
Blockchain Node Interface: The RPC connection settings (
rpc_url,rpc_user,rpc_pass,rpc_timeout) are used by the blockchain node communication layer to send requests and receive blockchain data.Mempool Processor: The mempool worker counts and timeout control how the mempool processing module manages unconfirmed transactions in memory.
Fiat Rate Service: The fiat rate provider settings enable the exchange rate module to fetch and update currency conversion rates, which downstream components use to display value in fiat terms.
User Interface / Reporting: Coin metadata (
coin_name,coin_shortcut,coin_label) is used to identify the blockchain asset in UI components and reporting modules.Message Queue / Event Notification: If configured, the
message_queue_bindingconnects the blockchain event processor to a messaging system for asynchronous event handling.
Visual Diagram
This file is a structured configuration file (JSON) without classes or functions. The most meaningful visualization is a **flowchart** showing how main configuration groups logically relate and influence subsystems.
flowchart TD
A[config.json] --> B[RPC Settings]
A --> C[Mempool Settings]
A --> D[Fiat Rates Settings]
A --> E[Coin Metadata]
A --> F[Message Queue Settings]
B --> B1[rpc_url]
B --> B2[rpc_user]
B --> B3[rpc_pass]
B --> B4[rpc_timeout]
C --> C1[mempoolTxTimeoutHours]
C --> C2[mempool_workers]
C --> C3[mempool_sub_workers]
C --> C4[queryBackendOnMempoolResync]
D --> D1[fiat_rates]
D --> D2[fiat_rates_vs_currencies]
D --> D3[fiat_rates_params]
E --> E1[coin_name]
E --> E2[coin_shortcut]
E --> E3[coin_label]
E --> E4[address_format]
E --> E5[subversion]
E --> E6[parse]
F --> F1[message_queue_binding]
Summary
`config.json` is a critical configuration file that encapsulates all essential runtime parameters for interacting with the Avalanche blockchain and related services in the system. It provides flexible and centralized control over RPC connections, mempool processing, fiat currency conversions, and coin metadata. Proper tuning of this file ensures optimized blockchain data ingestion, accurate currency conversion display, and efficient mempool management, ultimately supporting reliable and scalable blockchain application functionality.