Adding a Way to Deploy the Contract
Explore how to deploy smart contracts within a Web3 app using Solidity and React by leveraging Hardhat-generated ABIs, creating deployment functions, and managing contract state. Learn to test deployments on the Goerli Ethereum test network using test Ether from faucets, ensuring safe and cost-effective development.
We'll cover the following...
Deploying contracts
To deploy our contract on the blockchain, we’ll need to have the JSON description of the contract’s Application Binary Interface (ABI). Luckily, this is something that Hardhat creates for us when it compiles the contract.
Inside the Hardhat project, find the artifacts/contracts folder. Inside, there should be a folder for our contract. Copy the JSON file in that folder to contract/Contract.json in our front-end project.
artifacts__contracts__contract__Contract.json
We’ll be importing that file from our Next.js application:
import Contract from "../contract/Contract";
Let’s add a button to initiate the creation of the contract. We’ll make use of the MainButton component for this purpose. We’ll create a function called handleStartPartnership that will take care of the contract creation when the button is clicked. This button ...