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.