Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function stringToAddress(string memory _a) public pure returns (address) {
- bytes memory tmp = bytes(_a);
- uint160 iaddr = 0;
- uint160 b1;
- uint160 b2;
- for (uint i = 2; i < 2+2*20; i += 2) {
- iaddr *= 256;
- b1 = uint160(tmp[i]);
- b2 = uint160(tmp[i+1]);
- if ((b1 >= 97)&&(b1 <= 102)) b1 -= 87;
- else if ((b1 >= 48)&&(b1 <= 57)) b1 -= 48;
- if ((b2 >= 97)&&(b2 <= 102)) b2 -= 87;
- else if ((b2 >= 48)&&(b2 <= 57)) b2 -= 48;
- iaddr += (b1*16+b2);
- }
- return address(iaddr);
- }
- VehicleRegistry1.sol:266:18: TypeError: Explicit type conversion not allowed
- from "bytes1" to "uint160".
- b1 = uint160(tmp[i]);
- ^-------------^
- VehicleRegistry1.sol:267:18: TypeError: Explicit type conversion not allowed from "bytes1" to "uint160".
- b2 = uint160(tmp[i+1]);
- ^---------------^
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement