开发者社区> 问答> 正文

Error processing request:unknown transaction

Error processing request:unknown transaction

展开
收起
景凌凯 2020-03-18 18:58:49 1079 0
1 条回答
写回答
取消 提交回答
  • 有点尴尬唉 你要寻找的东西已经被吃掉啦!

    这个问题应该发生在TransactionReceiptProcessor内部。

    当调用web3j.ethGetTransactionReceipt(transactionHash).send()时内部会执行waitForTransactionReceipt。

    你的节点可能还没有彻底准备好,无法给你提供一个有效的TransactionReceipt。

    你可以通过手动构建交易来解决这个问题:

    Web3j web3 = Web3j.build(new HttpService()); // defaults to http://localhost:8545/ Credentials credentials = WalletUtils.loadCredentials("password", "/path/to/walletfile");

    // get the next available nonce EthGetTransactionCount ethGetTransactionCount = web3j.ethGetTransactionCount( address, DefaultBlockParameterName.LATEST).sendAsync().get(); BigInteger nonce = ethGetTransactionCount.getTransactionCount();

    // create our transaction RawTransaction rawTransaction = RawTransaction.createEtherTransaction( nonce, , , , );

    // sign & send our transaction byte[] signedMessage = TransactionEncoder.signMessage(rawTransaction, credentials); String hexValue = Hex.toHexString(signedMessage); // FROM here you can get the tx hash. EthSendTransaction ethSendTransaction = web3j.ethSendRawTransaction(hexValue).send();

    虽然可以使用自定义的交易管理器,但尽量尝试更改轮询的次数来增加获得txhash的概率。

    public static final int DEFAULT_POLLING_ATTEMPTS_PER_TX_HASH = 40; public static final long DEFAULT_POLLING_FREQUENCY = 1000 * 15;

    例如:

    new Transfer(client, new ClientTransactionManager(client ,fromAddress, 100))

    另外一个明确的方法:

     val txManager  = new RawTransactionManager(client,credentials,100,1000 * 15)
     val transfer   = new Transfer(client,txManager)
    
     transfer.sendFunds(
         walletAddress,
         amount,
         currency.convert)
    
    2020-03-18 18:58:59
    赞同 展开评论 打赏
问答地址:
问答排行榜
最热
最新

相关电子书

更多
Genomic Data Processing 立即下载
Stream Processing takes on Everything 立即下载
Scaling Spark applications by connecting code to resource consumption 立即下载