The first thing that must be done when implementing a smart contract inside a React application is the contract instance so that we can start calling methods from that contract all over the decentralized application. We'll use the compiled contract provided by Truffle and the address of it. Let's perform the following steps:
- Import web3 into your project:
import Web3Js from 'web3'
Why do you think I've named the variable Web3Js instead of just Web3? Because MetaMask injects its own version of web3, which is precisely named Web3, so when we develop, we may be used the injected version of web3, instead of the one that we are interested in importing. It's important to use a slightly different name to ...