I am trying to retrieve the total transaction count of an address using java, web3j and Infura as the Ethereum client. My code is as below:

EthGetTransactionCount txnCount = web3j.ethGetTransactionCount(infuraAccessToken
    BigInteger nonce = txnCount.getTransactionCount();       
    System.out.println("Transaction Count "+ nonce);

But I keep getting the following error:

    Exception in thread "main" org.web3j.exceptions.MessageDecodingException: Value must be in format 0x[1-9]+[0-9]* or 0x0     
    at org.web3j.utils.Numeric.decodeQuantity(Numeric.java:32)  
    at org.web3j.protocol.core.methods.response.EthGetTransactionCount.getTransactionCount(EthGetTransactionCount.java:13)  
    at com.mycompany.hellospring.NewClass.main(NewClass.java:46)

I am unable to find any solution related to this till now.

1 Answer 1


I was giving the access token provided by Infura in place of the address. So now I'm not getting the message decode exception. However, now O is always being returned as the transaction count which is incorrect.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.