Solidity Remix IDE – How to Pass Array of Address and Array of Uint

remixsolidity

Working on the remix IDE, i cant seem to pass an array of addresses along with an array of uint as parameter to a function. It runs just fine on ethfiddle though and behaves exactly how i expected it to.

It keeps saying on remix, syntax error unexpected token at JSON position 3.

How do I call and test the function set with an array of address and array of value.

here's the code snippet and I am using solidity version 0.5.1 :

contract SimpleStore {
  uint public value;
  address public addr;

  function set(address[] _addr , uint[] _value) public {
    value = _value[0];
    addr = _addr[0];
  }
  function get() public constant returns (uint) {
    return value;
  }
}

I have tried, with quotes without quotes with square brackets without square bracks 🙁 -thanks in advance.

Best Answer

After updating the code to work with Solidity 0.5.x, the following input for set worked fine for me:

["0x1234567890123456789012345678901234567890"], [1, 2, 3]

After calling set, I checked the values of addr and value to and got 0x12345... and 1, respectively.

For reference, here's the updated code I used with 0.5.2:

pragma solidity 0.5.2;

contract SimpleStore {
    uint256 public value;
    address public addr;

    function set(address[] calldata _addr, uint256[] calldata _value) external {
        value = _value[0];
        addr = _addr[0];
    }

    function get() external view returns (uint256) {
        return value;
    }
}