First, we use to check the balance by calling web3, eth, getBalance (), which accepts a callback function with two. To connect to an Ethereum node with JSON RPC on the core network, we need access to an Ethereum node. There are several ways to do this. On the one hand, you can run your own Ethereum node with Geth or Parity.
But this requires you to download a lot of data from the blockchain and keep it in sync. This is a big headache if you've ever tried to do this before. This is the second video in the 8-part tutorial series. In this video, I'll show you how to read smart contract data from The Ethereum Blockchain.
The reason we're going to use this library is that we want to sign all transactions locally. If we had our own Ethereum node locally, we could unlock an account that was stored locally and sign all of our transactions locally. If that were the case, we wouldn't necessarily need to use this library. However, we are going to use a remote node hosted by Infura in this tutorial.
While Infura is a reliable service, we still want to sign transactions locally instead of giving the remote node the management of our private keys. These steps are the same because every time we write data to the blockchain, they always consist of these same basic steps. I'm trying to show them that implementing a smart contact actually feels a lot like sending Ether from one account to another, or calling a smart contract function. We are still creating a transaction and sending it to the network.
The only difference is the parameters of the transaction. We will continue to use an ERC-20 smart contract as a reference point for this tutorial because this standard specifies that the smart contract must issue a transfer event every time an ERC-20 token is transferred. In fact, we will connect to the Ethereum mainnet to subscribe to the Transfer event for the OmiseGO ERC-20 token. Open your favorite code editor (I use Visual Studio Code) with the project folder we created.
This provider will be injected into the browser if you are using web3 on the front end or an object that you are going to create yourself using websocketprovider or IPCProvider. If you're working in the browser, some wallets directly inject a web3 instance and you should try to use it whenever possible, especially if you plan to interact with the user's Ethereum address to make transactions.