7 Web3 and a channel Dapp
This chapter covers
· Web3 API for accessing Ethereum client node functions
· Programming with web3 modules and web3 provider
· Designing a Dapp with a channel, an off-chain feature
· Implementing a micropayment channel for a global cleanup problem
· Connecting off-chain operations with on-chain operations
The focus of this chapter is on web3. Using web3, you can pretty much set your Dapp on auto-pilot. If so, what is web3? Web3 API, simply called web3, is a comprehensive package for accessing blockchain functions. Blockchain infrastructure provides services for account management, recording of transactions (Txs), and smart contract execution, all of which you explored in previous chapters. Web3 exposes the functions of the Ethereum blockchain client node; it facilitates the interaction of external applications and the blockchain node. Web3 API facilitates programs to access blockchain services. You’ve been using web3 in Dapp application development in earlier chapters, where web3 usage was discussed at a high level. In chapter 4, you used web3.js in the Dapp development as part of the glue code (app.js) between the web application and the smart contract and included web3 (the minified version in web3.js.min) in the Dapp.
Definition
web3.js is a JavaScript library—commonly referred to as web3—that enables applications to access the services offered by the Ethereum blockchain client node.