Why write this article, because many people can't explain it clearly, and after reading many articles, I feel that the explanation makes people more and more confused.
Then I will put my understanding here (referring to many articles)
Reference link (yellow paper):
https://ethereum.github.io/yellowpaper/paper.pdf
Contract size: 24576 bytes, which should be 12 kb. That is to say, if a contract you write is deployed on the chain, you can only write its code at most 12 kb
Of course, for a file is a contract, 12kb is enough
It is enough to convert the written contract into binary digits no more than 24576 * 8
Put your contract address here to have a look. Link:
https://ropsten.etherscan.io/address/0x8808f84d046c4ad6d5ada894dadb90d627254fb0#code
The Yellow Book is very long, and I didn't read it much.
The next reference is V God's comment
Contract storage is a 32bytes key, and each key can correspond to a 32bytes value
What do you mean? 32bytes is 256bits, that is to say, there can be 2^256 different keys
Each key can store 32bytes of data, that is, it can store 2^256 * 32bytes === 2^261bytes of data
So the maximum value that a single contract can store is about 2^261bytes of data