Closed gndelia closed 2 years ago
Hey, sorry to hear you've been having issues with an RPC call.
I installed the same version of web3js and was able to sucessfully perform getFeeHistory
, perhaps it is hardhat?
Web3.eth.getFeeHistory('0x1', 'latest', []).then(console.log).catch(console.error)
Promise { <pending> }
> {
baseFeePerGas: [ '0x30aea7270d', '0x2deb22f72d' ],
gasUsedRatio: [ 0.27291628440852755 ],
oldestBlock: '0xce36b8'
}
If theres anything that points to web3js being an issue let us know and we'll try to investigate it when we can :)
Thanks for your response! I'll try to ping them on their side. I'm ok if you want to close this in the meantime. Thank you!
Hey @luu-alex, are you sure this isn't a problem in web3?
The eth_feeHistory
section of the spec says that the first argument should be a hex-encoded unsigned string:
But here:
Web3 seems to be converting it to a plain number (as far as I understand, at least).
Some nodes might be more permissive in what they accept, which makes sense. But we try to follow the spec as much as possible, so that code that runs on Hardhat will run in any spec-compliant node.
Hey @fvictorio thank you for taking a look, that makes alot of sense. I have reopened the issue and will try to tackle this problem. @gndelia I was curious are you still facing issues with a fork from ganache-cli? If so what was the error.
I get Method eth_feeHistory not supported.
- but that might be that I just need to update ganache-cli 😬
Is there an existing issue for this?
Current Behavior
Not sure if this is an error in web3.js or in hardhat, but after reading some docs and tracing the possible bug fix I think it should be fixed here (I might be wrong!)
When calling
getFeeHistory
in my app, using a local fork with hardhat, I get the following errorExpected Behavior
I expect the proper response of
eth_feeHistory
, something likeSteps to Reproduce
(according to the docs, these are valid parameters)
By running this with a local fork with hardhat, I get the above-mentioned error (See below for hardhat config)
Web3.js Version
1.5.3
Environment
Anything Else?
hardhat config is pretty simple
hardhat version: 2.6.7
so I just run
npx hardhat node
and connect with Metamask to that local forkThen, the code of the app just do what I wrote in the "Steps to Reproduce" section After a couple of hours of debugging; I found that if I change this line right here, updating the formatters for
eth_feeHistory
fromto
then it works. I found this as part of implementing EIP-1559 for a dapp.
I tried to use this method with a fork with ganache-cli, but I also failed to make it work, but I am still unsure of the reasons, as the error was different.
Not sure if this is a problem in web3 or in hardhat though 😓