By Daniel Luca
A new chapter is being written with the introduction of Transient Storage, courtesy of EIP-1153. This upgrade promises to revolutionize the temporary storage and management of data within transactions, stirring quite a debate in the community. It aims to optimize gas costs and enhance the efficiency of smart contracts. Yet, for all its potential, it's easy to misuse, leading to costly mistakes.
If you're a developer familiar with Solidity and keen on Ethereum's latest, this article is for you. Whether you're looking to optimize smart contracts or explore new features, we'll dive into how Transient Storage opens up new possibilities.
EIP-1153 was first proposed in June 2018, and since then, it has evolved and changed how gas pricing and refunding work and how the opcodes are designed. That’s why some articles you’ll find online are obsolete or don’t explain correctly how this works and how it should be used.
https://x.com/Bount3yHunt3r/status/1751059387555135777?s=20
Since this is such a controversial topic, an easy-to-get-it-wrong implementation detail, we will explore some ways you can mess this up. By the end of this article, when you review code or build software yourself, you will identify when you fall into one of these traps and should be able to correct them.
This feature has its pros and cons. On one hand, it can help you reduce gas costs if used correctly. On the other hand, it can also add complexity, introduce new context, and create additional EVM mechanics, which can increase the attack surface and make the auditing process more complicated.
Even the Solidity team is warning about possible misuse of this feature.
Without further ado, let’s dive into the technical details.
Think of Transient Storage as a hash table, one that starts fresh for each contract with each new transaction. Transient Storage offers a temporary space for data that only vanishes after the transaction completes.
The most important thing to understand is that Transient Storage is a new Page you can write and read from. The Transient Storage Page does not intersect with the Storage Page.
Let's examine all the ways information can be stored in the EVM: Stack, Memory, Storage, and now, Transient Storage.
It’s a new place where things are written to.
I intentionally omit the possibility of storing information as contract bytecode or calldata, as these methods have downsides.