web3j icon indicating copy to clipboard operation
web3j copied to clipboard

Cannot decode to DynamicStruct

Open formingform opened this issue 10 months ago • 0 comments

web3j version: 12.0.0

solidity code like this:

abi.encode(_from, _to, _value)

Here is my JAVA test code, both TypeDecoder.decodeDynamicStruct() and TypeDecoder.decode() is failed. (The comments include the error message).

Test
    public void test_typeDecoder() {

// encoded 
 = "00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000001e078";
        String encoded =
                TypeEncoder.encode(
                        new DynamicStruct(
                                new Address("0x01"),
                                new Address("0x02"),
                                new Uint256(123000)));


        //Decode fails with: TypeReferenced struct must contain a constructor with types that extend Type
        //DynamicStruct struct = TypeDecoder.decodeDynamicStruct(encoded, 0, TypeReference.create(DynamicStruct.class));

        //Decode fails with: Array types must be wrapped in a TypeReference
        //DynamicStruct struct = TypeDecoder.decode(encoded, DynamicStruct.class);
    }
 

formingform avatar Mar 19 '25 10:03 formingform