getrawtransaction
retrieves raw or decoded Bitcoin transaction data bytxid
, optionally with a specific block hash.- Verbose mode (
true
) returns a detailed JSON, while omitting it yields the raw hex string. - Transactions typically remain in the mempool for around 14 days; dropped transactions require resubmission with adequate fees.
- Bitcoin Core runs many operations single-threaded, so complex or parallel requests may slow under heavy load.
Main article
In Web3 and blockchain, we get a new chain or a new RPC provider almost daily, and the ability to interact with multiple blockchain networks through RPC endpoints is crucial for developers, applications, and services. The Multi-Endpoint Shared Configuration (MESC) emerges as a pivotal standard in this ecosystem, addressing the pain points of configuring and managing RPC endpoints across diverse tools and platforms. MESC introduces a standard for configuring RPC endpoints in DApps, emphasizing the ease of sharing configuration data and managing many endpoints. It focuses on making RPC configuration sharing across tools, languages, and environments straightforward, alongside simplifying the management of numerous RPC endpoints. This guide will teach us how to use the MESC CLI using Chainstack endpoints.Key components of MESC
MESC represents a significant leap toward simplifying the complexities developers face daily. Let’s get into the core aspects that make MESC an indispensable tool for developers navigating the Web3 space.Typical usage scenario
Consider a decentralized voting application,VoteChain
, designed to operate across multiple blockchain networks. This application needs to interact with different RPC endpoints to submit votes or query vote counts. The traditional method requires hardcoding or manually specifying the RPC URL for each network, which is error-prone and cumbersome, especially when aiming to support numerous networks.
Common interface
One of MESC’s standout features is its common interface, implemented across different programming languages and platforms. This uniformity allows developers to interact with the MESC configuration seamlessly, regardless of their development environment. Whether it’s Python, Rust, or any other supported language, the interface remains consistent, ensuring developers can easily switch between tools and languages without relearning how to access and manage their RPC configurations.MESC specifications
MESC employs a detailed schema to encapsulate all necessary information for RPC configurations, comprising three key-value data schemas:RpcConfig
, Endpoint
, and Profile
. Each schema is meticulously designed to cover all aspects of RPC configuration, from global settings to specific endpoint details and user profiles.
- RpcConfig schema: The backbone of MESC, detailing the version, default endpoints, and default networks, mapping chain IDs to endpoint names, network names to chain IDs, and specific endpoint configurations. It also includes profiles for user-specific settings and global metadata for additional information.
- Endpoint schema: Specifies individual RPC endpoints, including their names, URLs, associated chain IDs, and any metadata related to the endpoint. This schema ensures each endpoint is uniquely identifiable and adequately linked to its network.
- Profile schema: Users can define custom configurations, including a default endpoint, network defaults, and profile-specific metadata. Enabling or disabling MESC for specific profiles allows users to manage their RPC connections.
RpcConfig
and Endpoint
schemas are mandatory, with no allowance for unspecified keys except within metadata sections. It mandates that endpoint names referenced in the configuration must correspond to actual endpoints defined within the schema, ensuring referential integrity.
Find the full spefications in the MESC repository.
MESC’s role in simplifying configurations
By leveraging MESC,VoteChain
can dynamically select the appropriate RPC endpoint based on user input or application context, such as the specific blockchain network for casting votes. This is made possible through MESC’s ability to interpret various forms of identifiers:
- Direct URL: For direct access to a specific RPC endpoint.
- Network name: Specify the blockchain network using familiar names.
- Chain ID: Enabling selection based on the unique identifier of the blockchain.
- Custom profile: Supporting configurations for various deployment scenarios or user preferences.
VoteChain
to be highly adaptable and user-friendly, significantly reducing the barrier to entry for users unfamiliar with the specific details of blockchain networks.
Hypothetical implementation
To bring this scenario to life, imagineVoteChain
incorporates a feature allowing users to select the blockchain network for their voting campaign directly from the application interface. Behind the scenes, VoteChain
uses MESC to manage and resolve the appropriate RPC endpoints:
For user-friendly network selection: Users can choose a network by name through the VoteChain
interface. The application then queries the MESC configuration to retrieve the corresponding RPC URL, ensuring seamless interaction with the chosen network.
Pseudo code example
Get started with the MESC CLI
Now that we understand MESC well and what it’s trying to solve, let’s learn how to use the MESC CLI.Prerequisites
Before we install the MESC CLI, ensuring your development environment is properly set up is essential. The MESC CLI is developed in Rust; having Rust and Cargo (the Rust package manager) installed on your system is a prerequisite. To install Rust and Cargo, execute the following command in your terminal:Get Chainstack endpoints
To configure the MESC CLI you’ll also need some endpoints. Follow these steps to get them from Chainstack; remember, you can use any EVM-compatible endpoint.Instal the MESC CLI
With Rust and Cargo ready, installing the MESC CLI is straightforward. Use Cargo to install the MESC CLI with the following command:For additional installation methods and further information, consult the MESC User Guide.
Understand mesc.json
configuration
After installing the MESC CLI, the next step is configuring your MESC environment. This is where mesc.json
comes into play. mesc.json
is a JSON-formatted configuration file MESC utilizes to manage your RPC endpoints. It is the central repository for all your endpoint configurations, including the default endpoint, network-specific defaults, and any custom profiles you may need for different projects or environments.
The mesc.json
file is structured to include vital details such as the version of MESC being used (mesc_version
), a list of RPC endpoints (endpoints
), and mappings for network defaults (network_defaults
) and network names (network_names
). This structured approach allows for a high degree of flexibility and control over how your applications interact with blockchain networks.
Create mesc.json
There are a few ways to manage the mesc.json
file. The first method we’ll explore is creating one directly from the MESC CLI.
Open a terminal on your system and run:
1) File (recommended)
and follow the instructions to add your endpoints and create mesc.json
.
Here is how the process will look like in the console:
mesc.json
file, which is saved by default in the root user directory. Additionally, it automatically sets the MESC_PATH
environment variable in both .bashrc
and .profile
.
.bashrc
and .profile
are shell scripts for configuring user environment variables and settings.mesc.json
file created will look like this:
Edit mesc.json
We have a basic MESC configuration file; let’s customize it a bit, adding default networks and default endpoints. In this example, I created the file with two Chainstack endpoints, Ethereum mainnet and Avalanche mainnet. Let’s assume I want to default to Ethereum; we can configure the file as follows:
Learn more about the MESC configuration and metadata options in the MESC User Guide
MESC CLI: Overview of basic commands
Let’s get into the essentials with the MESC CLI. Starting withmesc --help
, you’ll uncover a comprehensive list of commands and their structure alongside valuable help topics for an in-depth understanding of specific commands or steps.
If the
MESC_PATH
environment variable isn’t correctly configured, you might encounter issues. Use mesc help setup
for guidance on proper setup. In case you’ve stored the mesc.json
file in its default location, setting the environment variable is straightforward:ShellExplore available endpoints
Use themesc ls
command to display a detailed list of available endpoints. This command also serves as a quick check to ensure MESC is correctly set up, indicating any setup errors directly:
mesc endpoint
command to print the full info about endpoints.
Verify endpoint connectivity
To test the connectivity and performance of the endpoints, use themesc ping
command. This command not only verifies the operational status of each endpoint but also provides metrics such as latency and the latest block number:
Send requests using MESC
At this point, MESC is fully set up, and we can start using it to send RPC requests. The most straightforward way to test and explore its features is by sending cURL requests. The power of MESC lies in the, as we discussed earlier, MESC allows us to access endpoints intuitively like Endpoint Name or Network Name. This is the structure to send a basic cURL request:$(mesc url)
will use the default endpoint, in our case eth_chainstack
, let’s fetch the chain ID, for instance:
1
. To use the Avalanche endpoint, simply add its name to the command:
You can use the Chainstack EVM-Knife to convert hexadecimal values to decimal.
0xa86a
is 43114
as decimal, which is Avalanche chain ID.Check out the MESC User Guidefor more information.