You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
馃摑 Details
I think immutable attributes should be used much more in OZ contracts for attributes that aren't meant to be changed. One example is _name and _symbol in ERC20 / ERC721.
Using immutable is much more clear from a semantic point of view, making clear those attributes are set in the constructor and don't change anymore.
Also, my understanding is immutable attributes are better than storage ones in terms of gas consumption.
The text was updated successfully, but these errors were encountered:
You are right in saying that making name and symbol immutable would somehow be cleaner. There are however many reasons we don't do it.
We don't expect these variables to be read by other contracts, so the storage read cost is small.
Making immutable would change the storage layout, and cause issues when upgrading from current implementations.
Strings are non-value type, and CANNOT be marked as immutable. We could store them as bytes32, and cast that to string, but that would be messy and would lose generality as it would limit the length to 31 bytes.
馃摑 Details
I think
immutable
attributes should be used much more in OZ contracts for attributes that aren't meant to be changed. One example is_name
and_symbol
in ERC20 / ERC721.Using immutable is much more clear from a semantic point of view, making clear those attributes are set in the constructor and don't change anymore.
Also, my understanding is immutable attributes are better than storage ones in terms of gas consumption.
The text was updated successfully, but these errors were encountered: