I try to convert hex string to bytes.
function MyContract() public {
string memory str = "A76A95918C39eE40d4a43CFAF19C35050E32E271";
array1 = bytes(str);
bytes memory str1 = hex"A76A95918C39eE40d4a43CFAF19C35050E32E271";
array2 = str1;
}
In array1 I have only unicode from str like array1[0] - 41
. In array 2 I have what I want array2[0] - a7
. But I can't use hex with variable.
I want to use function arguments for conversion to bytes like:
function (string str) {
return bytes(hex(str))
}
Question: Is there any way to do the conversion in Solidity?
Thanks so much in advance.