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.


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

Reference: Is there a (theoretical) limit for amount of data that a contract can store?

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. – user1364368 Dec 8 '18 at 13:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.