public class HTTool extends Object
| 构造器和说明 |
|---|
HTTool() |
| 限定符和类型 | 方法和说明 |
|---|---|
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 |
addFeeRechargeHt(String fromAddress,
String privateKey,
BigInteger value,
String toAddress,
String multySignContractAddress,
BigInteger gasPrice,
BigInteger nonce)
(充值HT) 追加手续费
HECO网络向NERVE网络充值HT
|
static String |
authorization(String fromAddress,
String privateKey,
String multySignContractAddress,
String bep20ContractAddress)
授权使用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 isHTToken) |
static EthSendTransactionPo |
createRechargeErc20(String fromAddress,
String privateKey,
BigInteger value,
String toAddress,
String multySignContractAddress,
String bep20ContractAddress)
(只组装交易)充值ERC20资产
HECO网络向NERVE网络充值ERC20资产
|
static EthSendTransactionPo |
createRechargeHt(String fromAddress,
String privateKey,
BigInteger value,
String toAddress,
String multySignContractAddress)
(只组装交易)充值HT
HECO网络向NERVE网络充值HT
|
static EthSendTransactionPo |
createTransferErc20(String fromAddress,
String privateKey,
String toAddress,
BigInteger amount,
String contractAddress,
BigInteger gasLimit,
BigInteger gasPrice)
在HECO上转账ERC20资产(只组装交易 不广播)
|
static EthSendTransactionPo |
createTransferHt(String fromAddress,
String privateKey,
String toAddress,
BigDecimal amount,
BigInteger gasLimit,
BigInteger gasPrice)
在BSC上转账HT资产(只组装交易 不广播)
|
static String |
ethSign(String priKey,
String dataHex) |
static int |
getContractTokenDecimals(String tokenContract) |
static BigInteger |
getCurrentGasPrice() |
static BigInteger |
getErc20Balance(String address,
String contractAddress)
获取ERC20资产余额
|
static BigDecimal |
getHtBalance(String address)
获取HT资产余额
|
static org.web3j.protocol.core.methods.response.TransactionReceipt |
getTxReceipt(String txHash) |
static boolean |
init(String rpcAddress,
int chainId)
自定义BSC RPC地址
|
static boolean |
isAuthorized(String fromAddress,
String multySignContractAddress,
String bep20ContractAddress)
查询是否已经授权使用ERC20资产
|
static MetaMaskWalletApi |
metaMask() |
static String |
personalSign(String priKey,
String data) |
static EthSendTransactionPo |
rechargeErc20(String fromAddress,
String privateKey,
BigInteger value,
String toAddress,
String multySignContractAddress,
String bep20ContractAddress)
充值ERC20资产
HECO网络向NERVE网络充值ERC20资产
|
static EthSendTransactionPo |
rechargeHt(String fromAddress,
String privateKey,
BigInteger value,
String toAddress,
String multySignContractAddress)
充值HT
HECO网络向NERVE网络充值HT
|
static String |
signTypedDataV4(String priKey,
String json) |
static BigInteger |
totalSupply(String contractAddress) |
static org.web3j.protocol.core.methods.response.EthSendTransaction |
transferErc20(String fromAddress,
String privateKey,
String toAddress,
BigInteger amount,
String contractAddress,
BigInteger gasLimit,
BigInteger gasPrice)
在HECO上转账ERC20资产
|
static String |
transferHt(String fromAddress,
String privateKey,
String toAddress,
BigDecimal amount,
BigInteger gasLimit,
BigInteger gasPrice)
在BSC上转账HT资产
|
static WalletApi |
walletApi() |
public static MetaMaskWalletApi metaMask()
public static WalletApi walletApi()
public static boolean init(String rpcAddress, int chainId)
rpcAddress - public static String transferHt(String fromAddress, String privateKey, String toAddress, BigDecimal amount, BigInteger gasLimit, BigInteger gasPrice) throws Exception
fromAddress - 转出地址privateKey - 转出地址私钥toAddress - 接收地址amount - 转出数量gasLimit - gasPrice - Exceptionpublic static EthSendTransactionPo createTransferHt(String fromAddress, String privateKey, String toAddress, BigDecimal amount, BigInteger gasLimit, BigInteger gasPrice) throws Exception
fromAddress - 转出地址privateKey - 转出地址私钥toAddress - 接收地址amount - 转出数量gasLimit - gasPrice - Exceptionpublic static org.web3j.protocol.core.methods.response.EthSendTransaction transferErc20(String fromAddress, String privateKey, String toAddress, BigInteger amount, String contractAddress, BigInteger gasLimit, BigInteger gasPrice) throws Exception
fromAddress - 转出地址privateKey - 转出地址私钥toAddress - 接收地址amount - 转出数量(根据小数位数换算后的整数)contractAddress - ERC20资产合约地址Exceptionpublic static EthSendTransactionPo createTransferErc20(String fromAddress, String privateKey, String toAddress, BigInteger amount, String contractAddress, BigInteger gasLimit, BigInteger gasPrice) throws Exception
fromAddress - 转出地址privateKey - 转出地址私钥toAddress - 接收地址amount - 转出数量(根据小数位数换算后的整数)contractAddress - ERC20资产合约地址Exceptionpublic static BigDecimal getHtBalance(String address) throws Exception
address - Exceptionpublic static BigInteger getErc20Balance(String address, String contractAddress) throws Exception
address - contractAddress - Exceptionpublic static EthSendTransactionPo rechargeHt(String fromAddress, String privateKey, BigInteger value, String toAddress, String multySignContractAddress) throws Exception
fromAddress - 转出地址privateKey - 转出地址私钥value - 转出数量(根据小数位数换算后的整数)toAddress - 接收token的NERVE地址multySignContractAddress - 多签合约地址Exceptionpublic static EthSendTransactionPo createRechargeHt(String fromAddress, String privateKey, BigInteger value, String toAddress, String multySignContractAddress) throws Exception
fromAddress - 转出地址privateKey - 转出地址私钥value - 转出数量(根据小数位数换算后的整数)toAddress - 接收token的NERVE地址multySignContractAddress - 多签合约地址Exceptionpublic static EthSendTransactionPo addFeeRechargeHt(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 rechargeErc20(String fromAddress, String privateKey, BigInteger value, String toAddress, String multySignContractAddress, String bep20ContractAddress) throws Exception
fromAddress - 转出地址privateKey - 转出地址私钥value - 转出数量(根据小数位数换算后的整数)toAddress - 接收token的NERVE地址multySignContractAddress - 多签合约地址bep20ContractAddress - ERC20 token合约地址Exceptionpublic static EthSendTransactionPo createRechargeErc20(String fromAddress, String privateKey, BigInteger value, String toAddress, String multySignContractAddress, String bep20ContractAddress) throws Exception
fromAddress - 转出地址privateKey - 转出地址私钥value - 转出数量(根据小数位数换算后的整数)toAddress - 接收token的NERVE地址multySignContractAddress - 多签合约地址bep20ContractAddress - 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 bep20ContractAddress) throws Exception
fromAddress - 转出地址privateKey - 转出地址私钥multySignContractAddress - 多签合约地址bep20ContractAddress - ERC20 token合约地址Exceptionpublic static boolean isAuthorized(String fromAddress, String multySignContractAddress, String bep20ContractAddress) throws Exception
fromAddress - 转出地址multySignContractAddress - 多签合约地址bep20ContractAddress - 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 isHTToken)
public static BigDecimal calNVTByGasPrice(BigDecimal nvtUSD, BigDecimal gasPrice, BigDecimal ethUSD, BigDecimal gasLimit)
public static String signTypedDataV4(String priKey, String json) throws IOException
IOExceptionCopyright © 2021. All rights reserved.