config.json


Overview

The `config.json` file is a configuration file used to define runtime parameters and operational settings for a Polygon (MATIC) blockchain node or related service component. It primarily configures how the system interacts with external data sources (e.g., fiat currency exchange rates), blockchain RPC endpoints, mempool transaction handling, and coin metadata.

This file does **not** contain executable code but serves as a structured JSON-based configuration that other system components consume at startup or runtime to tailor behavior according to the specified parameters.


Detailed Explanation of Configuration Fields

Field Name

Type

Description

Example Value

`fiat_rates`

string

Specifies the source/provider of fiat currency exchange rates.

"coingecko"

`fiat_rates_params`

string (JSON)

JSON string specifying parameters related to the fiat rates API, including URL, coin to fetch rates for, platform info, and polling period in seconds.

"{\"url\": \"https://api.coingecko.com/api/v3\", \"coin\": \"matic-network\",\"platformIdentifier\": \"polygon-pos\",\"platformVsCurrency\": \"usd\",\"periodSeconds\": 900}"

`fiat_rates_vs_currencies`

string

Comma-separated list of fiat and crypto currency codes against which the base coin exchange rates will be fetched.

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

`mempoolTxTimeoutHours`

integer

Number of hours after which unconfirmed mempool transactions are considered timed out and may be dropped or re-processed.

`48`

`queryBackendOnMempoolResync`

boolean

Flag determining if the backend database should be queried when resyncing the mempool.

`false`

`coin_name`

string

Full name of the cryptocurrency (used for display purposes).

"Polygon"

`coin_shortcut`

string

Short ticker symbol of the cryptocurrency.

`"MATIC"`

`coin_label`

string

Label or display name for the coin, often matching `coin_name`.

"Polygon"

`rpc_url`

string

RPC endpoint URL used to connect with the blockchain node (supports WebSocket in this example).

`"ws://localhost:8546"`

`rpc_user`

string

Username for RPC authentication (empty if no authentication is required).

`""`

`rpc_pass`

string

Password for RPC authentication (empty if no authentication is required).

`""`

`rpc_timeout`

integer

Timeout in seconds for RPC calls to the blockchain node.

`25`

`parse`

boolean

Flag indicating whether to parse incoming data (e.g., transaction or block data).

`true`

`message_queue_binding`

string

Binding key or identifier for message queue integration (empty if not used).

`""`

`subversion`

string

Subversion or client version string (empty if not specified).

`""`

`address_format`

string

Format specification for blockchain addresses (empty if default is used).

`""`

`mempool_workers`

integer

Number of worker threads or processes handling mempool transactions.

`8`

`mempool_sub_workers`

integer

Number of sub-worker threads/processes under each mempool worker.

`2`

`block_addresses_to_keep`

integer

Number of block addresses to retain in memory/cache for quicker access or history.

`300`


Usage Example

This file is usually loaded by the blockchain node service or a related component at startup. Here is a pseudocode example of how this configuration might be used in a Node.js service:

const fs = require('fs');

const config = JSON.parse(fs.readFileSync('config.json', 'utf-8'));

// Connect to RPC endpoint
const rpcClient = new RpcClient({
  url: config.rpc_url,
  user: config.rpc_user,
  pass: config.rpc_pass,
  timeout: config.rpc_timeout,
});

// Setup fiat rates polling
const fiatParams = JSON.parse(config.fiat_rates_params);
const fiatRatesProvider = new FiatRatesProvider(config.fiat_rates, fiatParams, config.fiat_rates_vs_currencies);

// Initialize mempool workers
const mempoolManager = new MempoolManager(config.mempool_workers, config.mempool_sub_workers, config.mempoolTxTimeoutHours);

// Other logic...

Important Implementation Details


Interaction With Other System Components


Visual Diagram: Configuration Structure Flowchart

flowchart TD
    A[config.json] --> B[Fiat Rates Config]
    A --> C[Mempool Config]
    A --> D[RPC Config]
    A --> E[Coin Metadata]
    A --> F[Misc Settings]

    B --> B1["fiat_rates"]
    B --> B2["fiat_rates_params"]
    B --> B3["fiat_rates_vs_currencies"]

    C --> C1["mempoolTxTimeoutHours"]
    C --> C2["queryBackendOnMempoolResync"]
    C --> C3["mempool_workers"]
    C --> C4["mempool_sub_workers"]
    C --> C5["block_addresses_to_keep"]

    D --> D1["rpc_url"]
    D --> D2["rpc_user"]
    D --> D3["rpc_pass"]
    D --> D4["rpc_timeout"]

    E --> E1["coin_name"]
    E --> E2["coin_shortcut"]
    E --> E3["coin_label"]

    F --> F1["parse"]
    F --> F2["message_queue_binding"]
    F --> F3["subversion"]
    F --> F4["address_format"]

Summary

The `config.json` file serves as a centralized configuration hub for the Polygon blockchain node or service, defining essential parameters for fiat rate fetching, RPC connectivity, mempool transaction management, and coin metadata. Proper configuration ensures smooth operation, efficient data processing, and accurate currency conversions within the system. It interacts closely with network communication modules, data parsers, and external APIs, enabling a modular and scalable blockchain infrastructure.