can a contract handle an array with ten million elements?

islandBillyislandBilly Member Posts: 15
I have written a contract that has an array of uint256's inside a simple struct. The rest of the struct is just some strings and a smaller integer. If the Dapp that manages this contract becomes widely accepted, the array of uints could hit tens of millions of elements. Considering how Solidity has trouble retrieving more than 6 or 8 state variables at a time, and how the EVM is compared to a 1995 cell phone, can anybody tell me whether my array will be okay if it gets that big??


  • o0ragman0oo0ragman0o Member, Moderator Posts: 1,291 mod
    As long as you're dealing with the array atomically, i.e, updating only a few individual elements each transaction, there is no problem. Just don't try to 'delete' it in one hit, that will go OOG and potentially lock up your contract
  • mikeshultzmikeshultz Member Posts: 5
    Using an array is likely to cause you out of gas errors and depending on how it's built, could render your contract useless. You should at least run some tests with your expected usage.

    Depending on your needs, a mapping is probably better.
Sign In or Register to comment.