-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Inaccurate documentation for bytes encoding #15303
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Similar issue with third example too for |
This issue has been marked as stale due to inactivity for the last 90 days. |
It is simply wrong, string values are passed as bytes in those examples. I had raised this issue on foundry too, if they are lacking functionality and probably lacking specifications compliance. But this is just problematic technically, mixing string and bytes will create inconsistent encoding values. For example, if a function receives |
Page
https://docs.soliditylang.org/en/latest/abi-spec.html#examples
Abstract
Encoding process of bytes and string is confusing(wrong). In the first example function
bar(bytes3[2] memory)
, two arguments are passed["abc", "def"]
which are getting encoded to their ASCII equivalent and get right padded. This suggests, function signature should look likebar(string[2] memory)
as mentioned in Formal Specification of the Encoding for string except for the length part.Otherwise, if the function signature is
bar(bytes3[2] memory)
then directly bytes should be passed into functions which would be616263
and646566
. After encoding these would become0x6162630000000000000000000000000000000000000000000000000000000000
and0x6465660000000000000000000000000000000000000000000000000000000000
Pull request
The text was updated successfully, but these errors were encountered: