Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to configure API Interface in Ethernet Square

Shulou Source: shulou.com Published: 2022-06-01 02:27:00 10月03日 Update

This article mainly explains the "Ethernet Square API interface configuration", the article explains the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "Ethernet Square API interface configuration" bar!

Ethernet square application development interface refers to the API interface provided by ethernet square node software, which can be used by decentralized applications to access intelligent contracts on ethernet square. The application development interface of Ethernet Square adopts JSON-PRC standard, which is usually provided to the application through HTTP or websocket.

JSON-RPC is a stateless lightweight remote procedure call (RPC) protocol. The specification defines the data structure and the corresponding processing rules, and uses the JSON (RFC 4627) data format. The specification itself is transmission-independent and can be used in in-process communication, socket sockets, HTTP or various message communication environments.

Configuration of ethernet square application development interface

The application development interface access points of different node software may be different. The default JSON-RPC end nodes of common ethernet square node software are as follows:

Geth-http://localhost:8545

Parity-http://localhost:8545

Pytheapp-http://localhost:4000

Take the most common geth node software as an example, you can use the-- rpc option to launch its HTTP-based JSON-RPC application development interface.

~ $geth-- rpc

You can use the-- rpcaddr and-- rpcport options to modify the default listening port (8545) and listening address (localhost):

~ $geth-rpc-rpcaddr-rpcport

If you need to access the RPC interface from the browser, you need to set the CORS correctly, otherwise the javascript call will fail due to the restriction of the same origin policy:

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

You can also use the admin.startRPC (addr,port) command in the geth console to start JSON RPC.

The call of ethernet square application development interface

Using the standard HTTP protocol, you can call the ethernet square API, 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:8545

You can click here to view the ethernet square application development interface manual in Chinese.

Encapsulation development package of ethernet square application development interface

In order to facilitate the invocation of ethernet square application development interfaces in code in different languages, development packages in different languages have emerged in the etherfang community, such as:

Javascript:Web3.js

Php:Web3.php

Python:Web3.py

Java:Web3j

C#:Nethereum

According to your needs, you can choose the appropriate development package to call the ethernet square application development interface, which can greatly shorten the time required to dock ethernet square nodes.

Thank you for reading, the above is the content of "how to configure the API interface in Ethernet Square". After the study of this article, I believe you have a deeper understanding of how to configure the API interface in Ethernet Square, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Interfaces Ethernet development application application development configuration nodes software differences development packages learning content commands common data standards languages monitoring communication appropriate Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn OPPO Reno Shulou Technology MySQL Apple