The Ethereum Application Development interface refers to the API interface provided by the Ethereum node software that decentralized applications can use to access smart contracts on Ethereum. The Ethereum application development interface adopts the JSON-PRC standard and is typically provided to application calls via HTTP or WebSocket.

Json-rpc is a stateless lightweight remote procedure call (RPC) protocol. The SPECIFICATION defines the data structure and corresponding processing rules. The specification uses JSON (RFC 4627) data format.

Configuration of ethereum application development interface

The application development interface access points of different node software may be different. The default JSON-RPC endpoint of common Ethereum node software is as follows:

  • Geth – http://localhost:8545
  • Parity – http://localhost:8545
  • Pytheapp – http://localhost:4000

In the case of the most common GETH node software, you can use the -RPC option to launch its HTTP-based JSON-RPC application development interface.

~$ geth --rpc
Copy the code

You can change the default listening port (8545) and listening address (localhost) using the -rpcADDR and -rpcPort options:

~$ geth --rpc --rpcaddr <ip> --rpcport <portnumber>
Copy the code

If you need to access the RPC interface from the browser, you need to set CORS correctly. Otherwise, the javascript call will fail due to the same-origin policy:

~$ geth --rpc --rpccorsdomain "http://localhost:3000"
Copy the code

You can also start JSON RPC from the GEth console using the admin.startrPC (addr,port) command.

Ethereum application development interface call

Using the standard HTTP protocol, you can invoke the Ethereum application development interface. For example, you can use the curl tool on the command line:

~ $curl -x POST -- data '{" jsonrpc ":" 2.0 ", "method" : "web3_clientVersion", "params" : [], "id" : 67}' http://127.0.0.1:8545Copy the code

You can check out the Ethereum API Manual in Chinese here.

Ethereum application development interface package

To facilitate the invocation of the Ethereum API in code in different languages, the Ethereum community has sprung up with development kits in different languages, such as:

  • Javascript: web3.js, tutorial: Getting started with Ethereum Dapp Development
  • PHP: web3.php, tutorial: PHP Ethereum development details
  • Python: web3. py, tutorial: Python Ethereum development details
  • Java: Web3j, tutorial: Web3j Ethereum development details
  • C# : Nethereum, tutorial: how to develop ethereum in c#

You can choose the appropriate development package to call the Ethereum API based on your needs, which can greatly reduce the time required to connect to ethereum nodes.