0

I want to log data in Ethereum block-chain. It is obvious that we can create a smart contract that emits events and retrieve data from it.

But is sending a transaction with data but no ETH value (just gas but no ETH) more efficient than deploying a contract that emit events?

I would like to from the following perspectives:

  1. Cost - Which of the 2 methods is cheaper?
  2. Retrieval - Is any method provides faster data retrieval than the other?
  3. Deletion - Does deleting smart contract data deletes the events as well?

Would love to know some answers for the above.

Thank you! :)

2
  • create a smart contract that emits events and retrieve data from it. - you do realize that in order for this contract to emit events you will still need to send transactions (calling the function which emits those events), right? Jul 13 '20 at 7:21
  • @goodvibration - I am pretty aware of that but that's not the focal point. Kindly look into the 3 aspects I am trying to compare. It goes without saying that you need to call a function to emit events. But do we even need to create a smart contract and call events or just encode the data in a random transaction? What are the pros and cons of the 2 methods with respect to cost, retrieval or deletion. Think I got he answer below. Jul 14 '20 at 8:13
1

In Ethereum you pay for each byte sent - whether it's to a smart contract or to an EOA (externally owned address). With smart contracts you also pay for the execution (and for the initial contract deployment).

I would say this depends on what you want to do with the data. IF you simply send a transaction with arbitrary data to any address it's possible but quite unconventional and therefore tooling for such functionality is probably quite poor. Also there's no structuring of the data and not much other ways to organize it either.

So if you want any easy way to access the data you should send it to a contract (and possibly even emit events).

Data retrieval can always be done from your local node so it's always efficient, no matter which way the data is stored.

If you delete a contract it only deletes its bytecode from the blockchain from that block onwards - all history is kept. So the contract simply can't be used after that.

1
  • Thank you very much! This is what I was looking for. Jul 14 '20 at 8:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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