fairDataSociety / fdp-contracts

Fair Data Protocol smart contracts and its utilities
4 stars 1 forks source link

feat: approximate gas price calculation #153

Closed IgorShadurin closed 11 months ago

IgorShadurin commented 12 months ago

https://github.com/fairDataSociety/fdp-create-account/issues/293 https://github.com/fairDataSociety/fdp-contracts/issues/152

tomicvladan commented 12 months ago

I've tested this function in create account app, and here are the results:

FDP Play: 0.001878513
Sepolia: 0.000805077667677192
Goerli: account.context.tsx:150 Error: invalid BigNumber string (argument="value", value="NaN", code=INVALID_ARGUMENT, version=bignumber/5.7.0)
Optimism Goerli: 0.0008587488268359
Arbitrum Goerli: 0.0008587488

The values seem too small, so I'm not sure how reliable this approach is?

Maybe we could optionally include support for alchemy to calculate gas prices?

tomicvladan commented 12 months ago

And the current gas estimation works fine for Optimism Goerli and Arbitrum Goerli, if we just could support this functionality in our RPC, gas estimation would work fine.

IgorShadurin commented 12 months ago

The values seem too small

Why? Current Sepolia gas price is 0.000001483 gwei. I registered an account and spent 0.000198072014129136+0.00007323600537064+0.00011723250844074=0.00038854052 ETH. https://sepolia.etherscan.io/address/0x79E21B53731762434076035B3dC36C0A6c388687

This approach should work for other networks too (apart from Goerli, we should remove support for it).

As @darkobas2 said, there are plugins for our node, but they require a paid subscription.

tomicvladan commented 12 months ago

Maybe these are correct prices now. I tried to register an account on Sepolia with 0.0009 ETH and it didn't work. But we don't have any better solution at the moment.