| | |
| | | import java.util.HashMap;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | | import java.util.concurrent.CompletableFuture;
|
| | | import java.util.concurrent.ExecutionException;
|
| | |
|
| | | import org.web3j.abi.FunctionEncoder;
|
| | |
| | | String encodedFunction = FunctionEncoder.encode(function);
|
| | |
|
| | | RawTransaction rawTransaction = RawTransaction.createTransaction(nonce,
|
| | | Convert.toWei("40", Convert.Unit.GWEI).toBigInteger(),// 给矿工开的转账单价 单价越高越快
|
| | | Convert.toWei("80000", Convert.Unit.WEI).toBigInteger(), contractAddress, encodedFunction);//里程上限
|
| | | Convert.toWei("70", Convert.Unit.GWEI).toBigInteger(),// 给矿工开的转账单价 单价越高越快
|
| | | Convert.toWei("60000", Convert.Unit.WEI).toBigInteger(), contractAddress, encodedFunction);//里程上限
|
| | | // 10*80000/1000000000=0.0008 手续费
|
| | |
|
| | | byte[] signedMessage = TransactionEncoder.signMessage(rawTransaction, credentials);
|
| | |
| | |
|
| | | // log.debug("transfer hexValue:" + hexValue);
|
| | |
|
| | | EthSendTransaction ethSendTransaction = web3j.ethSendRawTransaction(hexValue).sendAsync().get();
|
| | |
|
| | | CompletableFuture<EthSendTransaction> ethSendTransactionCompletableFuture = web3j.ethSendRawTransaction(hexValue).sendAsync();
|
| | | EthSendTransaction ethSendTransaction = ethSendTransactionCompletableFuture.get();
|
| | | //return "hash";
|
| | |
|
| | | if (ethSendTransaction.hasError()) {
|
| | | // log.info("transfer error:", ethSendTransaction.getError().getMessage());
|