Skip to content
Discussion options

You must be logged in to vote

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 than storage, 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 the memory data location.

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@Hiren879
Comment options

@krakxn
Comment options

@Hiren879
Comment options

@krakxn
Comment options

Answer selected by Hiren879
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants