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.

"coingecko"

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

{"url": "https://api.coingecko.com/api/v3", "coin": "ethereum", "platformIdentifier": "ethereum", "platformVsCurrency ": "eth", "periodSeconds": 900}

mempoolTxTimeoutHours

Number

Number of hours after which a transaction in the mempool is considered timed out and cleaned up.

`24`

queryBackendOnMempoolResync

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.

"Optimism"

`coin_shortcut`

String

Abbreviation or ticker symbol for the coin.

`"ETH"`

`coin_label`

String

Label used in UI or logs to represent the coin.

"Optimism"

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

`""`

address_format

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`

block_addresses_to_keep

Number

Number of block addresses to retain for historical or processing purposes.

`300`


Important Implementation Details


Interaction With Other System Components


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

This file acts as the foundational configuration cornerstone, influencing how the system connects, processes, and presents blockchain data.