Why use local variables of type storage to store values in a contract if you can emit events and later from the front-end search and retrieve those values? If we do not want to operate with the variables and simply leave a "stamp", in terms of gas it would be cheaper and we could have a record of the values within the event log.

What is the sense to use local storage variables in a SC that there are no operations with the values and the intention is just to save fixed values each time a function is called?

1 Answer 1


Blockchain Storage variable is like a box, they hold data for the contract to use later, but they cost more and event logs are like a notice board: record something that happened during a transaction and are cheaper.

Decision guide:

  • Need data later? Use storage.
  • Just want to note an event? Use event logs (they're also good for analysis).


  • Use storage to count completed tasks.
  • Use event logs to note each task completion without a permanent count, and for analysis purposes.
  • 1
    Thx I finally decide to implement logs Commented May 9 at 12:58
  • If I update this SC to a most improved version. Its possible to use the same log or each version will have independt logs? Commented May 9 at 13:06
  • Yess, you can use the same event log for all versions of the contract. Each version can add events to the same log, keeping everything in one place. For example, if you have an event called "TaskCompleted" in version 1: Code: event TaskCompleted(uint256 taskId, address worker); You can continue using the same event in version 2 without any changes: Code: event TaskCompleted(uint256 taskId, address worker); This ensures that all versions of the contract log task completions in the same event, making it easy to manage and analyze the data. Commented May 9 at 16:51

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.