December 2018
Beginner to intermediate
564 pages
17h 34m
English
web3.js can communicate with nodes using HTTP or IPC. We will use HTTP to set up communication with nodes. web3.js allows us to establish connections with multiple nodes. An instance of web3 represents a connection with a node. The instance exposes the APIs.
When an app is running inside Mist, it automatically makes an instance of web3 available that's connected to the mist node. The variable name of the instance is web3.
Here is the basic code to connect to a node:
if (typeof web3 !== 'undefined') { web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545")); }
At first, we check here whether the code is running inside mist by checking whether web3 is undefined or not. If web3 is defined, then we use the ...
Read now
Unlock full access