Hi

Please I need help with abi.encodePacked for addresses

Solidity code
keccak256(abi.encodePacked(0x0A144d4E1C59640125d1024814d190AD2349587c));
this returns: 0x26d303775d506a2857576a8b15df8ce65c69520d80d367f50c1482064bcc2234

while js code
web3.eth.abi.encodeParameter('address', '0x0A144d4E1C59640125d1024814d190AD2349587c')
returns: 0x604077134bee57e87d2813621b7339f114bce70e6658fb7f3cf14912cdd6438c

both solidity and js returned the same value when the input is uint256

Jul 7, 2020, 9:51 PM
Daniel Kirchner @ekpyron Helped me on gitter

abi.encode gives the same result as web3.eth.abi.encodeParameter

abi.encodePacked called like that on an address gives 20 unpadded bytes - abi.encode(address(...)) will give 32 bytes with the correct padding.
Jul 8, 2020, 12:30 PM

© 2024 Draquery.com All rights reserved.