1
// contracts/Gold20.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

contract Gold20 is ERC20 {
    constructor() ERC20("Gold20", "G20") {
       
    }
     function mint(address account, uint256 amount) public {
        _mint(account,amount);
    }
}

it is my contract when i get gas limit

//ethers.js
...
        if(baseFeePerGas){
            
            params = {
                gasLimit: ethers.BigNumber.from('21000').mul(1000),
                maxFeePerGas: baseFeePerGas.add(1),
                maxPriorityFeePerGas: baseFeePerGas,
                from
            };
        }else{
            const bn = await provider.getGasPrice();
            params = {
                gasLimit: ethers.BigNumber.from('21000').mul(1000),
                gasPrice: bn,
                from
            };
        }
        contract.estimateGas.transfer(to, value, params);

i get result is 0x89a1 (35233)

The transaction always fails because out of gas

For a successful transaction I try to add more gas such as 85233

query receipt of successful transaction, gasUsed is 30493

https://explorer.fzcode.com/tx/0x95b1b47c73b45a06988a81777d0aef73594e920d97280a6d526b8fbf67d44674

https://explorer.fzcode.com/tx/0xb7fddcb02d1c84995d053e23943b890afedc9a13d59bec81e351a924972f4bce

why?

block chain build by geth. etgereum/client-go:alltools-v1.10.20

dazan
  • 13
  • 2

0 Answers0