public class HTTool extends Object
| 构造器和说明 |
|---|
HTTool() |
| 限定符和类型 | 方法和说明 |
|---|---|
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 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 void |
init(String rpcAddress)
自定义BSC RPC地址
|
static boolean |
isAuthorized(String fromAddress,
String multySignContractAddress,
String bep20ContractAddress)
查询是否已经授权使用ERC20资产
|
static String |
rechargeErc20(String fromAddress,
String privateKey,
BigInteger value,
String toAddress,
String multySignContractAddress,
String bep20ContractAddress)
充值ERC20资产
HECO网络向NERVE网络充值ERC20资产
|
static String |
rechargeHt(String fromAddress,
String privateKey,
BigInteger value,
String toAddress,
String multySignContractAddress)
充值HT
HECO网络向NERVE网络充值HT
|
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)
在BSC上转账ERC20资产
|
static String |
transferHt(String fromAddress,
String privateKey,
String toAddress,
BigDecimal amount,
BigInteger gasLimit,
BigInteger gasPrice)
在BSC上转账HT资产
|
public static void init(String rpcAddress)
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 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 BigDecimal getHtBalance(String address) throws Exception
address - Exceptionpublic static BigInteger getErc20Balance(String address, String contractAddress) throws Exception
address - contractAddress - Exceptionpublic static String rechargeHt(String fromAddress, String privateKey, BigInteger value, String toAddress, String multySignContractAddress) throws Exception
fromAddress - 转出地址privateKey - 转出地址私钥value - 转出数量(根据小数位数换算后的整数)toAddress - 接收token的NERVE地址multySignContractAddress - 多签合约地址Exceptionpublic static String 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 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)
Copyright © 2021. All rights reserved.