Interacting with a Smart Contract
Learn how to call smart contract methods using the web3.js library
We'll cover the following
After the last lesson, we have a smart contract deployed to the Goerli network. Now, we'll see how we can call its method using web3.js. To do this, we'll write a new script that'll first register a new address in our name service contract and then try to read the address associated with this name.
New configuration
The new script we'll write will need to know the smart contract address we deployed in the previous lesson. Since we already have the .env
file to store the configuration of our application, we'll add one more variable called NAME_SERVICE_ADDRESS
with the contract address.
After adding the smart contract’s address variable to the configuration file, it now looks like this:
Get hands-on with 1400+ tech skills courses.