2
contract MyContract {
    uint public len;
    mapping(uint=>byte) public names;
    function initContracts(byte[] contractNames_){
        for(uint i=0;i<contractNames_.length;i++){
            names[i]=contractNames_[i];
        }
        len=contractNames_.length;
    }
}

When I use Mist, and pass [0x01,0x02,0x03], it seems that byte[] contractNames_ can not be assigned to storage mapping names, and variable len remains 0.

  • Have you tried ["0x01","0x02","0x03"] with the hex strings quoted in Mist? I tried your code as is and it worked with quoted hex strings in browser-solidity (output at pastebin.com/psYDzPn0). – eth Sep 4 '16 at 6:54
  • thank u very much! [0x01,0x02,0x03] is not valid. – Jim Green Sep 4 '16 at 7:17
2

The input [0x01,0x02,0x03] had to use quoted hex strings: ["0x01","0x02","0x03"]

The code works as is in browser-solidity and OP has confirmed it also works in Mist.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.