I have a test function:
function test(uint[400] subscriptions, uint[400] subscriptionIndexes) public view returns
(uint[4000], uint[4000], uint[400]) {
uint[4000] memory postSenders;
uint[4000] memory postIds;
for (uint i = 0; i < 4000; i++) {
postSenders[i] = 1;
postIds[i] = 1;
}
return (postSenders, postIds, subscriptionIndexes);
}
If I connect Remix to Ganache, and call the function by copy pasting the parameters into the Remix IDE blue function box then it runs fine. If I try to call the same contract on the same Ganache network using web3 v 1.0 I get an out of gas error.
let subs = [1,1, ... ,1]
let indexes = [1,1, ... ,1]
let results = await contract.methods.test(subs, indexes).call()
If I reduce the number of loops in the test function eventually it will stop giving the out of gas error. Does anyone know what might be causing the problem?
The function also runs fine on Rinkeby via Remix.
Thanks!