| | |
| | | * 服务器地址
|
| | | */
|
| | | //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 {
|
| | |
| | | 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);
|
| | |
| | | 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("50", Convert.Unit.GWEI).toBigInteger(),
|
| | | Convert.toWei("60000", Convert.Unit.WEI).toBigInteger(), toAddress, value);
|
| | | byte[] signedMessage = TransactionEncoder.signMessage(rawTransaction, credentials);
|
| | | String hexValue = Numeric.toHexString(signedMessage);
|