0

I encountered a problem. My contract occasionally has execution exceptions, but there is no error prompt. I read the VM trace and found the following errors, but I don't understand why. Can someone help me? enter image description heret https://bscscan.com/vmtrace?txhash=0x4a0b818dcf9c67289e28215a2deb0f1e18e6e50a5d13d86d94d6bd6e9d96996a

Important: I found success transaction,SSTORE costs 5000 gas: enter image description here https://bscscan.com/vmtrace?txhash=0x7322838db22b96dbb26e9175f10a66766b3fb8deeb791fa3d7ee2612b4b2cb0b

But the error transaction,SSTORE costs 20000 gas: enter image description here https://bscscan.com/vmtrace?txhash=0xecd94d8aca1f4e0d0769556aa36675592bd5bde5e625cc4236bc94a6c9b0e779 Why?

1 Answer 1

1

The contract is running out of gas.

The line where the error is show:

Operation      Gas   GasCost
----------------------------
EXTCODESIZE    44       700

The available gas at that point is 44, and EXTCODESIZE requires 700.

4
  • Thanks for your reply! But why is it good most of the time, only occasionally? Moreover, even if the gas price is increased, such problems occasionally occur.
    – bencong he
    Commented Aug 25, 2021 at 8:43
  • The users use metamask. Doesn't metamask execute in advance? Why do users still fail when they pay enough gas fees?
    – bencong he
    Commented Aug 25, 2021 at 8:47
  • For a similar contract ,I have never met this bug on matic, but there is a 10% probability on BSC
    – bencong he
    Commented Aug 25, 2021 at 8:48
  • @benconghe The gas calculation depends on the contract's state if it changes between the estimation and the transaction mined it might cause this type of errors. When doing my transactions I'll add an extra 10%. You could examine the contract's source and make it less dependent on state changes.
    – Ismael
    Commented Aug 25, 2021 at 14:25

Your Answer

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

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