Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

NFT marketplace deployment cost estimation

Testing a smart contract for implementing very basic NFT marketplace functionality
I use HardHat with Alchemy for deployment on Polygon Mumbai TestNet

module.exports = {
  defaultNetwork: "hardhat",
  networks: {
    hardhat: {
      chainId: 1337
    },
    mumbai: {
      url: "https://polygon-mumbai.g.alchemy.com/v2",
      accounts: [privateKey]
    }
  }
}
const factory = await hre.ethers.getContractFactory("NFTMarket");
const market = await factory.deploy();
await market.deployed();

Everything works as expected, enjoyed it so far and would like to build on functionality

Is there any way to see upfront the gas amount required for the deployment of my contract?
Both on Ethereum Mainnet and Polygon to see the difference in costs

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Yes, you can compile your contracts and create the transaction that would deploy your contracts without actually deploying your contracts.

You can use the hardhat gas reporter which also gives you an estimate of the gas estimation, this time it will be within hardhat.
https://github.com/cgewecke/hardhat-gas-reporter

If you have a simple contract, you can add it to https://remix.ethereum.org/ and compile it. When you hit the deploy button, there should be this pop-up
that lets you view the gas estimation, gas limit, and the current max fee, which gives you a good estimate of your transaction fee.
enter image description here

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading