I have a few questions regarding the deploy to the main net. They are mostly about the cost of it. Im using hardhat and ethers.js for deployment. The contract itself is written in Solidity.

  1. Could you please provide me with the exact pricing for deploying the smart contract? I found out that its basic fee of 21k gas + 32k of some contract creation fee. Then theres the price for kbs of the contract. But the kbs are what Im not so sure of. On every site they state a different price for kb of compiled bytecode of my contract. Could you please provide me with the gas price for kb in 2021?

  2. Where can I found my compiled bytecode size - the size that determines the pricing? When I compile my code with hardhat it produces a bunch of .json files in the artifacts folder. I am really struggling to understand which one is the compiled contract bytecode that will be stored on the blockchain and that I will pay for.

  3. How can I set gas prices in ethers.js? In every tutorial or example that I saw, nobody sets gas prices manually in ethers.js, not even a gasLimit. Is ethers.js setting these prices by itself? And are the prices that ethers.js sets good or are they unnecessary high? Or is there a way to set the gas price in the hardhat config file?

  4. Which amount of eth would you guess that my deployment to the main net will take? My contract is written in Solidity, it uses the classic openzepellin libraries for ERC-721 tokens. I put everything into just one .sol file and it has 1.4k lines.

  • 1
    deploy the contract on a test net, see how much gas it consumes on etherscan (Gas Used by Transaction), then check the current gas price on the main net etherscan.io/gastracker (you need it in WEI) and multiple both to get the amount of ether to deploy your contract with that gas price.
    – Majd TL
    Oct 28 at 10:24
  • If you are asking these questions, I think you are doing something wrong. NFT costs a few hundred USD to deploy. Developing it costs hundreds of times that. And sales should be hundreds of times that. Oct 28 at 14:14
  • @MajdTL Thanks for replying. So I already deployed my contract on rinkeby and this is the transaction: rinkeby.etherscan.io/tx/…. So as I understand the relevant field is Gas Used by Transaction, which shows 3.6mil. Is this Gas Used by Transaction identical across all the networks? Will the deployment of this exact contract cost the same 3.6mil on the main net?
    – Nerobod
    Oct 28 at 15:00
  • @WilliamEntriken what do you mean doing something wrong? I just dont understand where should I get some info about the prices of deploying my contract. And I also dont understand how to set the gas price or gas limit in hardhat or ethers.js. Or even if I should set these prices manually at all. Maybe its just better to let the ethers.js count these prices for me. Which I dont know therefore I am asking these questions. On the other hand Im quite familiar with the ERC-721 standard and solidity so I had enough skill to write and test the contract
    – Nerobod
    Oct 28 at 15:07
  • Answer WITHOUT any warranty: It will consume the same amount of gas if you do exactly the same process (if price 60 gwei then you need probably 0.25 ether). Another solution for you, you can copy your contracts to remix and BE CAREFUL (make sure you are using the correct compiler+optimization and imported dependencies of openzeppelin (you cant use @Openzepplin, you need to get them from Github using correct tag&version) then connect your metamask to remix and click on deploy, then metamask will pop up and ask you to confirm (DONT CONFIRM), and you can see how much is estimated to pay
    – Majd TL
    Oct 28 at 15:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.