# Can a contract's internal storage keep increasing forever?

In other words, is there a limit on the amount of storage a contract can hold?

Suppose a field is an Array for instance, and the contract has a method for adding items. Can I keep calling the contract so it adds more and more data?

Yes, a contract has infinite internal storage.

But there are 2 limits to practicality: gas costs and the block gas limit.

Gas costs are discussed in: Is there anything stopping me from using the ethereum blockchain as data storage?

Furthermore, the block gas limit will limit how much computation, search, iteration, etc can be performed on the data.

• Correction single contract can hold 2^261 bytes (2^256 keys * 32b)
– eth
Feb 5, 2016 at 13:28
• Oh, yeah I screwed up the math again. Dang. Feb 5, 2016 at 14:14
• See the more detailed explanation here: ethereum.stackexchange.com/a/1040/16 Feb 8, 2016 at 9:28

No, contracts' internal storage cannot increment forever. However, it is fairly more than enough for all types of purposes.

The limits for all storage variables together is:

2^256 Keys of 32 bytes = 2^261 bytes .

This is: 115,792,089,237,316,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000 of Keys 32 bytes.

That is equal to: 3,705,346,855,594,120,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000 bytes.

Witch is in terabytes: 3,705,346,855,594,120,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000 terabytes

There are 2^256 different keys, and each key can store 32 bytes, so that's a total of 2^261 bytes that could be stored. That said, by then the Ethereum blockchain will probably break due to a hash collision

However, as @eth♦ suggest, you should also consider the gas cost and the block gas limits.

Moreover, if you are using a mapping, a collision may happen because the location of a value key is computed using the hash function `sha3(key, p)`. Check here for more details: Is there a maximum number of entries for a mapping?. But again this collision is a concern when your data size is about 2^160 or 2^80 bytes. And this is a very large storage to consider.

• 2^261 Bytes is ≈ 3,7*10^78 Bytes, but the estimation for the total data volume stored on earth in year 2025 according to this article on forbes.com is "just" 175 Zettabytes = 1,75*10^23. Dec 8, 2018 at 13:38