svanas / delphereum

web3 implementation for the Delphi programming language

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

i mean question ...how to use this to encode bytes32 param

yonghumeijj opened this issue · comments

example:
func(address,bytes32)

how to encode it local.not call network.

last issuse i mean your sample :
procedure TTests.TestCase9;
begin
const SS: ISingleSwap = TSingleSwap.Create
.Kind(GivenOut)
.PoolId(byteArrayToBytes32(web3.utils.fromHex('0x61d5dc44849c9c87b0856a2a311536205c96c7fd000200000000000000000000')))
.AssetIn(TAddress('0xdFCeA9088c8A88A76FF74892C1457C17dfeef9C1').ToChecksum) // WETH
.AssetOut(TAddress('0x41286Bb1D3E870f3F750eB7E1C25d7E48c8A1Ac7').ToChecksum) // BAL
.Amount(web3.utils.scale(100, 18)); // 100 BAL
Assert.AreEqual(
web3.eth.abi.encode(
'swap(' +
'(bytes32,uint8,address,address,uint256,bytes)' +
')',
[SS]
).ToLower,
'0x8fc89ecf' +
'0000000000000000000000000000000000000000000000000000000000000020' +
'61d5dc44849c9c87b0856a2a311536205c96c7fd000200000000000000000000' +
'0000000000000000000000000000000000000000000000000000000000000001' +
'000000000000000000000000dfcea9088c8a88a76ff74892c1457c17dfeef9c1' +
'00000000000000000000000041286bb1d3e870f3f750eb7e1c25d7e48c8a1ac7' +
'0000000000000000000000000000000000000000000000056bc75e2d63100000' +
'00000000000000000000000000000000000000000000000000000000000000c0' +
'0000000000000000000000000000000000000000000000000000000000000000'
);
end;

this is the only one about bytes32.but not a normal param .PoolId is a menber in tuple.

bytes32 is an array of exactly 32 bytes. You can use the byteArrayToBytes32 helper function, or you can pass exactly 32 bytes. Then hex-encode are argument before you pass it to web3.eth.call.

Please don't open new issues for questions that aren't bugs.