optimism
optimism copied to clipboard
sender address missing in sdk for deposit and withdrawal gas estimation
Describe the bug A clear and concise description of what the bug is. https://github.com/ethereum-optimism/optimism/blob/034a993e4e3662a8a7625f0492fcf0b7b21d68e8/packages/sdk/src/cross-chain-messenger.ts#L2042 Gas estimation for deposit and withdrawal of ETH and ERC20 do not consider the sender's address. It uses default which is 0x0, which can cause wrong estimation or error.
In the case for OP Sepolia 0x0 address only has 1 wei. Hence, when trying to deposit any amount bigger than 1 wei from any EOA, gas estimation will fail with the following error
insufficient funds for gas * price + value: address 0x0000000000000000000000000000000000000000 have 1 want 10000000000000000 (supplied gas 30000000
This is because gas estimation is trying to compute the gas cost of transferring 1 wei from 0x0 to recipient instead of the actual sender to recipient.
For deposit and withdrawal of ETH or ERC20, sender address should be used in the gas estimate.
To Reproduce Steps to reproduce the behavior:
-
Go to '...'
-
Click on '....'
-
Scroll down to '....'
-
See error
-
Setup a OP Stack (L3) on top of OP Sepolia
-
Try bridging operation using the sdk
Expected behavior A clear and concise description of what you expected to happen.
Screenshots If applicable, add screenshots to help explain your problem.
System Specs:
- OS:
- Package Version (or commit hash): OP SDK version 3.1.2
Additional context Add any other context about the problem here.
You should consider migrating to viem as the sdk is going to be phased out eventually. viem natively supports op stack chains
You should consider migrating to viem as the sdk is going to be phased out eventually. viem natively supports op stack chains
Do you have a rough timeline on when the SDK will be phased out?
@bb111189 no rough timeline at the moment. Which function are you using that triggers the issue?
@bb111189 no rough timeline at the moment. Which function are you using that triggers the issue?
I'm having this issue when calling await crossChainMessenger.estimateGas.withdrawETH(amount) with any amount larger than 1
if I forcefully override the from address like this
await crossChainMessenger.estimateGas.withdrawETH(amount, { overrides: { from: address } })
it works. However, this is not needed for DepositETH for example, so it is a bit inconsistent
if I forcefully override the
fromaddress like thisawait crossChainMessenger.estimateGas.withdrawETH(amount, { overrides: { from: address } })it works. However, this is not needed for DepositETH for example, so it is a bit inconsistent
I have the same problem. If I override the from address it works, otherwise it returns a insufficient funds error
the sdk has been deprecated