Timeline for How to convert an bytes to address in Solidity?
Current License: CC BY-SA 4.0
5 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jan 21, 2022 at 23:09 | comment | added | e18r |
@LukeHutchison in my answer, the first 32 bytes specify the length of the string variable and the second 32 are the actual content. That's why I skip the first 32 bytes. As for Paul Steckler's answer, I'm not sure. And for your last question, I have no idea. I haven't used Solidity in a while. Sorry.
|
|
Jan 13, 2022 at 2:45 | comment | added | Luke Hutchison |
thanks, yes, I have seen that link before. But what I was asking about was why this answer uses addr := mload(add(bys, 32)) while Paul Steckler's answer uses addr := mload(add(bys, 20)) . Also there is no explanation of why the first 32 or 20 bytes are being skipped (is it just a matter of skipping padding?) Finally, does this work? (address addr) = abi.decode(theBytes, (address)); -- doesn't this avoid assembly altogether? Does it return the same result as one of the two assembly examples?
|
|
Jan 11, 2022 at 22:45 | comment | added | e18r |
@LukeHutchison if I understand correctly, you are calling an external contract via address.call() , then you are receiving some data, and you want to know what format that data has. Well, that totally depends on the contract you are calling. It can send whatever data using whatever format. However, there is a standard for encoding data, which is defined by Solidity and generally respected elsewhere. Take a look at it here: docs.soliditylang.org/en/v0.8.11/abi-spec.html#abi
|
|
Dec 14, 2021 at 10:26 | comment | added | Luke Hutchison |
What specifies what format the data will be in, if this is referring to a way of decoding the bytes return value from address.call() ? This is different from Paul Steckler's own answer, above.
|
|
Feb 5, 2021 at 15:36 | history | answered | e18r | CC BY-SA 4.0 |