🛠️ We're partnering with Alchemy to bring you a free Ethereum Developer Bootcamp! Get started here 🛠️
Now that we've successfully deployed a smart contract to the goerli network, let's test out our web3 skills and interact with it!
This is the file where we'll write our interaction script. We'll be using the Ethers.js library that you previously installed in Part 1.
If you want to see the ABI you can print it to your console:
In order to interact with our contract we need to create an instance of it in our code. To do so with Ethers.js, we'll need to work with three concepts:
We'll use the contract ABI from the previous step to create our instance of the contract:
You can read more about Providers, Signers, and Contracts in the Ethers.js documentation.
Congrats! You've just successfully read smart contract data from the Ethereum blockchain, way to go!
Now just run the script and you should be able to see the old message, the updating status, and the new message printed out to your terminal!
That is due to the mining process! If you are curious about how to track transactions while they are being mined, visit the Alchemy mempool to see the status of your transaction (whether it's pending, mined, or got dropped by the network). If your transaction got dropped, it's also helpful to check Goerli Etherscan and search for your transaction hash.
And that's it! You've now deployed AND interacted with an Ethereum smart contract.