0

Can someone explain why the same WFTM transfer costs one time 38k and another time 23k gas?

Here are the two transactions:

https://ftmscan.com/tx/0xfaf2b8757f2c1d90a7b58df7f4cbd4022062855ca77095ac705ace91a5f3cf35

https://ftmscan.com/tx/0x1b88ea94d5fb57d7f07a45402090fbdd0b47017e49b2632dc78ea0e860cc0e57

1 Answer 1

0

This is related to the gas metering of storage changes.

When you transfer a token, the balance sheet inside the token contract is updated. This means you need to adjust the balance of the sender and the receiver.

When a storage slot was originally 0 and is changed to a non-zero value, you need to pay 20k gas. Otherwise you pay 5k gas. And you change the value from non-zero to zero you get a gas refund at the end of transaction of 15k gas.

Looking at the second link you shared you can see that 0x3099e12ca83c51e9b82ea6c5a08723aed4912068 transferred all tokens available, therefore setting the balance of that account to zero. This triggered the gas refund of 15k gas, which is the difference in gas costs.

1
  • Many thanks that sounds interesting.
    – flo
    Jan 13, 2022 at 18:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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