Skip to content

Cannot decode to DynamicStruct #2168

Open
@formingform

Description

@formingform

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);
    }
 

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA bug in behaviour or functionality

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions