Is there a theoretical limit to the amount of data that one contract can store while running in a private net in which gas is not a concern?

Context: In a financial Dapp which is to replace global payment systems, tx/s throughput is certainly one limiting factor that is widely discussed. But that is not what I am getting at here. Can a contract store 1GB, 1TB, ... data in a contract? The data would not be written in one go, but rather accumulate over time.

Example: Let's assume a best case scenario in which we manage to squeeze a single transaction of tokens living on top of a smart contract into 100 bytes. At 1000 tps throughput this would yield 100*1000*3600*24*31*12 = 3.2TB/year. Feel free to guess if / when this will be possible.

  • 2
    Are you 100% sure you need to store all these records for all eternity? If this is about communicating things between parties using Whisper messages might be better. An other option would be to save a 32 byte hash which points to the real data in Swarm or IPFS etc. – Maran Feb 5 '16 at 12:46
  • Good point, I am quite sure I do not need them for all eternity, just trying to understand the fundamentals. I am sure that I want all those records initially but it would be great to be able to move them to IPFS after N blocks - e.g. after a typical auditing period of one year. Seems tough to implement that in a contract without centralization right now (move out of blockchain onto IPFS and make sure the right stuff is now in IPFS). – Validity Labs - Sebastian Feb 8 '16 at 9:26
up vote 37 down vote accepted

Contract storage is a key of 32 bytes and a value of 32 bytes, so the maximum a single contract can store is around 1.46 GB (32^32).

False. 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....

  • 1
    Thanks, I updated and will fix my comment here… – eth Feb 5 '16 at 13:11
  • 1
    What do you mean break, will the whole blockchain fail? Are there no checks for duplicate hashes? Will the transaction have to be rewinded/redone until no collision occurs? – BlockChange Jul 25 '16 at 11:00
  • 1
    @BlockChange If duplicate hashes are discovered, there are much bigger problems because that would mean the hashing algorithm has been broken. For reference, for @2^261, assuming you can compute 1 hash per picosecond, you'd still need more time than we have until the heat death of the universe to find a conflict like that, unless the hashing algorithm is broken – Earlz Dec 13 '16 at 15:37
  • 2
    2^261 = #bytes that can be stored with 2^256 addresses, each storing 2^5 (=32) bytes. It has nothing to do with the hashing algorithm. The hashing algorithm used is Keccak 256-bit hash, giving 2^256 possible hash values, but you would not have to wait until the last one, for a collision to happen. Recall the Birthday Problem (a.k.a Birthday Paradox). Probability of collision is > 99% after 2^130 values. With 2^160 of those values as addresses of 2^160 contracts, P(collision) > 99.999999.... % (not sure how many 9's after the decimal point) – Ajoy Bhatia Jan 10 '17 at 0:11
  • @Earlz - The point is that there are about 2^35 seconds in a millennium (1000 years). So at the rate of creating 1 contract per second, it would take 2^125 millennia to create 2^160 contracts. Getting collisions long before then does NOT imply that the hashing algorithm is "broken". – Ajoy Bhatia Jan 10 '17 at 0:18

Contract storage is a key of 32 bytes and a value of 32 bytes, so the maximum a single contract can store is around 2^261 bytes (2^256 * 32b).

In a private chain where gas is not a concern, since the address space is 160 bits, assuming it can all be used, 2^160 contracts can be created. So in theory around 2^421 bytes is the maximum that contracts can store.

  • 5
    You'd run into hash collisions long before you created 2^160 contracts; 2^80 is probably a more reasonable estimate. – Nick Johnson Apr 14 '16 at 14:22
  • Why would there be hash collision after you created 2^80 contracts? @Nick Johnson – alper Dec 23 '17 at 18:43
  • Can a key's value be a struct, which might be larger than 32 bytes? @eth♦ – alper Dec 23 '17 at 18:51
  • 1
    @Alper The keys of contract storage can only be 32 bytes. – eth Dec 30 '17 at 13:50
  • @NickJohnson it is the point at which there is a ~50% probability of a collision having already occurred at least once, computer scientists would refer to it as a "Birthday attack". – user3338098 Feb 28 at 21:19

Your Answer


By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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