简体   繁体   English

在不部署合约的情况下估算铸造 erc20 代币的 gas

[英]Estimate gas of minting erc20 token without deploying contract

I want to estimate gas of minting erc20 token without deploying contract.我想在不部署合约的情况下估计铸造 erc20 代币的气体。 I am aware of contract.estimateGas but I dont have any contract address to test it.我知道contract.estimateGas,但我没有任何合约地址来测试它。 Is it possible to do it without providing contract address?不提供合约地址可以吗?

Each ERC20 contract can have different gas requirements, depending on its implementation.每个 ERC20 合约可能有不同的 gas 需求,具体取决于其实施。

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.通常,代币铸币包括一次存储写入、一个事件日志、少量 memory 操作,通常还有一次存储读取(验证执行此 function 的用户是否被授权铸币)......总共通常花费数万个 gas 单位.

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.但实际成本不仅受操作量的影响,还受合约中函数数量的影响,铸币厂 function 是external的还是public的,以及许多其他因素。

TLDR: "Usually tens of thousands of gas units" is the closest you can get without estimating against a specific implementation. TLDR:“通常有数万个气体单位”是您可以得到的最接近的值,而无需根据具体实施进行估算。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM