Skip to content

LEAFERx/chiado-ethers-mre

Repository files navigation

chiado-ethers-mre

This is a minimal reproducible example of a bug in the hardhat library when transacting on Chiado network.

Steps to reproduce

  1. Create .env based on .env.example, fill in the prefunded deployer private key.
  2. Run npm i to install dependencies.
  3. Run npx hardhat --network chiado run scripts/deploy.js to deploy the contract.

Bug Output

ProviderError: FeeTooLow, EffectivePriorityFeePerGas too low 0 < 1, BaseFee: 7

Expected Behavior

The transaction should succeed.

Bug Analysis

From this discussion, we know that JsonRpcSigner does not call populateTransaction when sendTransaction is called. The gas fee population is done by the node, which in this case the hardhat wrapper node.

The JsonRpcSigner is connected to a AutomaticGasPriceProvider ultimately, which implements the sendTransaction method here and determine the gas price here.

It uses eth_feeHistory to determine the gas fee data, in which the maxPriorityFeePerGas is set here based on the returned reward value.

In Chiado network, the reward value can be 0 since a lot of blocks are empty, which results in maxPriorityFeePerGas being 0, causing the transaction to fail.

eth_feeHistory on Chiado

Request script:

curl --location 'https://rpc.chiadonetwork.net' \
--header 'Content-Type: application/json' \
--data '{
    "jsonrpc": "2.0",
    "method": "eth_feeHistory",
    "params": [
        "0x1",
        "latest",
        [
            50
        ]
    ],
    "id": 0
}'

Example response:

{
    "jsonrpc": "2.0",
    "result": {
        "baseFeePerGas": [
            "0x7",
            "0x7"
        ],
        "gasUsedRatio": [
            0
        ],
        "oldestBlock": "0x318ad5",
        "reward": [
            [
                "0x0"
            ]
        ]
    },
    "id": 0
}

Workaround

Using Wallet instead of JsonRpcSigner or manually populate/override the gas price in the transaction object.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published