config.json


Overview

The `config.json` file serves as a centralized configuration repository for an Ethereum-based blockchain application. It defines key parameters related to network connectivity, transaction processing, fiat currency exchange rates, and operational behaviors of components such as the mempool and RPC communication. This file primarily configures runtime settings that influence how other modules interact with the Ethereum network, external APIs, and internal services.

The file is structured as a JSON object containing various configuration keys and their associated values. These configurations enable the application to adapt to different environments, optimize performance, and integrate with third-party data sources.


Detailed Explanation of Configuration Parameters

Network and Node Configuration

Parameter

Type

Description

Example

`consensusNodeVersion`

String

URL endpoint to retrieve the Ethereum consensus node's version information via HTTP.

`"http://localhost:3500/eth/v1/node/version"`

`rpc_url`

String

WebSocket URL for connecting to the Ethereum JSON-RPC server for blockchain interactions.

`"ws://localhost:8546"`

`rpc_user`

String

Username for RPC server authentication (if required).

`""` (empty means no authentication)

`rpc_pass`

String

Password for RPC server authentication (if required).

`""`

`rpc_timeout`

Number

Timeout value in seconds for RPC requests to prevent hanging connections.

`25`


Coin and Currency Configuration

Parameter

Type

Description

Example

`coin_name`

String

Full name of the cryptocurrency.

"Ethereum"

`coin_shortcut`

String

Short symbol or ticker of the cryptocurrency.

`"ETH"`

`coin_label`

String

A label identifier for display or logging purposes.

"Ethereum"

`fiat_rates`

String

The source of fiat currency exchange rates. Currently set to use ["coingecko"](/projects/291/69194).

"coingecko"

`fiat_rates_params`

String

JSON string containing parameters for querying fiat rates, such as API URL, coin name, platform, etc.

"{\"url\": \"https://api.coingecko.com/api/v3\", \"coin\": \"ethereum\", ...}"

`fiat_rates_vs_currencies`

String

Comma-separated list of fiat and crypto currencies against which to fetch exchange rates.

`"AED,ARS,AUD,...,BTC,ETH"`


Mempool and Performance Configuration

Parameter

Type

Description

Example

`mempoolTxTimeoutHours`

Number

Number of hours after which unconfirmed transactions in the mempool expire or get dropped.

`24`

`queryBackendOnMempoolResync`

Boolean

Flag indicating whether the backend should be queried during mempool resynchronization.

`false`

`mempool_workers`

Number

Number of worker threads/processes dedicated to mempool transaction processing.

`8`

`mempool_sub_workers`

Number

Number of sub-workers under each mempool worker for finer-grained parallelism.

`2`


Other Operational Parameters

Parameter

Type

Description

Example

`parse`

Boolean

Whether to enable parsing of blockchain data (such as transactions or blocks).

`true`

`message_queue_binding`

String

Configuration string for message queue binding (e.g., for RabbitMQ or Kafka).

`""` (empty)

`subversion`

String

Subversion string identifying the client or node version.

`""` (empty)

`address_format`

String

Format to use for addresses, if specific formatting is required (e.g., hex, checksum).

`""` (empty)

`block_addresses_to_keep`

Number

Number of addresses to retain per block for indexing or caching purposes.

`300`


Usage Examples

Since this file is a JSON configuration file, it is typically loaded at application startup by a configuration manager or service. Example usage in a Node.js environment:

const fs = require('fs');
const path = require('path');

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

console.log(`Connecting to Ethereum node at ${config.rpc_url} with timeout ${config.rpc_timeout}s.`);

This configuration object will then be passed to various components such as the RPC client, mempool manager, and fiat rate fetchers to initialize them with the desired parameters.


Important Implementation Details


Interaction with Other System Components


Visual Diagram

flowchart TD
    A[config.json] --> B[RPC Client Module]
    A --> C[Fiat Rate Fetcher]
    A --> D[Mempool Manager]
    A --> E[Address & Block Indexer]
    A --> F[Message Queue Layer]

    B -->|rpc_url, rpc_user, rpc_pass, rpc_timeout| G[Ethereum Node]
    C -->|fiat_rates, fiat_rates_params, fiat_rates_vs_currencies| H[CoinGecko API]
    D -->|mempoolTxTimeoutHours, mempool_workers, mempool_sub_workers| I[Mempool Processing Threads]
    E -->|block_addresses_to_keep, address_format| J[Address Cache]
    F -->|message_queue_binding| K[Message Broker]

    style A fill:#f9f,stroke:#333,stroke-width:2px

Summary

The `config.json` file is a critical configuration asset that governs how the Ethereum-related components of the application operate and interact with external services. It provides flexibility to change endpoints, tune performance, and connect with third-party APIs without altering the codebase. Understanding and maintaining this file is essential for deploying the application in various environments and ensuring smooth interoperability among its components.