0

I'm trying to estimate the gas usage for a smart contract for an NFT token - is it possible to do before the actual sale?

contract is already published and all functions as well.

so I want to know how much contract will be used for the mint function of a smart contract

1 Answer 1

0

You can simulate the transaction with estimateGas. It basically runs the transaction locally, without sending it to the blockchain, and sees how much it costs. Check your library for the exact function name.

Although this functionality fails if the contract reverts (for example because the sale is not open yet). In that case you should deploy it locally, enable the sale functionality and do the same estimation - or even a real transaction.

2
  • is there no way to try and do that without deploying locally? seems like a ton of work just for gas calculation? - sale is not open yet
    – teggr234
    Dec 28, 2021 at 15:07
  • You can just fork mainnet and try locally Dec 28, 2021 at 19:03

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.