0

https://etherscan.io/tx/0x43f39829b3a48c4146808b12489e01bdb5dfa32d5b49514298339a719e538c09

this tx failed, and the msg shows the cause is: out of gas, but Gas Limit is 520000, while only 86056 Gas Used By Txn.

why would this happen?

ps. source code of the erc20 token we are trying to swap is at https://etherscan.io/address/0x4ceda7906a5ed2179785cd3a40a69ee8bc99c466#code

  • thanks, but why etherscan shows out of gas? in my experience, when revert are called, the error message will be "reverted" – DiveInto Aug 14 '18 at 10:37
2

If you look at the parity trace for the transaction, you can see that it runs out of gas on a call from 0x4ceda7906a5ed2179785cd3a40a69ee8bc99c466 to 0x092988fc1090ff8f924b8f9cc71350e90ca446cd, which only received 2411 gas.

When contracts make sub calls, they are allows to only pass on a subset of the gas available to the entire transaction.

It seems like the contract you are using for the swaps limits certain external calls to 4999 gas.

Thus, when you the balanceOf function is invoked on the token, it receives only 4999 gas. This particular token seems to be using another contract to track the balances, and then makes a second internal call to retrieve the balance from there. This call only receives 2411 gas (which is all that's left of the 4999 gas from the initial balanceOf call), which is not enough to complete the read and return operation, and thus runs out of gas.

There is likely no way you can fix this without updating the token swaps contract.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.