2

I can't understand where are these events log data is stored?

I can access to my logs by

myContract.allEvents({
    fromBlock: 2139049,
    toBlock: 'latest'
  }, function(error, event){
      console.log("event : ",event);
});

But, can i access this logs after one year? Or they'll be removed? And where is this logs are storing?

user25688
  • 41
  • 2

1 Answers1

4

Event logs are stored within transaction receipts, which are stored in blocks. You will be able to access your event logs for as long as the network remains active.

Zack McGinnis
  • 791
  • 6
  • 6
  • Is there reason do not use event log for storing some data? I just need to store ipfs hash in each transaction, and later return those hashes in correct order. As i understand, reason is that contract can't access event log itself? – user25688 Apr 19 '18 at 19:40
  • It is fairly common practice for a dApp to read data from contract event logs (rather than from the contract), as it is often a cheaper form of storage. You are correct in that the contract cannot access the event log directly. As for returning the hashes/events in the correct order, I do not believe web3 does this by default. – Zack McGinnis Apr 19 '18 at 19:48
  • I will order it by frontend js scripts. I'm very surprised, since I read that the logs are stored on the nodes and they can retire. If it's not, so this is very cool, because of cheap – user25688 Apr 19 '18 at 22:07
  • Event logs will always be recoverable since transaction receipts are stored within blocks. – Zack McGinnis Apr 19 '18 at 22:23