0

I read somewhere that there is a limit on the amount of data that can be stored in a contract. And so there is a limit on how big arrays can be.

Now I am wondering is there a limit on how many mappings a contract can have? And is there a limit on how many events a contract can emit?

I am asking this to understand how a factory contract would store pointers if it had many child contracts.

YulePale
  • 1,843
  • 3
  • 19
  • 46

3 Answers3

2

The (theoretical) total storage for a contract is 2^256 * 32 bytes regardless of how you store it. That number is huge, you'll run into issues long before filling that storage.

I don't think there's a max number of Events that you can emit. However you'll probably limited by gas cost and block gas limit.

Diego Ferri
  • 926
  • 8
  • 12
1

Now I am wondering is there a limit on how many mappings a contract can have? And is there a limit on how many events a contract can emit?

The practical limit for this is the transaction cost. You can in theory pump data to Ethereum blockchain at the rate of around few megabyte a minute, but you would pay billions of dollars per month for the transaction cost.

I am asking this to understand how a factory contract would store pointers if it had many child contracts.

Someone pays the transaction cost and the storage of a pointer is roughly the cost of executing SSTORE EVM instructions.

Mikko Ohtamaa
  • 22,269
  • 6
  • 62
  • 127
1

Now I am wondering is there a limit on how many mappings a contract can have?

If you mean variables of type mapping, and not entries in a particular mapping, then you'll eventually be limited by the maximum contract (code) size, which is 24kB. (Though I think if you had that many mappings then you'd need to reconsider your contract design... )

Richard Horrocks
  • 37,835
  • 13
  • 87
  • 144