Solidity Data Storage – Is There a Limit for Data a Contract Can Store?

contract-designdapp-developmentprivate-blockchainstorage

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.

Best Answer

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

Related Topic