-
Will the below code refactor affect the GAS fees paid by the transaction?
Vs
As per my understanding, this should not affect the GAS fees because this is just code refactoring for readability purposes. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
The latter is less gas intensive relative to the former. Why? Because in the former, we are declaring and initializing
|
Beta Was this translation helpful? Give feedback.
The latter is less gas intensive relative to the former.
Why? Because in the former, we are declaring and initializing
simpleStorage
, which is a storage variable and hence, will consume extra gas. This is precisely why the latter is less gas-intensive as there is no variable declaration (which consumes gas).memory
(less gas intensive thanstorage
, as values are discarded) keyword could be used for the former, but it is important to note that the latter is still cheaper because there is no reference to thememory
data location.