Skip to content

Instantly share code, notes, and snippets.

@ChristianOConnor
Created May 27, 2023 11:14
Show Gist options
  • Save ChristianOConnor/a24e365449ff2be81067c562dc2decc2 to your computer and use it in GitHub Desktop.
Save ChristianOConnor/a24e365449ff2be81067c562dc2decc2 to your computer and use it in GitHub Desktop.
Deploy the GetAddressFromSig contract on hardhat
import { ethers } from "hardhat";
const hre = require("hardhat");
const dotenv = require("dotenv");
dotenv.config();
async function main() {
const GetAddressFromSig = await hre.ethers.getContractFactory("GetAddressFromSig");
const gasPrice = await GetAddressFromSig.signer.getGasPrice();
console.log(`Current gas price: ${gasPrice}`);
const estimatedGas = await GetAddressFromSig.signer.estimateGas(
GetAddressFromSig.getDeployTransaction("RANDOM NFT 5", "RNFT5"),
);
console.log(`Estimated gas: ${estimatedGas}`);
const deploymentPrice = gasPrice.mul(estimatedGas);
const deployerBalance = await GetAddressFromSig.signer.getBalance();
console.log(`Deployer balance: ${ethers.utils.formatEther(deployerBalance)}`);
console.log(`Deployment price: ${ethers.utils.formatEther(deploymentPrice)}`);
const getAddressFromSig = await GetAddressFromSig.deploy("RANDOM NFT 5", "RNFT5");
await getAddressFromSig.deployed();
console.log("GetAddressFromSig deployed to:", getAddressFromSig.address);
}
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