Skip to content

Instantly share code, notes, and snippets.

@ChristianOConnor
Created May 28, 2023 07:21
Show Gist options
  • Save ChristianOConnor/de2a4608f09f514f42d1767a3abc8604 to your computer and use it in GitHub Desktop.
Save ChristianOConnor/de2a4608f09f514f42d1767a3abc8604 to your computer and use it in GitHub Desktop.
Deploys RandomDebug5Local NFT contract
// 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
import { ethers } from "hardhat";
// Runtime Environment's members available in the global scope.
const hre = require("hardhat");
const dotenv = require("dotenv");
dotenv.config();
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 RandomReachDebug5 = await hre.ethers.getContractFactory("RandomReachDebug5Local");
const gasPrice = await RandomReachDebug5.signer.getGasPrice();
console.log(`Current gas price: ${gasPrice}`);
const estimatedGas = await RandomReachDebug5.signer.estimateGas(
RandomReachDebug5.getDeployTransaction("RANDOM NFT 5", "RNFT5"),
);
console.log(`Estimated gas: ${estimatedGas}`);
const deploymentPrice = gasPrice.mul(estimatedGas);
const deployerBalance = await RandomReachDebug5.signer.getBalance();
console.log(`Deployer balance: ${ethers.utils.formatEther(deployerBalance)}`);
console.log(`Deployment price: ${ethers.utils.formatEther(deploymentPrice)}`);
const randomReachDebug5 = await RandomReachDebug5.deploy("RANDOM NFT 5", "RNFT5");
await randomReachDebug5.deployed();
console.log("RandomReachDebug5 deployed to:", randomReachDebug5.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