public class HtgWalletApi extends Object implements WalletApi, MetaMaskWalletApi
| 限定符和类型 | 字段和说明 |
|---|---|
protected org.web3j.protocol.Web3j |
web3j |
| 限定符和类型 | 方法和说明 |
|---|---|
String |
authorization(String fromAddress,
String prikey,
String multySignContractAddress,
String bep20Address)
ERC20 授权
|
org.web3j.crypto.RawTransaction |
authorizationWithoutSign(String fromAddress,
String multySignContractAddress,
String bep20Address)
ERC20 授权
|
List<org.web3j.abi.datatypes.Type> |
callViewFunction(String contractAddress,
org.web3j.abi.datatypes.Function function)
调用合约的view/constant函数
|
List<org.web3j.abi.datatypes.Type> |
callViewFunction(String contractAddress,
org.web3j.abi.datatypes.Function function,
boolean latest) |
protected void |
checkIfResetWeb3j(int times) |
BigInteger |
convertMainAssetToWei(BigDecimal value) |
String |
convertToNewAddress(String address) |
static BigDecimal |
convertWeiToHt(BigInteger balance) |
EthSendTransactionPo |
createRechargeErc20(String fromAddress,
String prikey,
BigInteger value,
String toAddress,
String multySignContractAddress,
String bep20ContractAddress) |
EthSendTransactionPo |
createRechargeErc20WithGas(String fromAddress,
String prikey,
BigInteger value,
String toAddress,
String multySignContractAddress,
String bep20ContractAddress,
BigInteger gasLimit,
BigInteger gasPrice)
充值ERC20(不发送)
1.授权使用ERC20资产
2.充值
|
org.web3j.crypto.RawTransaction |
createRechargeErc20WithoutSign(String fromAddress,
BigInteger value,
String toAddress,
String multySignContractAddress,
String bep20ContractAddress)
充值ERC20 (不签名)
1.授权使用ERC20资产
2.充值
|
org.web3j.crypto.RawTransaction |
createRechargeErc20WithoutSign(String fromAddress,
BigInteger value,
String toAddress,
String multySignContractAddress,
String bep20ContractAddress,
BigInteger gasPrice,
BigInteger nonce)
充值ERC20 加速 (不签名)
|
EthSendTransactionPo |
createRechargeMainAsset(String fromAddress,
String prikey,
BigInteger value,
String toAddress,
String multySignContractAddress) |
EthSendTransactionPo |
createRechargeMainAssetWithGas(String fromAddress,
String prikey,
BigInteger value,
String toAddress,
String multySignContractAddress,
BigInteger gasLimit,
BigInteger gasPrice)
充值主资产(不发送)
|
org.web3j.crypto.RawTransaction |
createRechargeMainAssetWithoutSign(String fromAddress,
BigInteger value,
String toAddress,
String multySignContractAddress)
充值主资产(不签名)
|
org.web3j.crypto.RawTransaction |
createRechargeMainAssetWithoutSign(String fromAddress,
BigInteger value,
String toAddress,
String multySignContractAddress,
BigInteger gasPrice,
BigInteger nonce)
充值主资产 加速(不签名)
|
EthSendTransactionPo |
createSendMainAsset(String fromAddress,
String privateKey,
String toAddress,
BigDecimal value,
BigInteger gasLimit,
BigInteger gasPrice)
转账ETH 只组装交易 不发送
|
org.web3j.crypto.RawTransaction |
createSendMainAssetWithoutSign(String fromAddress,
String toAddress,
BigDecimal value,
BigInteger gasLimit,
BigInteger gasPrice) |
EthSendTransactionPo |
createSendTx(String fromAddress,
String priKey,
org.web3j.abi.datatypes.Function txFunction,
BigInteger value,
String contract) |
org.web3j.crypto.RawTransaction |
createSendTxWithoutSign(String fromAddress,
org.web3j.abi.datatypes.Function txFunction,
BigInteger value,
String contract) |
org.web3j.crypto.RawTransaction |
createSendTxWithoutSign(String fromAddress,
org.web3j.abi.datatypes.Function txFunction,
BigInteger value,
String contract,
BigInteger gasPrice,
BigInteger nonce) |
EthSendTransactionPo |
createTransferERC20Token(String from,
String to,
BigInteger value,
String privateKey,
String contractAddress,
BigInteger gasLimit,
BigInteger gasPrice)
转账ERC20 只组装交易 不发送
|
org.web3j.crypto.RawTransaction |
createTransferERC20TokenWithoutSign(String from,
String to,
BigInteger value,
String contractAddress,
BigInteger gasLimit,
BigInteger gasPrice) |
org.web3j.protocol.core.methods.response.EthCall |
ethCall(String from,
String to,
BigInteger gasLimit,
BigInteger gasPrice,
BigInteger value,
String data,
boolean latest) |
org.web3j.protocol.core.methods.response.EthEstimateGas |
ethEstimateGas(String from,
String to,
BigInteger gasLimit,
BigInteger gasPrice,
BigInteger value,
String data) |
String |
ethSign(String priKey,
String dataHex) |
BigDecimal |
getBalance(String address)
HT余额
|
Block |
getBlock(long height) |
Block |
getBlock(String hash) |
org.web3j.protocol.core.methods.response.EthBlock.Block |
getBlockByHeight(Long height)
Method:getBlockByHeight
Description: 根据高度获取区块
Author: xinjl
Date: 2018/4/16 15:23
|
long |
getBlockHeight() |
int |
getContractTokenDecimals(String tokenContract) |
BigInteger |
getCurrentGasPrice() |
protected org.web3j.abi.datatypes.Function |
getERC20ApproveFunction(String spender,
BigInteger value) |
BigInteger |
getERC20Balance(String address,
String contractAddress)
获取ERC20 token指定地址余额
|
BigInteger |
getERC20Balance(String address,
String contractAddress,
org.web3j.protocol.core.DefaultBlockParameterName status) |
static HtgWalletApi |
getInstance(String symbol,
String chainName) |
static HtgWalletApi |
getInstance(String symbol,
String chainName,
String rpcAddress) |
BigInteger |
getNonce(String from)
获取nonce,Pending模式 适用于连续转账
|
org.web3j.protocol.core.methods.response.Transaction |
getTransaction(Long height,
Integer index)
Method:获取链上交易
Description:
Author: xinjl
Date: 2018/4/16 15:23
|
org.web3j.protocol.core.methods.response.TransactionReceipt |
getTxReceipt(String txHash) |
void |
initialize() |
boolean |
isAuthorized(String fromAddress,
String multySignContractAddress,
String bep20Address)
是否已授权过
|
String |
personalSign(String priKey,
String data) |
EthSendTransactionPo |
rechargeErc20(String fromAddress,
String prikey,
BigInteger value,
String toAddress,
String multySignContractAddress,
String bep20ContractAddress)
充值ERC20
1.授权使用ERC20资产
2.充值
|
EthSendTransactionPo |
rechargeErc20(String fromAddress,
String prikey,
BigInteger value,
String toAddress,
String multySignContractAddress,
String bep20ContractAddress,
BigInteger gasPrice,
BigInteger nonce)
充值ERC20 加速 直接发送交易
|
EthSendTransactionPo |
rechargeMainAsset(String fromAddress,
String prikey,
BigInteger value,
String toAddress,
String multySignContractAddress)
充值主资产
|
EthSendTransactionPo |
rechargeMainAsset(String fromAddress,
String prikey,
BigInteger value,
String toAddress,
String multySignContractAddress,
BigInteger gasPrice,
BigInteger nonce)
充值主资产 加速
|
RpcResult |
request(String requestURL,
String method,
List<Object> params) |
boolean |
restartApi(String rpcAddress,
int chainId) |
org.web3j.protocol.core.methods.response.EthSendTransaction |
send(String hexValue)
Method:send
Description: 发送交易
Author: xinjl
Date: 2018/4/16 15:22
|
org.web3j.protocol.core.methods.response.EthSendTransaction |
sendAsync(String hexValue) |
String |
sendMainAsset(String fromAddress,
String privateKey,
String toAddress,
BigDecimal value,
BigInteger gasLimit,
BigInteger gasPrice)
发送ETH
|
EthSendTransactionPo |
sendRawTransaction(String privateKey,
BigInteger nonce,
BigInteger gasPrice,
BigInteger gasLimit,
String to,
BigInteger value,
String data) |
String |
sendRawTransactionWithoutBroadcast(String privateKey,
BigInteger nonce,
BigInteger gasPrice,
BigInteger gasLimit,
String to,
BigInteger value,
String data) |
org.web3j.protocol.core.methods.response.EthSendTransaction |
sendTransaction(String fromAddress,
String secretKey,
Map<String,BigDecimal> transferRequests) |
String |
sendTransaction(String toAddress,
String fromAddress,
String secretKey,
BigDecimal amount) |
org.web3j.protocol.core.methods.response.EthSendTransaction |
sendTransaction(String toAddress,
String fromAddress,
String secretKey,
BigDecimal amount,
String contractAddress) |
EthSendTransactionPo |
sendTx(String fromAddress,
String priKey,
org.web3j.abi.datatypes.Function txFunction,
BigInteger value,
String contract) |
EthSendTransactionPo |
sendTx(String fromAddress,
String priKey,
org.web3j.abi.datatypes.Function txFunction,
BigInteger value,
String contract,
BigInteger gasPrice,
BigInteger nonce) |
EthSendTransactionPo |
sendTx(String fromAddress,
String priKey,
org.web3j.abi.datatypes.Function txFunction,
String contract) |
String |
signTypedDataV4(String priKey,
String json) |
BigInteger |
totalSupply(String contractAddress) |
org.web3j.protocol.core.methods.response.EthSendTransaction |
transferERC20Token(String from,
String to,
BigInteger value,
String privateKey,
String contractAddress,
BigInteger gasLimit,
BigInteger gasPrice)
ERC-20Token交易
|
org.web3j.protocol.core.methods.response.EthCall |
validateRawTransaction(String from,
String to,
String data,
BigInteger value) |
public static HtgWalletApi getInstance(String symbol, String chainName, String rpcAddress)
public static HtgWalletApi getInstance(String symbol, String chainName)
public boolean restartApi(String rpcAddress, int chainId)
public org.web3j.protocol.core.methods.response.EthSendTransaction transferERC20Token(String from, String to, BigInteger value, String privateKey, String contractAddress, BigInteger gasLimit, BigInteger gasPrice) throws Exception
Exceptionpublic org.web3j.crypto.RawTransaction createTransferERC20TokenWithoutSign(String from, String to, BigInteger value, String contractAddress, BigInteger gasLimit, BigInteger gasPrice) throws Exception
Exceptionpublic EthSendTransactionPo createTransferERC20Token(String from, String to, BigInteger value, String privateKey, String contractAddress, BigInteger gasLimit, BigInteger gasPrice) throws Exception
createTransferERC20Token 在接口中 WalletApiExceptionpublic String sendMainAsset(String fromAddress, String privateKey, String toAddress, BigDecimal value, BigInteger gasLimit, BigInteger gasPrice) throws Exception
Exceptionpublic org.web3j.crypto.RawTransaction createSendMainAssetWithoutSign(String fromAddress, String toAddress, BigDecimal value, BigInteger gasLimit, BigInteger gasPrice) throws Exception
Exceptionpublic EthSendTransactionPo createSendMainAsset(String fromAddress, String privateKey, String toAddress, BigDecimal value, BigInteger gasLimit, BigInteger gasPrice) throws Exception
createSendMainAsset 在接口中 WalletApiExceptionpublic void initialize()
protected void checkIfResetWeb3j(int times)
public org.web3j.protocol.core.methods.response.Transaction getTransaction(Long height, Integer index)
public static BigDecimal convertWeiToHt(BigInteger balance)
public org.web3j.protocol.core.methods.response.EthBlock.Block getBlockByHeight(Long height) throws Exception
Exceptionpublic BigDecimal getBalance(String address) throws Exception
address - Exceptionpublic BigInteger getERC20Balance(String address, String contractAddress) throws Exception
address - 查询地址contractAddress - 合约地址InterruptedExceptionExceptionpublic BigInteger getERC20Balance(String address, String contractAddress, org.web3j.protocol.core.DefaultBlockParameterName status) throws Exception
Exceptionpublic org.web3j.protocol.core.methods.response.EthSendTransaction sendTransaction(String fromAddress, String secretKey, Map<String,BigDecimal> transferRequests)
public String sendTransaction(String toAddress, String fromAddress, String secretKey, BigDecimal amount)
public org.web3j.protocol.core.methods.response.EthSendTransaction sendTransaction(String toAddress, String fromAddress, String secretKey, BigDecimal amount, String contractAddress) throws Exception
Exceptionpublic BigInteger getNonce(String from) throws Exception
from - InterruptedExceptionExceptionpublic org.web3j.protocol.core.methods.response.EthSendTransaction send(String hexValue)
public org.web3j.protocol.core.methods.response.EthSendTransaction sendAsync(String hexValue) throws Exception
Exceptionpublic BigInteger convertMainAssetToWei(BigDecimal value)
public EthSendTransactionPo rechargeMainAsset(String fromAddress, String prikey, BigInteger value, String toAddress, String multySignContractAddress) throws Exception
Exceptionpublic EthSendTransactionPo rechargeMainAsset(String fromAddress, String prikey, BigInteger value, String toAddress, String multySignContractAddress, BigInteger gasPrice, BigInteger nonce) throws Exception
Exceptionpublic EthSendTransactionPo createRechargeMainAssetWithGas(String fromAddress, String prikey, BigInteger value, String toAddress, String multySignContractAddress, BigInteger gasLimit, BigInteger gasPrice) throws Exception
createRechargeMainAssetWithGas 在接口中 WalletApiExceptionpublic EthSendTransactionPo createRechargeMainAsset(String fromAddress, String prikey, BigInteger value, String toAddress, String multySignContractAddress) throws Exception
Exceptionpublic org.web3j.crypto.RawTransaction createRechargeMainAssetWithoutSign(String fromAddress, BigInteger value, String toAddress, String multySignContractAddress) throws Exception
Exceptionpublic org.web3j.crypto.RawTransaction createRechargeMainAssetWithoutSign(String fromAddress, BigInteger value, String toAddress, String multySignContractAddress, BigInteger gasPrice, BigInteger nonce) throws Exception
Exceptionpublic EthSendTransactionPo rechargeErc20(String fromAddress, String prikey, BigInteger value, String toAddress, String multySignContractAddress, String bep20ContractAddress) throws Exception
Exceptionpublic EthSendTransactionPo rechargeErc20(String fromAddress, String prikey, BigInteger value, String toAddress, String multySignContractAddress, String bep20ContractAddress, BigInteger gasPrice, BigInteger nonce) throws Exception
Exceptionpublic EthSendTransactionPo createRechargeErc20WithGas(String fromAddress, String prikey, BigInteger value, String toAddress, String multySignContractAddress, String bep20ContractAddress, BigInteger gasLimit, BigInteger gasPrice) throws Exception
createRechargeErc20WithGas 在接口中 WalletApiExceptionpublic EthSendTransactionPo createRechargeErc20(String fromAddress, String prikey, BigInteger value, String toAddress, String multySignContractAddress, String bep20ContractAddress) throws Exception
Exceptionpublic org.web3j.crypto.RawTransaction createRechargeErc20WithoutSign(String fromAddress, BigInteger value, String toAddress, String multySignContractAddress, String bep20ContractAddress) throws Exception
Exceptionpublic org.web3j.crypto.RawTransaction createRechargeErc20WithoutSign(String fromAddress, BigInteger value, String toAddress, String multySignContractAddress, String bep20ContractAddress, BigInteger gasPrice, BigInteger nonce) throws Exception
Exceptionpublic String authorization(String fromAddress, String prikey, String multySignContractAddress, String bep20Address) throws Exception
Exceptionpublic org.web3j.crypto.RawTransaction authorizationWithoutSign(String fromAddress, String multySignContractAddress, String bep20Address) throws Exception
Exceptionpublic boolean isAuthorized(String fromAddress, String multySignContractAddress, String bep20Address) throws Exception
Exceptionprotected org.web3j.abi.datatypes.Function getERC20ApproveFunction(String spender, BigInteger value)
public EthSendTransactionPo sendTx(String fromAddress, String priKey, org.web3j.abi.datatypes.Function txFunction, String contract) throws Exception
Exceptionpublic EthSendTransactionPo sendTx(String fromAddress, String priKey, org.web3j.abi.datatypes.Function txFunction, BigInteger value, String contract) throws Exception
Exceptionpublic EthSendTransactionPo sendTx(String fromAddress, String priKey, org.web3j.abi.datatypes.Function txFunction, BigInteger value, String contract, BigInteger gasPrice, BigInteger nonce) throws Exception
Exceptionpublic org.web3j.crypto.RawTransaction createSendTxWithoutSign(String fromAddress, org.web3j.abi.datatypes.Function txFunction, BigInteger value, String contract) throws Exception
Exceptionpublic org.web3j.crypto.RawTransaction createSendTxWithoutSign(String fromAddress, org.web3j.abi.datatypes.Function txFunction, BigInteger value, String contract, BigInteger gasPrice, BigInteger nonce) throws Exception
Exceptionpublic EthSendTransactionPo createSendTx(String fromAddress, String priKey, org.web3j.abi.datatypes.Function txFunction, BigInteger value, String contract) throws Exception
Exceptionpublic org.web3j.protocol.core.methods.response.TransactionReceipt getTxReceipt(String txHash) throws Exception
Exceptionpublic List<org.web3j.abi.datatypes.Type> callViewFunction(String contractAddress, org.web3j.abi.datatypes.Function function) throws Exception
Exceptionpublic List<org.web3j.abi.datatypes.Type> callViewFunction(String contractAddress, org.web3j.abi.datatypes.Function function, boolean latest) throws Exception
Exceptionpublic int getContractTokenDecimals(String tokenContract) throws Exception
Exceptionpublic BigInteger totalSupply(String contractAddress) throws Exception
Exceptionpublic BigInteger getCurrentGasPrice() throws IOException
IOExceptionpublic EthSendTransactionPo sendRawTransaction(String privateKey, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String to, BigInteger value, String data) throws Exception
sendRawTransaction 在接口中 MetaMaskWalletApiExceptionpublic String sendRawTransactionWithoutBroadcast(String privateKey, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String to, BigInteger value, String data) throws Exception
sendRawTransactionWithoutBroadcast 在接口中 MetaMaskWalletApiExceptionpublic org.web3j.protocol.core.methods.response.EthCall validateRawTransaction(String from, String to, String data, BigInteger value) throws Exception
validateRawTransaction 在接口中 MetaMaskWalletApiExceptionpublic org.web3j.protocol.core.methods.response.EthCall ethCall(String from, String to, BigInteger gasLimit, BigInteger gasPrice, BigInteger value, String data, boolean latest) throws Exception
ethCall 在接口中 MetaMaskWalletApiExceptionpublic org.web3j.protocol.core.methods.response.EthEstimateGas ethEstimateGas(String from, String to, BigInteger gasLimit, BigInteger gasPrice, BigInteger value, String data) throws Exception
ethEstimateGas 在接口中 MetaMaskWalletApiExceptionpublic RpcResult request(String requestURL, String method, List<Object> params)
request 在接口中 MetaMaskWalletApipublic String ethSign(String priKey, String dataHex)
ethSign 在接口中 MetaMaskWalletApipublic String personalSign(String priKey, String data)
personalSign 在接口中 MetaMaskWalletApipublic String signTypedDataV4(String priKey, String json) throws IOException
signTypedDataV4 在接口中 MetaMaskWalletApiIOExceptionCopyright © 2021. All rights reserved.