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!

DamiToma
  • 172
  • 1
  • 8

1 Answers1

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
alberto
  • 3,343
  • 2
  • 12
  • 21