3

How can I hard code bytes in solidity for a static call?

Ive tried:

bytes memory data = "0xfeaf968c";

bytes memory data = \xfeaf968c";

It works when I manually enter it as an input parameter, while it fails for some reason when I externally call it when its hard coded in this format.

Matt Jaf
  • 339
  • 2
  • 8

1 Answers1

6

You can use the hex keyword to hard-code bytes in your contract.

bytes memory data = hex"feaf968c";

or

bytes memory data = "\xfe\xaf\x96\x8c";

Matt Jaf
  • 339
  • 2
  • 8