0

I'm trying to verify what happened in a transaction, to my understanding the only guaranteed way would be to monitor state change. The other options I've looked into are the combinations of input data/logs data/transaction traces. To my understanding, these don't have guarantees to provide a complete and credible picture of what happened in a transaction.

Does anyone know a way to determine how Ethereum's state changed after the completion of a transaction, or does anyone know a credible way to determine what happened in a transaction?

4
  • 2
    If you run your own archive node (or hire one) you can replay any transaction you like with tracing enabled, which tells you every single EVM opcode that executed
    – user253751
    Feb 9, 2023 at 15:30
  • 1
    @user253751 thank you! looking into this now
    – itgav
    Feb 9, 2023 at 16:07
  • you can avoid running archival node if you implement a very robust tracing mechanism. You have only 128 blocks keeping state changes on the tail of the blockchain, so if your processes get a downtime and it lasts for more than 128 blocks, you will lose the state changes (there will be a "hole" in your data and you won't be able to trace)
    – Nulik
    Feb 10, 2023 at 14:29
  • you "confirm" the state changes by getting a Receipt of the trnasaction and checking the Status field, this is how it is guaranteed that all changes are permanent. You don't need to verify every state change individually
    – Nulik
    Feb 10, 2023 at 14:31

1 Answer 1

1

Any smart contract state is publicly available on any EVM chain. You just need to read it after the transaction executed, for instance:

 const value256 = await ethers.provider.getStorageAt(contractAddress, slot);

You just need to figure out what slots you want to read and decode them afterwards.

You can find ideas about computing slots and decoding several types here

Hope this helps.

2
  • Thank you! looking into this now
    – itgav
    Feb 9, 2023 at 16:07
  • Please accept the answer if it helped in your problem. Thanks.
    – prc
    Feb 9, 2023 at 17: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.