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
Usage of bytes(uint)
is ambiguous
#14046
Comments
Hi @adaki2004 and thanks for the report. Do you mind posting the actual output of all of the |
Hey @nikola-matic !
|
@adaki2004 what happens if you do the following: console.logBytes(concatenation);
// or
console.logBytes(abi.encodePacked(hex"0000000000000000000000000000000000000000000000000000000000000001")); It seems more an issue with the foundry |
Thanks @r0qs ! Will check in a minute but you can see my main problem below.
|
With console.logBytes:
|
Seems like the |
Right. The problem is that not all ascii characters are printable, so you are getting the correct output as far as I'm concerned. For instance, if you do: console.log(string(abi.encodePacked(hex"0000000000000000000000000000000000000000000000000000000000000061"))); You should get
Not really sure of what you want achieve here, but if you want to define some sort of unique identifier based on the console.logBytes32(keccak256(abi.encodePacked(chainId, name))); |
Yes, so what we are trying to do is to keep track of a mapping between a So the string of |
hum...a bit tricky to focus on gas optimization while keeping readability, often this is not really the case. And honestly, I'd rather use a hash as a key. But yeah, design discussions around this is out of scope of the issue. I'd suggest that you post your design questions in our forum, or our matrix channel or even Ethereum stack exchange, and we can continue discussions from there. I'm closing this since it is not a compiler issue ;) |
Description
Usage of
bytes(uint)
conversion is ambiguous.Here is a demonstration of usage - running a simple foundry test.
You can see, it seems like it produces empty bytes, but when it is hashed (
keccak256
) the output is different, meaning there is something else under the hood.Environment
Steps to Reproduce
See source code above.
The text was updated successfully, but these errors were encountered: