This is a minimal reproducible example of a bug in the hardhat
library when transacting on Chiado
network.
- Create
.env
based on.env.example
, fill in the prefunded deployer private key. - Run
npm i
to install dependencies. - Run
npx hardhat --network chiado run scripts/deploy.js
to deploy the contract.
ProviderError: FeeTooLow, EffectivePriorityFeePerGas too low 0 < 1, BaseFee: 7
The transaction should succeed.
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.
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
}
Using Wallet
instead of JsonRpcSigner
or manually populate/override the gas price in the transaction object.