public class ETHTool extends Object
| 构造器和说明 |
|---|
ETHTool() |
| 限定符和类型 | 方法和说明 |
|---|---|
static EthSendTransactionPo |
addFeeRechargeErc20(String fromAddress,
String privateKey,
BigInteger value,
String toAddress,
String multySignContractAddress,
String bep20ContractAddress,
BigInteger gasPrice,
BigInteger nonce)
(充值ERC20资产)追加手续费
BSC网络向NERVE网络充值BEP20资产
|
static EthSendTransactionPo |
addFeeRechargeEth(String fromAddress,
String privateKey,
BigInteger value,
String toAddress,
String multySignContractAddress,
BigInteger gasPrice,
BigInteger nonce)
(充值ETH) 追加手续费
BSC网络向NERVE网络充值BNB
|
static String |
authorization(String fromAddress,
String privateKey,
String multySignContractAddress,
String erc20ContractAddress)
授权使用ERC20资产
|
static List<org.web3j.abi.datatypes.Type> |
callViewFunction(String contractAddress,
org.web3j.abi.datatypes.Function function)
调用合约的view/constant函数
|
static BigDecimal |
calNVTByGasPrice(BigDecimal nvtUSD,
BigDecimal gasPrice,
BigDecimal ethUSD,
BigDecimal gasLimit) |
static BigDecimal |
calNVTOfWithdraw(BigDecimal nvtUSD,
BigDecimal gasPrice,
BigDecimal ethUSD,
boolean isETHToken) |
static EthSendTransactionPo |
createRechargeErc20(String fromAddress,
String privateKey,
BigInteger value,
String toAddress,
String multySignContractAddress,
String erc20ContractAddress)
充值ERC20资产
以太坊网络向NERVE网络充值ERC20资产
|
static EthSendTransactionPo |
createRechargeEth(String fromAddress,
String privateKey,
BigInteger value,
String toAddress,
String multySignContractAddress)
(只组装交易)充值ETH
以太坊网络向NERVE网络充值ETH
|
static EthSendTransactionPo |
createTransferErc20(String fromAddress,
String privateKey,
String toAddress,
BigInteger value,
String contractAddress,
BigInteger gasLimit,
BigInteger gasPrice)
在ETH上转账ERC20资产(只组装交易 不广播)
|
static EthSendTransactionPo |
createTransferEth(String fromAddress,
String privateKey,
String toAddress,
BigDecimal value,
BigInteger gasLimit,
BigInteger gasPrice)
在ETH上转账ETH资产(只组装交易 不广播)
|
static int |
getContractTokenDecimals(String tokenContract) |
static BigInteger |
getCurrentGasPrice() |
static BigInteger |
getErc20Balance(String address,
String contractAddress)
获取ERC20资产余额
|
static BigDecimal |
getEthBalance(String address)
获取ETH资产余额
|
static org.web3j.protocol.core.methods.response.TransactionReceipt |
getTxReceipt(String txHash) |
static void |
init(String rpcAddress)
自定义 ETH RPC地址
|
static boolean |
isAuthorized(String fromAddress,
String multySignContractAddress,
String erc20ContractAddress)
查询是否已经授权使用ERC20资产
|
static MetaMaskWalletApi |
metaMask() |
static EthSendTransactionPo |
rechargeErc20(String fromAddress,
String privateKey,
BigInteger value,
String toAddress,
String multySignContractAddress,
String erc20ContractAddress)
充值ERC20资产
以太坊网络向NERVE网络充值ERC20资产
|
static EthSendTransactionPo |
rechargeEth(String fromAddress,
String privateKey,
BigInteger value,
String toAddress,
String multySignContractAddress)
充值ETH
以太坊网络向NERVE网络充值ETH
|
static BigInteger |
totalSupply(String contractAddress) |
static org.web3j.protocol.core.methods.response.EthSendTransaction |
transferErc20(String fromAddress,
String privateKey,
String toAddress,
BigInteger value,
String contractAddress,
BigInteger gasLimit,
BigInteger gasPrice)
在ETH上转账ERC20资产
|
static String |
transferEth(String fromAddress,
String privateKey,
String toAddress,
BigDecimal value,
BigInteger gasLimit,
BigInteger gasPrice)
在ETH上转账ETH资产
|
public static MetaMaskWalletApi metaMask()
public static void init(String rpcAddress)
rpcAddress - public static String transferEth(String fromAddress, String privateKey, String toAddress, BigDecimal value, BigInteger gasLimit, BigInteger gasPrice) throws Exception
fromAddress - 转出地址privateKey - 转出地址私钥toAddress - 接收地址value - 转出数量gasLimit - gasPrice - Exceptionpublic static EthSendTransactionPo createTransferEth(String fromAddress, String privateKey, String toAddress, BigDecimal value, BigInteger gasLimit, BigInteger gasPrice) throws Exception
fromAddress - 转出地址privateKey - 转出地址私钥toAddress - 接收地址value - 转出数量gasLimit - gasPrice - Exceptionpublic static org.web3j.protocol.core.methods.response.EthSendTransaction transferErc20(String fromAddress, String privateKey, String toAddress, BigInteger value, String contractAddress, BigInteger gasLimit, BigInteger gasPrice) throws Exception
fromAddress - 转出地址privateKey - 转出地址私钥toAddress - 接收地址value - 转出数量(根据小数位数换算后的整数)contractAddress - ERC20资产合约地址Exceptionpublic static EthSendTransactionPo createTransferErc20(String fromAddress, String privateKey, String toAddress, BigInteger value, String contractAddress, BigInteger gasLimit, BigInteger gasPrice) throws Exception
fromAddress - 转出地址privateKey - 转出地址私钥toAddress - 接收地址value - 转出数量(根据小数位数换算后的整数)contractAddress - ERC20资产合约地址Exceptionpublic static BigDecimal getEthBalance(String address) throws Exception
address - Exceptionpublic static BigInteger getErc20Balance(String address, String contractAddress) throws Exception
address - contractAddress - Exceptionpublic static EthSendTransactionPo rechargeEth(String fromAddress, String privateKey, BigInteger value, String toAddress, String multySignContractAddress) throws Exception
fromAddress - 转出地址privateKey - 转出地址私钥value - 转出数量(根据小数位数换算后的整数)toAddress - 接收token的NERVE地址multySignContractAddress - 多签合约地址Exceptionpublic static EthSendTransactionPo addFeeRechargeEth(String fromAddress, String privateKey, BigInteger value, String toAddress, String multySignContractAddress, BigInteger gasPrice, BigInteger nonce) throws Exception
fromAddress - 转出地址privateKey - 转出地址私钥value - 转出数量(根据小数位数换算后的整数)toAddress - 接收token的NERVE地址multySignContractAddress - 多签合约地址Exceptionpublic static EthSendTransactionPo createRechargeEth(String fromAddress, String privateKey, BigInteger value, String toAddress, String multySignContractAddress) throws Exception
fromAddress - 转出地址privateKey - 转出地址私钥value - 转出数量(根据小数位数换算后的整数)toAddress - 接收token的NERVE地址multySignContractAddress - 多签合约地址Exceptionpublic static EthSendTransactionPo rechargeErc20(String fromAddress, String privateKey, BigInteger value, String toAddress, String multySignContractAddress, String erc20ContractAddress) throws Exception
fromAddress - 转出地址privateKey - 转出地址私钥value - 转出数量(根据小数位数换算后的整数)toAddress - 接收token的NERVE地址multySignContractAddress - 多签合约地址erc20ContractAddress - ERC20 token合约地址Exceptionpublic static EthSendTransactionPo createRechargeErc20(String fromAddress, String privateKey, BigInteger value, String toAddress, String multySignContractAddress, String erc20ContractAddress) throws Exception
fromAddress - 转出地址privateKey - 转出地址私钥value - 转出数量(根据小数位数换算后的整数)toAddress - 接收token的NERVE地址multySignContractAddress - 多签合约地址erc20ContractAddress - ERC20 token合约地址Exceptionpublic static EthSendTransactionPo addFeeRechargeErc20(String fromAddress, String privateKey, BigInteger value, String toAddress, String multySignContractAddress, String bep20ContractAddress, BigInteger gasPrice, BigInteger nonce) throws Exception
fromAddress - 转出地址privateKey - 转出地址私钥value - 转出数量(根据小数位数换算后的整数)toAddress - 接收token的NERVE地址multySignContractAddress - 多签合约地址bep20ContractAddress - BEP20 token合约地址Exceptionpublic static String authorization(String fromAddress, String privateKey, String multySignContractAddress, String erc20ContractAddress) throws Exception
fromAddress - 转出地址privateKey - 转出地址私钥multySignContractAddress - 多签合约地址erc20ContractAddress - ERC20 token合约地址Exceptionpublic static boolean isAuthorized(String fromAddress, String multySignContractAddress, String erc20ContractAddress) throws Exception
fromAddress - 转出地址multySignContractAddress - 多签合约地址erc20ContractAddress - ERC20 token合约地址Exceptionpublic static List<org.web3j.abi.datatypes.Type> callViewFunction(String contractAddress, org.web3j.abi.datatypes.Function function) throws Exception
contractAddress - function - Exceptionpublic static org.web3j.protocol.core.methods.response.TransactionReceipt getTxReceipt(String txHash) throws Exception
Exceptionpublic static int getContractTokenDecimals(String tokenContract) throws Exception
Exceptionpublic static BigInteger totalSupply(String contractAddress) throws Exception
Exceptionpublic static BigInteger getCurrentGasPrice() throws IOException
IOExceptionpublic static BigDecimal calNVTOfWithdraw(BigDecimal nvtUSD, BigDecimal gasPrice, BigDecimal ethUSD, boolean isETHToken)
public static BigDecimal calNVTByGasPrice(BigDecimal nvtUSD, BigDecimal gasPrice, BigDecimal ethUSD, BigDecimal gasLimit)
Copyright © 2021. All rights reserved.