Using WEB3 and Infura to develop Ethernet Ethereum block chain __ block chain

Source: Internet
Author: User
Tags etherscan
web3

github:https://github.com/ethereum/web3.js/
Web3.js is a JavaScript library provided by the Etheric Square, which encapsulates the RPC communication API of Ethernet square, provides a series of interaction methods with block chain, makes JS and Ethernet square Interactive easy. Infura

Official website: https://infura.io/
The local installation of Geth requires more time and space to synchronize chunks, and Infura can be much simpler, Infura provides open Ethernet and test nodes, and can use the API provided by Infura to access the ether and IPFs. Go to the official website only need to provide email registered link can be. using WEB3 and Infura development

The most common operations such as looking at the ether balance of an Ethernet address (similar to Etherscan).

Introduce web3 through NPM or other means, and use Infura to provide the primary/test network for initialization.

XXXX for your application in Infura address
web3 = new Web3 (New Web3.providers.HttpProvider ("https://mainnet.infura.io/xxxxxxxx"));

You can then call the Web3 interface, such as getting a ether number of addresses

Wei is the smallest unit on the etheric square, ether 18 digits after the decimal point for a wei
var balancewei = web3.eth.getBalance (" 0xc257274276a4e539741ca11b590b9447b26a8051 "). Tonumber ();
Convert from Wei to ether
var balance = Web3.fromwei (Balancewei, ' ether ');

This can be done from the main Ethernet network, such as viewing block information, deploying smart contracts, and so on.
Specific development can refer to the ether square JS Api:https://github.com/ethereum/wiki/wiki/javascript-api
Demo Simple Etherscan


Demo Github:https://github.com/wlchn/ethersee

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.