Using java and ethers to achieve the same function, but the results are inconsistent

Viewed 27

ethers:

console.log(ethers.utils.defaultAbiCoder.encode(["uint256", "bytes"], ["100000000000000","0x000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb922660000000000000000000000000000000000000000000000000000000000000001"]));

result:0x00000000000000000000000000000000000000000000000000005af3107a400000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000040000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb922660000000000000000000000000000000000000000000000000000000000000001

java:

BigInteger amount = new BigInteger("100000000000000");

        DynamicStruct struct = new DynamicStruct(new Address("0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"),new Uint8(1));
        StaticArray1<DynamicStruct> array1 = new StaticArray1<>(DynamicStruct.class,struct);

        DynamicStruct struct1 = new DynamicStruct(new Uint256(amount),array1);

        System.out.println("---" + TypeEncoder.encode(struct1));

result: 00000000000000000000000000000000000000000000000000005af3107a400000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000020000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb922660000000000000000000000000000000000000000000000000000000000000001

The ethers result contains two 4's, but the java result has one 4 and one 2, which confuses me

0 Answers
Related