package.json, which will continue to grow as you install project dependencies.
Create an empty hardhat.config.jsby using the arrow keys and enter:
contractsdirectory. Create it:
.jsonfile. This file should be created under the root directory, and named
private.json. Because this key is highly sensitive information, it's very important that we are not revealing any information when deploying. To ensure this, we want to create a
.gitignorefile under our root directory. Then, you can ignore any files by using the format:
.filenameor any directories by using:
directory/. In our case, we are trying to ignore our private key file so it should look like this:
module.exports, we need to provide the Solidity version (
0.8.1according to our contract file), and the network details. Here, we are using testnet(Beresheet) network for the following example :
Box.sol, uses Solidity 0.8.1. Make sure the Hardhat configuration file is correctly set up with this solidity version. If so, we can compile the contract by running:
artifactsdirectory is created: it holds the bytecode and metadata of the contract, which are
.jsonfiles. It’s a good idea to add this directory to your
deployment script. First, let's create a new directory (
scripts). Inside the newly created directory, add a new file
ethers. Because we'll be running it with Hardhat, we don't need to import any libraries.
getContractFactory()method. Next, let's use the
deploy()method that exists within this instance to initiate the smart contract. Lastly, we wait for its deployment by using
deployed(). Once deployed, we can fetch the address of the contract inside the box instantiation.
Box.solcontract once again. Don't worry about the
undefinedoutput you will get after each line is executed:
5or the value you have stored initially.