config.json
Overview
The `config.json` file serves as the primary configuration resource for a blockchain-related software module, likely a node or service interacting with the Base (Ethereum-based) network. It specifies critical runtime parameters, including fiat currency exchange rate sources, blockchain node connection details, mempool transaction handling, and other operational settings.
This configuration drives how the application interfaces with external services (e.g., CoinGecko for exchange rates), communicates with the blockchain node via RPC, and manages internal processing such as mempool transaction timeouts and worker concurrency.
Detailed Explanation of Configuration Fields
Since `config.json` is a JSON configuration file without classes or functions, the documentation focuses on the purpose and use of each key/value pair:
Key | Type | Description | Example / Notes |
|---|---|---|---|
`fiat_rates` | string | Defines the service or provider used for fetching fiat currency exchange rates. In this file, ["coingecko"](/projects/291/69194) indicates that the CoinGecko API is the source. | |
`fiat_rates_vs_currencies` | string | A comma-separated list of fiat and cryptocurrency symbols for which exchange rates are to be fetched relative to the base currency. | `"AED,ARS,AUD,...,BTC,ETH"` includes many fiat currencies plus Bitcoin and Ethereum. |
`fiat_rates_params` | string (JSON encoded) | Contains parameters for the fiat rate fetching API, including API endpoint URL, coin identifier, platform, currency, and refresh period in seconds. | `"{\"url\": \"https://api.coingecko.com/api/v3\", \"coin\": \"ethereum\", \"platformIdentifier\": \"ethereum\", \"platformVsCurrency \": \"eth\", \"periodSeconds\": 900}"` |
`mempoolTxTimeoutHours` | integer | Defines how long (in hours) a transaction stays in the mempool before timing out. This helps in cleaning stale transactions from memory pools. | `24` (hours) |
boolean | Indicates whether to query the backend system when resynchronizing the mempool. This can be used to ensure consistency but may increase load. | `false` | |
`coin_name` | string | The full name of the blockchain coin or token that this configuration targets. | |
`coin_shortcut` | string | The ticker symbol or shorthand for the coin. | `"ETH"` |
`coin_label` | string | A label used within the application to identify the coin. | |
`rpc_url` | string | The WebSocket URL endpoint for connecting to the blockchain node's RPC interface. | `"ws://localhost:8546"` |
`rpc_user` | string | Username for RPC authentication (empty if not needed). | `""` (empty) |
`rpc_pass` | string | Password for RPC authentication (empty if not needed). | `""` (empty) |
`rpc_timeout` | integer | Timeout duration (in seconds) for RPC calls to the blockchain node. | `25` (seconds) |
`parse` | boolean | Indicates whether to parse transaction data and blocks. Parsing enables more detailed analysis but potentially requires more resources. | `true` |
`message_queue_binding` | string | Configuration related to message queue bindings, possibly for event or data streaming systems. Empty if not configured. | `""` (empty) |
`subversion` | string | String to identify the client subversion or build version. Empty if not set. | `""` (empty) |
string | Specifies the address format used by the application (e.g., legacy, bech32). Empty if default or unspecified. | `""` (empty) | |
`mempool_workers` | integer | Number of worker threads/processes dedicated to mempool transaction processing. This affects concurrency and performance. | `8` |
`mempool_sub_workers` | integer | Number of sub-workers for mempool processing, likely a finer granularity for parallelism. | `2` |
`block_addresses_to_keep` | integer | The number of blocks for which address data is retained. This might affect how far back address-related information is cached or stored. | `600` |
Usage Examples
Since `config.json` is a static JSON file, its usage is primarily by the application loading this file at startup or runtime to configure its behavior.
Example (pseudo-code):
import json
with open('config.json') as f:
config = json.load(f)
# Connect to blockchain node RPC
rpc = connect_rpc(url=config["rpc_url"], timeout=config["rpc_timeout"])
# Setup fiat rates fetching service
fiat_service = FiatRateService(
provider=config["fiat_rates"],
params=json.loads(config["fiat_rates_params"]),
currencies=config["fiat_rates_vs_currencies"].split(',')
)
# Configure mempool workers
mempool_manager = MempoolManager(
workers=config["mempool_workers"],
sub_workers=config["mempool_sub_workers"],
tx_timeout=config["mempoolTxTimeoutHours"]
)
# Further initialization...
Important Implementation Details and Observations
Fiat Rates Parameters:
Thefiat_rates_paramsvalue is itself a JSON string, which must be parsed before use. This nested JSON contains API endpoint and coin/platform identifiers used to customize the exchange rate queries.Potential Typo in Key:
The key"platformVsCurrency "insidefiat_rates_paramshas an extra trailing space. This might cause issues when parsing or accessing this parameter programmatically.Concurrency Settings:
mempool_workersandmempool_sub_workersindicate that the system employs a multi-threaded or multi-process approach to handle mempool transactions efficiently.RPC Connection:
The file uses a WebSocket RPC URL (ws://localhost:8546), typical for Ethereum-based nodes, enabling real-time event subscriptions and communication.Address Data Retention:
block_addresses_to_keepsuggests a caching or retention strategy for address-related data, possibly to optimize block and transaction lookups or analytics.
Interaction with Other System Components
Blockchain Node (RPC Server):
Therpc_url,rpc_user,rpc_pass, andrpc_timeoutconfigure connectivity to the blockchain node. This file enables the application to communicate with the Base blockchain node to retrieve data, send transactions, and subscribe to events.Fiat Rate Provider:
The fiat rate settings connect the application to a third-party API (CoinGecko) to obtain up-to-date exchange rate information. This is important for applications that display or calculate values in multiple currencies.Mempool Processing Module:
Configuration parameters related to mempool workers and transaction timeout guide how the application manages the mempool — the pool of unconfirmed transactions.Message Queue (Optional):
Themessage_queue_bindingfield, though empty here, indicates potential integration with a message queue for event-driven processing or communication between system components.Parsing and Data Management:
Theparseflag controls whether detailed parsing of blockchain data is performed, affecting performance and feature availability.
Visual Diagram
Given that `config.json` is a configuration file without classes or functions, the most appropriate visual is a **flowchart** showing how the main configuration groups relate to key system components:
flowchart TD
A[config.json] --> B[Blockchain Node RPC]
A --> C[Fiat Rates Service]
A --> D[Mempool Processing]
A --> E[Message Queue (optional)]
B -->|Uses rpc_url, rpc_user, rpc_pass, rpc_timeout| F[Blockchain Node]
C -->|Uses fiat_rates, fiat_rates_params, fiat_rates_vs_currencies| G[CoinGecko API]
D -->|Uses mempoolTxTimeoutHours, mempool_workers, mempool_sub_workers| H[Mempool Manager]
E -->|Uses message_queue_binding| I[Message Queue System]
style A fill:#f9f,stroke:#333,stroke-width:2px
style B fill:#bbf,stroke:#333
style C fill:#bbf,stroke:#333
style D fill:#bbf,stroke:#333
style E fill:#bbf,stroke:#333
Summary
`config.json` configures key parameters for:
Connecting to and interacting with a Base/Ethereum blockchain node.
Fetching and managing fiat currency exchange rates.
Managing mempool transaction lifecycle and concurrency.
Optional messaging and blockchain data parsing behaviors.
This file is essential for tailoring the application's runtime behavior to the target blockchain network and external service integrations. Proper setup ensures efficient processing, reliable connectivity, and accurate financial data representation.
**End of `config.json` documentation**