December 2018
Beginner to intermediate
564 pages
17h 34m
English
web3 contains an eth object (web3.eth) specifically for Ethereum blockchain interactions and an shh object (web3.shh) for whisper interaction. Most APIs of web3.js are inside these two objects.
All the APIs are synchronous by default. If you want to make an asynchronous request, you can pass an optional callback as the last parameter to most functions. All callbacks use an error-first callback style.
Some APIs have an alias for asynchronous requests. For example, web3.eth.coinbase() is synchronous, whereas web3.eth.getCoinbase() is asynchronous.
Here is an example:
//sync request try { console.log(web3.eth.getBlock(48)); } catch(e) { console.log(e); } //async request web3.eth.getBlock(48, function(error, result){ if(!error) ...Read now
Unlock full access