Style guide suggestion for storage and transient storage

In my experience, treating storage and memory variables the same is confusing and dangerous for devs (new and old). For a long time, I have adopted a different coding style for storage variables, as documented here, which is also partly used by Chainlink in their coding style guide here.

As the EIP-1153: Transient storage is on the horizon, I think it’s time to raise this suggestion up to have a clear view of storage access, making the code much more readable and avoiding all local variable name collisions:

  • Storage variables are prefixed with s_ to indicate that they reside in storage and are expensive to read and write: s_storageVariable.
  • Transient storage variables are prefixed with t_ to indicate that they must be reset before the transaction ends: t_transientStorageVariable.
1 Like

I like the way you’re thinking! The idea of prefixing storage and transient storage variables for clarity is solid.

1 Like