AbiEncode with bytes param return Wrong
yonghumeijj opened this issue · comments
web3.eth.abi.encode('bytes',['0x0f00000002'])
return
0xB963E9B4
0000000000000000000000000000000000000000000000000000000F00000002
The Right is
0000000000000000000000000000000000000000000000000000000000000020
0000000000000000000000000000000000000000000000000000000000000005
0f00000002000000000000000000000000000000000000000000000000000000
From ABI Encoding Service Online for Solidity Smart Contracts by HashEx Check
web3.eth.abi.encode('bytes', [&array([$0f,$00,$00,$00,$02])]);
return
0xB963E9B4
0000000000000000000000000000000000000000000000000000000000000020
0000000000000000000000000000000000000000000000000000000000000005
000000000000000000000000000000000000000000000000000000000000000F
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000002
@yonghumeijj When you encode an arg that starts with 0x
, Delphereum will interpret that as a number or an address. You will want to pass in a string that starts with 0b
, for example: web3.utils.toBin(BigInteger.Create('0x0f00000002'))