0

Using Remix, I can't pass a set of bytes ["0xee", "0xff", "0xgg", "0xhh", "0xii"] to my function

function foo(bytes5 input) {
    // Do something
}

I've already tried all these formats:

["0xee", "0xff", "0xgg", "0xhh", "0xii"]
["0xeeffgghhii"]
["0xee0xff0xgg0xhh0xii"]
"0xeeffgghhii"
"0xee0xff0xgg0xhh0xii"
[["0xee"], ["0xff"], ["0xgg"], ["0xhh"], ["0xii"]]
"0xee", "0xff", "0xgg", "0xhh", "0xii"

The IDE always raises the same error or says (legitimately) that the number of arguments doesn't match with my function:

Error encoding arguments: Error: invalid bytes5 value (arg="", type="object", value=undefined)

As you can see I already tried the solutions suggested here and here, how should I do it?
Thanks in advance!

1 Answer 1

1

The set of bytes must be in hex, 0xgg, 0xhh and 0xii are not hex bytes.

Try this:

input : ["0xee", "0xff", "0xff", "0xff"]

function foo(bytes5 input) public view returns (bytes5) {
    return input;
}

output: 0: bytes5: 0xeeffffff00

If you want something more arbitrary:

input :  ["0x00","0xaa", "0xff"]

function foo(bytes memory input) public view returns (bytes memory) {
    return input;
}

output:  0: bytes: 0x00aaff
1
  • Damn I spent half an hour on this silly mistake! Thank you very much!
    – DamiToma
    Commented Jun 6, 2019 at 9:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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