Casting an address to string Solidity 8.0

How does one cast an address to a string?


Why don't you use the address data type

You can use our Strings library like this:

Strings.toHexString(uint256(uint160(msg.sender)), 20);

Wouldn't that be a costly operation using more gas

Thx man. Just what I needed

Other considerations. Thx

What do you need the string for, if I can give you an idea to save more gas

String is for json metadata

You most likely have absolutely no reason to do so (at least not one which would justify the performance hit).