thirdweb-dev / engine

The most powerful backend engine for web3 apps.
https://thirdweb.com/engine
Apache License 2.0
151 stars 59 forks source link

Transfer api failing #629

Closed dcapitator closed 1 month ago

dcapitator commented 2 months ago

I am trying to transfer out WETH9 tokens from my backend wallet using /transfer api.

payload: { "to": "0x80fbf2648f1eA0c0F7C2cDB6145a4AC87DE81575", "currencyAddress": "0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14", "amount": "0.6", "txOverrides": { "gas": "100000" } }

Note: Amount should be given in wei or ethers.

Simulating the transaction returns no error.

Executing the transaction fails in queue phase with error : insufficient funds for gas * price + value

I have 0.6 WETH9 and i have 0.1. ETHSepolia

https://sepolia.etherscan.io/address/0x3c0be3a855f32759f52650a154e0b757d90c9798

dcapitator commented 1 month ago

@farhanW3 any updates regarding this issue ?

dcapitator commented 1 month ago

@warengonzaga

arcoraven commented 1 month ago

Hi @dcapitator,

I assume you're calling the /backend-wallet/:chain/transfer endpoint. Your request body looks correct. (Note: The gas override isn't necessary: Engine should estimate appropriately the gas limit to use.)

The error you're encountering (insufficient funds for gas * price + value) suggests the gas fees estimated by Engine exceeds the ETH gas balance in your wallet. While your wallet does appear to have enough, it's possible that at the time of the transfer, Sepolia gas fees were very high and unable to complete the transaction.

Have you tried at different times to confirm if you're able to complete the transfer when gas is lower?

Here's a recent Engine transaction that transferred USDC on Sepolia when gas was lower: https://sepolia.etherscan.io/tx/0x4a2c5d4c46ced1b8b3b3c0d6652c63e88f9c941fcc0583f65b7463b92b9d3738

Rough ballpark math:

But Sepolia gas fees can be spiky. In your last transaction the gas fees were 470 gwei+. With this same math, your wallet must have 51658 470 10^-9 = 0.024 ETH in your wallet. I see your wallet has below that amount, which is why you would have seen this error.

Also can you try upgrading to Engine v2.0.x if you aren't already? There were some gas estimation improvements made to this version which may help your situation.

dcapitator commented 1 month ago

Hi @dcapitator,

I assume you're calling the /backend-wallet/:chain/transfer endpoint. Your request body looks correct. (Note: The gas override isn't necessary: Engine should estimate appropriately the gas limit to use.)

The error you're encountering (insufficient funds for gas * price + value) suggests the gas fees estimated by Engine exceeds the ETH gas balance in your wallet. While your wallet does appear to have enough, it's possible that at the time of the transfer, Sepolia gas fees were very high and unable to complete the transaction.

Have you tried at different times to confirm if you're able to complete the transfer when gas is lower?

Here's a recent Engine transaction that transferred USDC on Sepolia when gas was lower: https://sepolia.etherscan.io/tx/0x4a2c5d4c46ced1b8b3b3c0d6652c63e88f9c941fcc0583f65b7463b92b9d3738

Rough ballpark math:

  • 51,658 gas units spent
  • 5.52 gwei max fee per gas
  • I would need 51658 5.52 10^-9 = 0.00028 ETH in my wallet to complete this transaction, which I did.

But Sepolia gas fees can be spiky. In your last transaction the gas fees were 470 gwei+. With this same math, your wallet must have 51658 470 10^-9 = 0.024 ETH in your wallet. I see your wallet has below that amount, which is why you would have seen this error.

Also can you try upgrading to Engine v2.0.x if you aren't already? There were some gas estimation improvements made to this version which may help your situation.

Thank you for the reply . My bad i didnt look into sepolia gas spikes and i expected that the simulation would revert if the Transaction with the gasLimit set won't pass with the current chain gas prices.

I can confirm that the api is working as expected and can transfer tokens .

Not sure why the transaction got executed twice :

https://sepolia.etherscan.io/address/0x3c0be3a855f32759f52650a154e0b757d90c9798

Unless the first one failed and engine retried with higher gas and again due to sepolia sudden spike in gas price.

I think this is an old issue with engine v1 not retrying if its gas issue .