Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to hardcode bytes in solidity?

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.

like image 411
Matt Jaf Avatar asked Jul 21 '26 06:07

Matt Jaf


1 Answers

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";

like image 62
Milan Rilex Ristic Avatar answered Jul 23 '26 13:07

Milan Rilex Ristic