Focus mode
In web3, after building our smart contracts frontend integration is required to make them interact with users like in web2.
To develop a web application that can interact with a smart contract, we need 2 things about that smart contract:
When smart contracts we build in Solidity or Vyper are compiled, they give bytecode (binary data) and ABI (application binary interface) files as output.
Bytecode is the format of our contract that can be understood by EVM. Smart contracts are stored in EVM in bytecode format.
The ABI file can be thought of as a file describing how to communicate with the bytecode stored in the EVM. Web3.js and ethers.js libraries read the ABI file and understand how to communicate with the smart contract, so Web3.js library or ethers.js library acts as a bridge between contract and web2 languages.
By making use of the ABI file and various libraries, front-end applications or client programs can be written to enable the users to use the contracts easily.
The most frequently used libraries to develop front-end applications for Solidity smart contracts are ethers.js and Web3.js libraries.
Ethereum network is made up of nodes like other chains, which each contain a copy of the blockchain. These nodes only speak a language called JSON-RPC, which isn’t very human-readable. By using Web3.js or Ether.js libraries you can interact with a convenient and easily readable JavaScript interface, instead of JSON-RPC. They are both great libraries that allow developers to interact with the Ethereum blockchain and you to interact with a local or remote ethereum node using HTTP, IPC or WebSocket.
Modules of web3.js and ether.js libraries
Modules are often used to store functions inside them independently of other components. It increases the readability of the code by separating the pieces of code from each other. For those who are familiar with python or java, you might be familiar with “Classes”, which are analogous to JavaScript modules.
Per web3.js official documentation four modules modules that contain functionality for the ethereum ecosystem:
Similar to web3.js, ethers.js has four modules which make up the API.
Using these modules we can integrate our smart contracts to a regular frontend which builded using Html, css or JavaScript(Also JavaScript backgrounded frontend programming languages like).
Resources:
https://medium.com/coinmonks/solidity-and-web3-js-141115b0f8c5
https://blog.infura.io/post/ethereum-javascript-libraries-web3-js-vs-ethers-js-part-i
https://itnext.io/top-3-web-3-0-architecture-layers-explained-frontend-backend-and-data-e10200f7fc76
https://betterprogramming.pub/everything-you-need-to-know-about-fullstack-web3-94c0f1b18019
Programs to Accelerate Your Progress in a Software Career
Join our 4-8 month intensive Patika+ bootcamps, start with the fundamentals and gain comprehensive knowledge to kickstart your software career!
You need to enroll in the course to be able to comment!