Can anyone send a reference to Abi.encodePacked? I want to know how that function works, or refer to a source code.

Feb 20, 2022, 3:50 PM
The docs have some explanations here: https://docs.soliditylang.org/en/v0.8.11/abi-spec.html
Feb 20, 2022, 3:53 PM
@coffeeconverter one question if you can answer.
return abi.encodePacked(
a, //uint256 1
b,//uint256 2
c //uint256 3
);
//Result is 0x000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000003

When running keccak256("0x000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000003");
//Hash Result is 0xb7fde2a4469bd72dacef4708fed26d4a44b729ebf3bfb85b4931377f26efdbf5

But when we do it together
return keccak256(abi.encodePacked(
a,
b,
c
));
//Result is different 0x6e0c627900b24bd432fe7b1f713f1b0744091a646a9fe4a65a18dfed21f2949c

What am i missing?
Feb 20, 2022, 3:59 PM
if X is 1000 tokens, and you want that to be worth $300 to start, then pair it with $300 worth of the other token
make sense @Lebronggg ?
because in the keccak256("0x000...") example, you're hashing a string literal. Instead, you want to hash the bytes, so do keccak256(hex"0000....")
Feb 20, 2022, 4:13 PM

© 2024 Draquery.com All rights reserved.