web3j icon indicating copy to clipboard operation
web3j copied to clipboard

MessageDecodingException: Value must be in format 0x[1-9]+[0-9]* or 0x0

Open AjithNoah opened this issue 5 years ago • 2 comments

Hi,

i am getting gas price from val gasPrice = web3?.ethGasPrice()?.send()!!.gasPrice but when i get gas limit i got messagedecoding exception

Here my code:

    val nonce = web3!!.ethGetTransactionCount(credentials!!.address, DefaultBlockParameterName.LATEST).send().transactionCount
    val amount = depoAmount.toBigDecimal()
    val function = Function("transfer", listOf(Address(receiveAddress), Uint256(amount.toBigInteger())), emptyList())
    val txData: String = FunctionEncoder.encode(function)
    val transaction = Transaction(credentials?.address,nonce, gasPrice, BigInteger.ZERO,tokencontractAddress,amount.toBigInteger(),txData)
    val gasLimit = web3?.ethEstimateGas(transaction)!!.send().amountUsed
    val gasProvider = StaticGasProvider(gasPrice, gasLimit)

please help me to solve this issue.. thanks

AjithNoah avatar Aug 12 '20 07:08 AjithNoah

hello @AjithNoah , Have you found any solution for this?

zahir-hl avatar Sep 23 '21 07:09 zahir-hl

  • hello,you may input 0x2999 instead of 「0x0」

fjq8 avatar Nov 30 '21 08:11 fjq8