On-chain example:
pragma solidity 0.4.24; contract MyContract { uint[] public array; constructor() public { array.push(1); array.push(2); array.push(3); } function getArray() public view returns(uint[]) { return array; } } Off-chain example:
contract("MyContract", function(accounts) { it("Test", async function() { myContract = await artifacts.require("MyContract.sol").new(); let array = await myContract.getArray(); let item0 = await myContract.array(0); }); }); As you can see, the getArray function indeed returns the array.
But when I "call" the array, I need to pass an index (in other words, the array "returns" an item).
Attempting to execute:
let array = await myContract.array(); Results with:
Invalid number of arguments to Solidity function Why has the Solidity standard defined it this way?
Thank you!