can a contract handle an array with ten million elements?

islandBillyislandBilly Posts: 5Member
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??

Comments

  • o0ragman0oo0ragman0o Posts: 1,252Member, Moderator 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 Posts: 5Member
    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.