esaulpaugh / headlong

High-performance Contract ABI and RLP for Ethereum
Apache License 2.0
79 stars 20 forks source link

com.esaulpaugh.headlong.abi.ArrayType cannot be cast to com.esaulpaugh.headlong.abi.TupleType #46

Closed ShoaibKakal closed 2 years ago

ShoaibKakal commented 2 years ago

I've a getName() that returns a string.

   val function = com.esaulpaugh.headlong.abi.Function("getName()", "string")
                    val encodedFunction = function.encodeCallWithArgs()
                    val arr: ByteArray = encodedFunction.array()

                    val stringEncode =FastHex.encodeToString(arr,0, arr.size)

                    val response = web3j.ethCall(
                        Transaction.createEthCallTransaction(
                            credentials.address,
                            deployedContractAddress,
                            stringEncode
                        ),
                        DefaultBlockParameterName.LATEST
                    )
                        .sendAsync().get()

                    val decodeResponse = function.decodeReturn(FastHex.decode(response.value))

I'm getting error that ArrayType cannot be cast to TupleType? How to get rid of this?

ShoaibKakal commented 2 years ago

i forgot adding braces around the outputs in Function Wrong: val function = com.esaulpaugh.headlong.abi.Function("getName()", "string") Correct: val function = com.esaulpaugh.headlong.abi.Function("getName()", "(string)")