6

Are logs a reliable place to store data long-term?

From the documentation:

"These logs are associated with the address of the contract and will be incorporated into the blockchain and stay there as long as a block is accessible (forever as of Frontier and Homestead, but this might change with Serenity)"

Edit

Logs work now- I understand. But are they future-proof ways of storing app-critical information? What information beyond the "this might change with Serenity" is available? Will they still linger for a long time after that? Further insights appreciated.

1
  • hey will_durant, did you find the answer you were looking for? I m interested on this as well as we're planning to store some data in logs as it's cheaper
    – ianaz
    Mar 30, 2020 at 10:58

1 Answer 1

4
+25

Logs are reliable and the best way to process transactions when someone interacts with your contract. Example, if you have an auction contract, you can emit an event when a bid is made, when someone wins the bid, etc, and thus process the transaction As the documentation says, logs remain in the blockchain as long as the block is accessible.

You can always revisit those blocks/transactions from past and use web3.getTransaction() & web3.getTransactionReceipt() along with the ABI and LogParser to decode all logs/event hashes into Human Readable Text.

Hope this helps

3
  • I'm looking more for information about upcoming changes in Serenity. Apparently blocks may not be accessible forever. Dec 13, 2017 at 20:42
  • Log does the job. You just have to be aware that if a hard forks happens, you won´t be able to get past logs anymore Dec 14, 2017 at 9:42
  • Yeah, once hard forked the logs won’t be accessible Dec 15, 2017 at 3:06

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.