5

I have a function that looks like this:

function foo(uint _someVar, bytes calldata _data) public {
    ...
}

Then I make a call to it from another function with "" as _data:

foo(123, "");

"" seems to be the default way to pass blank bytes. However, I get this truffle compilation error:

TypeError: Invalid type for argument in function call. Invalid implicit conversion from literal_string "" to bytes calldata requested.

I have tried to declare and pass variables, but it all comes down to trying to assign blank calldata bytes. Any tips on how to do this?

1
  • 4
    Use new bytes(0).
    – Ismael
    May 3, 2021 at 7:52

2 Answers 2

3

Try to use "0x". It helps me.

1
1
bytes memory data = new bytes(0);
1
  • 1
    While this seems to answer the question, please avoid code only answer. Jun 18, 2022 at 4:07

Your Answer

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

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