I have a public function which takes in a uint256[] memory
input argument. I tried passing it an array of ~1000 elements in an array and it constantly failed with failing gas estimation. But, it works with ~150 elements - i'm continuing to test with higher length arrays but was wondering if there's a limit specified somewhere?
1 Answer
I don't think there's an explicit limit for an array size in a parameter. But the limit is caused by hitting the a gas limit.
You need to pay gas for each byte of data you input in your transaction, and per every operation the transaction triggers. If the combination of these two is too high, the transaction is reverted because it runs out of gas. Your wallet is also smart enough that it detects this failure and doesn't even let you execute the transaction.
If you have defined an explicit gas limit for transactions, you can make that higher. Otherwise you're simply hitting the network's block gas limit, which depends on the used network.
Furthermore, there's the possibility that your code simply reverts for some code-related reason.
-
1