public class BSCTool extends Object
| 构造器和说明 |
|---|
BSCTool() |
| 限定符和类型 | 方法和说明 |
|---|---|
static String |
authorization(String fromAddress,
String privateKey,
String multySignContractAddress,
String bep20ContractAddress)
授权使用BEP20资产
|
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 isBNBToken) |
static BigInteger |
getBep20Balance(String address,
String contractAddress)
获取BEP20资产余额
|
static BigDecimal |
getBnbBalance(String address)
获取BNB资产余额
|
static int |
getContractTokenDecimals(String tokenContract) |
static BigInteger |
getCurrentGasPrice() |
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)
查询是否已经授权使用BEP20资产
|
static String |
rechargeBep20(String fromAddress,
String privateKey,
BigInteger value,
String toAddress,
String multySignContractAddress,
String bep20ContractAddress)
充值BEP20资产
BSC网络向NERVE网络充值BEP20资产
|
static String |
rechargeBnb(String fromAddress,
String privateKey,
BigInteger value,
String toAddress,
String multySignContractAddress)
充值BNB
BSC网络向NERVE网络充值BNB
|
static BigInteger |
totalSupply(String contractAddress) |
static org.web3j.protocol.core.methods.response.EthSendTransaction |
transferBep20(String fromAddress,
String privateKey,
String toAddress,
BigInteger amount,
String contractAddress,
BigInteger gasLimit,
BigInteger gasPrice)
在BSC上转账BEP20资产
|
static String |
transferBnb(String fromAddress,
String privateKey,
String toAddress,
BigDecimal amount,
BigInteger gasLimit,
BigInteger gasPrice)
在BSC上转账BNB资产
|
public static void init(String rpcAddress)
rpcAddress - public static String transferBnb(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 transferBep20(String fromAddress, String privateKey, String toAddress, BigInteger amount, String contractAddress, BigInteger gasLimit, BigInteger gasPrice) throws Exception
fromAddress - 转出地址privateKey - 转出地址私钥toAddress - 接收地址amount - 转出数量(根据小数位数换算后的整数)contractAddress - BEP20资产合约地址Exceptionpublic static BigDecimal getBnbBalance(String address) throws Exception
address - Exceptionpublic static BigInteger getBep20Balance(String address, String contractAddress) throws Exception
address - contractAddress - Exceptionpublic static String rechargeBnb(String fromAddress, String privateKey, BigInteger value, String toAddress, String multySignContractAddress) throws Exception
fromAddress - 转出地址privateKey - 转出地址私钥value - 转出数量(根据小数位数换算后的整数)toAddress - 接收token的NERVE地址multySignContractAddress - 多签合约地址Exceptionpublic static String rechargeBep20(String fromAddress, String privateKey, BigInteger value, String toAddress, String multySignContractAddress, String bep20ContractAddress) 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 - BEP20 token合约地址Exceptionpublic static boolean isAuthorized(String fromAddress, String multySignContractAddress, String bep20ContractAddress) throws Exception
fromAddress - 转出地址multySignContractAddress - 多签合约地址bep20ContractAddress - BEP20 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 isBNBToken)
public static BigDecimal calNVTByGasPrice(BigDecimal nvtUSD, BigDecimal gasPrice, BigDecimal ethUSD, BigDecimal gasLimit)
Copyright © 2021. All rights reserved.