web3j Java:gas * 价格 + 价值的资金不足

问题描述

我正在尝试在主网上发送以太坊。

我的当前余额 = 2891999967219000 wei

乙醚中的气体限制:9E-12

以太坊的 Gas 价格:4.1E-9

我想转移当前余额的 1/10,但收到错误消息:

gas * 价格 + 价值的资金不足

下面是我的代码

    EthGetTransactionCount ethGetTransactionCount = web3.ethGetTransactionCount(credentials.getAddress(),DefaultBlockParameterName.LATEST).sendAsync().get();
    BigInteger nonce = ethGetTransactionCount.getTransactionCount();

    System.out.println("CALC REQUIRE AMOUNT = " + DefaultGasProvider.GAS_PRICE + " * " + DefaultGasProvider.GAS_LIMIT + " + " + new BigInteger("" + wei.divide(new BigInteger("10"))));
    System.out.println("= " + (DefaultGasProvider.GAS_PRICE.multiply(DefaultGasProvider.GAS_LIMIT).add(new BigInteger("" + wei.divide(new BigInteger("10"))))));
    RawTransaction rawTransaction = RawTransaction.createEtherTransaction(nonce,DefaultGasProvider.GAS_PRICE,DefaultGasProvider.GAS_LIMIT,toAddress,new BigInteger("" + wei.divide(new BigInteger("10"))));

    byte[] signedMessage = TransactionEncoder.signMessage(rawTransaction,credentials);
    String hexValue = Numeric.toHexString(signedMessage);
    // FROM here you can get the tx hash.
    EthSendTransaction ethSendTransaction = web3.ethSendRawTransaction(hexValue).send(); 

谁能帮我解决这个问题。谢谢

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...