I am trying to convert address string to type address in solidity but when I am doing
function StringToBytes(string memory _str) public pure returns (bytes memory) {
return bytes(_str);
}
function StringToBytesLength(string memory _str) public pure returns (uint256) {
return bytes(_str).length;
}
The result of StringToBytes is giving me 42 which should ideally gives me 20. If I am trying the same thing in python i.e convert string to bytes , it is giving me 20 bytes which is the length of an ethereum address in bytes. I had found several solutions to convert address string to address type but none of them is working for solidity version 0.7. Please help.