0

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
            ,DefaultBlockParameterName.LATEST).sendAsync().get();
    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.

0

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 acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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