我的代码正在调用web3j.ethGetTransactionCount并返回一个错误条件。我正在使用web3j 4.0.0。代码成功地连接到我的私有区块链并加载我的凭据。
失败的语句是带有注释“//get the next available nonce”的语句。web3j.ethGetTransactionCount毫无异常地返回,但其错误成员填充了代码-32601,并显示消息“ethGetTransactionCount方法不存在/不可用”。
显示的最后一个语句是抛出异常的语句,这并不奇怪,因为前面的语句失败了。
public static void main( String[] args )
{
Web3j web3j;
Web3ClientVersion web3ClientVersion;
Credentials credentials;
log.info("Starting program...");
web3j = Web3j.build(new HttpService());
try {
credentials = WalletUtils.loadCredentials("abcdef77654", "d:/ethPrivate/keystore/UTC--2019-01-09T17-59-33.005885600Z--03cead4ffe2768522aa2549f586b308b2d4cc19e");
// get the next available nonce
EthGetTransactionCount ethGetTransactionCount = web3j.ethGetTransactionCount("0x03cead4ffe2768522aa2549f586b308b2d4cc19e", DefaultBlockParameterName.LATEST).send();
BigInteger nonce = ethGetTransactionCount.getTransactionCount();
我已经从web3j github上的示例中复制了这段代码,所以很惊讶它没有工作。感激地接受了任何建议。