Learning the fundamentals of web3.js – the Ethereum JavaScript API
web3.js is a collection of Ethereum JavaScript APIs that enable you to develop clients to interact with the Ethereum blockchain. This lets you read and write data to and from the Ethereum blockchain with smart contacts. Web3 provides interactions with Ethereum nodes (be they local or remote) via HTTP, IPC, or WebSocket. web3.js is used to interact with an Ethereum node (Geth node) using JSON-RPC to read and write data to the network. We can install the web3.js library with Node Package Manager (npm).
In the following subsection, we’ll discuss the web3.js basics and see how to start using web3.js to interact with the Ethereum blockchain. web3.js can be used both in frontends and backends. To simplify our work, we will run the web3.js API from the command line and will cover some popular web3.js APIs.
web3.js project setup
To begin working with web3.js, we need to set up a project that includes...