Search code examples
ethereumweb3jsethers.js

Estimate gas of minting erc20 token without deploying contract


I want to estimate gas of minting erc20 token without deploying contract. I am aware of contract.estimateGas but I dont have any contract address to test it. Is it possible to do it without providing contract address?


Solution

  • Each ERC20 contract can have different gas requirements, depending on its implementation.

    Generally, token mint consists of one storage write, one event log, few memory operations, and usually one storage read (validating whether the user executing this function is authorized to mint tokens)... Which in total usually costs tens of thousands gas units.

    But the actual cost is affected not only by the amount of operations but also number of functions in the contract, whether the mint function is external or public, and many other factors.

    TLDR: "Usually tens of thousands of gas units" is the closest you can get without estimating against a specific implementation.