[Ethereum] Can solidity contract arrays receive arrays of addresses as parameters

addressesarrayssolidity

This question is related to this one but using address arrays instead of strings. Does solidity support arrays of addresses to be passed as method arguments?

contract C {
    uint256 hexVal = 0xABCD;

    function func(address[] addrs) {
        // Do somethings with addrs
    }
}

If yes, is it passed as a Javascript string array when called from an external app?

Best Answer

Yes solidity support arrays of addresses to be passed as method arguments. Here is an working example

pragma solidity ^0.4.11;

contract AddressStore {
    address[] public bought;

    // set the addresses in store
    function setStore(address[] _addresses) public {
        bought = _addresses;
    }
}

https://ethfiddle.com/gfNfIFcT2C

Related Topic