From 5ffadf76db128839a93a5588ec42aa4745b2f2af Mon Sep 17 00:00:00 2001
From: wzy <wzy19931122ai@163.com>
Date: Thu, 29 Oct 2020 20:24:34 +0800
Subject: [PATCH] Merge branch 'pilot' of https://gitee.com/chonggaoxiao/new_excoin into pilot
---
src/main/java/com/xcong/excoin/modules/blackchain/service/EthService.java | 18 ++++++++++++------
1 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/src/main/java/com/xcong/excoin/modules/blackchain/service/EthService.java b/src/main/java/com/xcong/excoin/modules/blackchain/service/EthService.java
index c2c9379..9eceda7 100644
--- a/src/main/java/com/xcong/excoin/modules/blackchain/service/EthService.java
+++ b/src/main/java/com/xcong/excoin/modules/blackchain/service/EthService.java
@@ -13,6 +13,7 @@
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
+import org.apache.commons.lang3.StringUtils;
import org.web3j.abi.FunctionEncoder;
import org.web3j.abi.FunctionReturnDecoder;
import org.web3j.abi.TypeReference;
@@ -54,7 +55,7 @@
* 服务器地址
*/
//private static final String ETH_UTL = "https://mainnet.infura.io/v3/882c66ebcfc141abbea22b948fa44321";
- private static final String ETH_UTL = "http://120.55.86.146:8545";
+ private static final String ETH_UTL = "http://114.55.250.231:8545";
public EthService() {
try {
@@ -209,10 +210,13 @@
}
// USDT
- public String tokenSend(String privateKey, String fromAddress, String toAddress, String amount)
+ public String tokenSend(String privateKey, String fromAddress, String toAddress, String amount,String gas)
throws InterruptedException, ExecutionException {
// Web3j web3j = Web3j.build(new
// HttpService("https://mainnet.infura.io/v3/882c66ebcfc141abbea22b948fa44321"));
+ if(StringUtils.isBlank(gas)){
+ gas="70";
+ }
String contractAddress = "0xdac17f958d2ee523a2206206994597c13d831ec7";
Credentials credentials = Credentials.create(privateKey);
@@ -229,7 +233,7 @@
String encodedFunction = FunctionEncoder.encode(function);
RawTransaction rawTransaction = RawTransaction.createTransaction(nonce,
- Convert.toWei("70", Convert.Unit.GWEI).toBigInteger(),// 给矿工开的转账单价 单价越高越快
+ Convert.toWei(gas, Convert.Unit.GWEI).toBigInteger(),// 给矿工开的转账单价 单价越高越快
Convert.toWei("60000", Convert.Unit.WEI).toBigInteger(), contractAddress, encodedFunction);//里程上限
// 10*80000/1000000000=0.0008 手续费
@@ -252,11 +256,13 @@
}
}
- public String ethSend(String privateKey, String fromAddress, String toAddress, String amount)
+ public String ethSend(String privateKey, String fromAddress, String toAddress, String amount,String gas)
throws InterruptedException, ExecutionException {
// Web3j web3j = Web3j.build(new
// HttpService("https://mainnet.infura.io/v3/882c66ebcfc141abbea22b948fa44321"));
-
+ if(StringUtils.isBlank(gas)){
+ gas="70";
+ }
Credentials credentials = Credentials.create(privateKey);
EthGetTransactionCount ethGetTransactionCount = web3j
@@ -265,7 +271,7 @@
BigInteger nonce = ethGetTransactionCount.getTransactionCount();
BigInteger value = Convert.toWei(amount, Convert.Unit.ETHER).toBigInteger();
RawTransaction rawTransaction = RawTransaction.createEtherTransaction(nonce,
- Convert.toWei("70", Convert.Unit.GWEI).toBigInteger(),
+ Convert.toWei(gas, Convert.Unit.GWEI).toBigInteger(),
Convert.toWei("60000", Convert.Unit.WEI).toBigInteger(), toAddress, value);
byte[] signedMessage = TransactionEncoder.signMessage(rawTransaction, credentials);
String hexValue = Numeric.toHexString(signedMessage);
--
Gitblit v1.9.1