i.e: { "components":[ { "internalType":"uint256", "name":"orderIndex", "type":"uint256" }, { "internalType":"uint256", "name":"itemIndex", "type":"uint256" } ], "internalType":"struct FulfillmentComponent[][]", "name":"", "type":"tuple[][]" }
================web3j=================== /*
offerFulfillments = [[{"orderIndex":0,"itemIndex":0}],[{"orderIndex":1,"itemIndex":0}]] */ List encodedParameters = new ArrayList<>(); encodedParameters.add( new DynamicArray( DynamicArray.class, offerFulfillments.stream().map(ov -> new DynamicArray<>( DynamicStruct.class, ov.stream().map(iv -> new DynamicStruct( new Uint256(iv.getOrderIndex()), new Uint256(iv.getItemIndex())) ).collect(Collectors.toList()) ) ).collect(Collectors.toList()) ) ); return FunctionEncoder.encodeConstructor(encodedParameters); the encode data is : 0000000000000000000000000000000000000000000000000000000000000020 0000000000000000000000000000000000000000000000000000000000000002 0000000000000000000000000000000000000000000000000000000000000001 -- the 1 0000000000000000000000000000000000000000000000000000000000000020 -- 32(dynamicArray + 32) 0000000000000000000000000000000000000000000000000000000000000000 -- 0 0000000000000000000000000000000000000000000000000000000000000000 -- 0 0000000000000000000000000000000000000000000000000000000000000001 -- the 2 0000000000000000000000000000000000000000000000000000000000000020 -- 32(dynamicArray + 32) 0000000000000000000000000000000000000000000000000000000000000001 -- 1 0000000000000000000000000000000000000000000000000000000000000000 -- 0
=============================web3js================ abi = { "components":[ { "internalType":"uint256", "name":"orderIndex", "type":"uint256" }, { "internalType":"uint256", "name":"itemIndex", "type":"uint256" } ], "internalType":"struct FulfillmentComponent[][]", "name":"", "type":"tuple[][]" };
const functionSignature = web3.eth.abi.encodeFunctionCall(abi, [offerFulfillments]);
the i get the encode data is
0000000000000000000000000000000000000000000000000000000000000020 0000000000000000000000000000000000000000000000000000000000000002 -- total 2 0000000000000000000000000000000000000000000000000000000000000040 -- offset of 1 00000000000000000000000000000000000000000000000000000000000000a0 -- offset of 2 0000000000000000000000000000000000000000000000000000000000000001 -- the 1 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000001 -- the 2 0000000000000000000000000000000000000000000000000000000000000001 0000000000000000000000000000000000000000000000000000000000000000
================================result=============== web3js is right; web3j is wrong
so ,how to get the right data with web3j to encode struct FulfillmentComponent[][]