Skip to content

Instantly share code, notes, and snippets.

@ximxim
Created October 24, 2021 00:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ximxim/9d294e0ddf8673ef27b3528e6a0a633c to your computer and use it in GitHub Desktop.
Save ximxim/9d294e0ddf8673ef27b3528e6a0a633c to your computer and use it in GitHub Desktop.
Solidity contract run script explained
* We require the Hardhat Runtime Environment explicitly here. This is optional
* but useful for running the script in a standalone fashion through `node <script>`.
*
* When running the script with `npx hardhat run <script>` you'll find the Hardhat
* Runtime Environment's members available in the global scope.
*
* Check: https://hardhat.org/guides/scripts.html#standalone-scripts-using-hardhat-as-a-library
*/
const hre = require("hardhat");
async function main() {
/**
* Hardhat always runs the compile task when running scripts with its command
* line interface.
*
* If this script is run directly using `node` you may want to call compile
* manually to make sure everything is compiled
* await hre.run('compile');
*
* We get the contract to deploy
*/
const contract = await hre.ethers.getContractFactory("MintingContract");
const token = await contract.deploy();
await token.deployed();
console.log("Greeter deployed to:", token.address);
}
/**
* We recommend this pattern to be able to use async/await everywhere
* and properly handle errors.
*/
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment