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.

"Avalanche"

`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.

"Avalanche"

`rpc_url`

String

WebSocket URL for connecting to the Avalanche node’s RPC interface.

"ws://localhost:9650/ext/bc/C/ws"

`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


Interaction with Other Parts of the System


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.