1
pragma solidity ^0.4.0;

contract Storage {

    uint8[5][5] public data;

    function Storage() public {

    }

    function setData(uint8[] _data) {
        for (int i=0;i<5; i++)
            data[i][1]=_data[i];
    }

    function getData() public constant returns(uint8[5][5]){
        return data;
    }


}

on my web3 page i call the contract to store the data:

        var byteArray = new Uint8Array(25);                
        var randomArray = [0x80, 0x02, 0x03, 0x04, 0x05,
                          0x01, 0x02, 0x03, 0x04, 0x05,
                          0x01, 0x02, 0x03, 0x04, 0x05,
                          0x01, 0x02, 0x03, 0x04, 0x05,
                          0x01, 0x02, 0x03, 0x04, 0x05];    
storeSC.setData(byteArray , function (error, result) {
        if (!error)
            document.getElementById('response').innerHTML = 'Success:' + result
        else
            console.error(error);
    });

Anybody can explain me why passing randomArray everything works but I send out a lot more data than needed, passing byteArray I get:

invalid number of arguments to solidity function

I just want to be able to pass a set of bytes to the method setData, any help on how to do it please?

0

I suspect this is a problem with using js typed array object, a single instance, which is not an array. Convert to number array first perhaps, using this https://stackoverflow.com/q/12760643/442396

  • Thank you this solved the problem, the array passed however wasn't really of 8bit, i guess i need to find a way around that – CounterIt Mar 5 '18 at 6:51
  • @Counterit ok pls upvote👍 – Sentinel Mar 5 '18 at 10:01
  • Afaik int must be converted to a big integer . – Sentinel Mar 5 '18 at 10:02

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.