I have a function in my contract and it have bytes1[4] array parameter and returns.
function foo(bytes1[4] memory _mdata) public pure returns(bytes1[4]){
bytes1[4] memory result;
uint8 i;
for(i=0 ; i<4 ; i++){
result[i] = _mdata[i];
}
return result;
}
And in my truffle test javascript, it have something like..
var myData = [0x01, 0x02, 0x03, 0x1f];
it("test", async() => {
let instant = await myArithmetic.deployed();
let result = await instant.foo(myData);
console.log(result);
I got [ '0x10', '0x20', '0x30', '0x1f' ]
Is this because of different endian between javascript and solidty compiler? But why the last one returned correctly??
["0x01", "0x02", "0x03", "0x1f"]
does it work? I often have problems with javascript function when you pass a number but it expect a string. To be safe everything bytesXX seems to require a string.["0x01", "0x02", "0x03", "0x1f"]
!! Thank you.