API Reference
Complete API documentation for @tetherto/wdk-wallet-tron-gasfree
API Reference
Table of Contents
| Class | Description | Methods |
|---|---|---|
| WalletManagerTronGasfree | Extends @tetherto/wdk-wallet. | Constructor, Methods, Properties |
| WalletAccountReadOnlyTronGasfree | Extends @tetherto/wdk-wallet. | Constructor, Methods, Properties |
| WalletAccountTronGasfree | Extends @tetherto/wdk-wallet-tron-gasfree. | Constructor, Methods, Properties |
WalletManagerTronGasfree
Extends @tetherto/wdk-wallet
Constructor
new WalletManagerTronGasfree(seed, config)Parameters
seed(string | Uint8Array<ArrayBufferLike>): The wallet's BIP-39 seed phrase.config(TronGasfreeWalletConfig): The configuration object.
Source
src/wallet-manager-tron-gasfree.js#L36
Methods
| Method | Description | Returns | Throws |
|---|---|---|---|
dispose() | Disposes all the wallet accounts, erasing their private keys from the memory. | void | - |
getAccount(index) | Returns the wallet account at a specific index (see BIP-44). | Promise<WalletAccountTronGasfree> | - |
getAccountByPath(path) | Returns the wallet account at a specific BIP-44 derivation path. | Promise<WalletAccountTronGasfree> | - |
getFeeRates() | Returns the current fee rates. | Promise<FeeRates> | - |
(static) getRandomSeedPhrase(wordCount) | Returns a random BIP-39 seed phrase. | string | - |
(static) isValidSeedPhrase(seedPhrase) | Checks if a seed phrase is valid. | boolean | - |
dispose()
Disposes all the wallet accounts, erasing their private keys from the memory.
Returns
void
getAccount(index)
Returns the wallet account at a specific index (see BIP-44).
Parameters
index(number, optional): The index of the account to get (default: 0).
Returns
Promise<WalletAccountTronGasfree> - The account.
Example
// Returns the account with derivation path m/44'/195'/0'/0/1
const account = await wallet.getAccount(1);Source
src/wallet-manager-tron-gasfree.js#L71
getAccountByPath(path)
Returns the wallet account at a specific BIP-44 derivation path.
Parameters
path(string): The derivation path (e.g. "0'/0/0").
Returns
Promise<WalletAccountTronGasfree> - The account.
Example
// Returns the account with derivation path m/44'/195'/0'/0/1
const account = await wallet.getAccountByPath("0'/0/1");Source
src/wallet-manager-tron-gasfree.js#L84
getFeeRates()
Returns the current fee rates.
Returns
Promise<FeeRates> - The fee rates (in suns).
Source
src/wallet-manager-tron-gasfree.js#L99
getRandomSeedPhrase(wordCount) (static)
Returns a random BIP-39 seed phrase.
Parameters
wordCount(12 | unknown, optional): The number of words in the seed phrase.
Returns
string - The seed phrase.
isValidSeedPhrase(seedPhrase) (static)
Checks if a seed phrase is valid.
Parameters
seedPhrase(string): The seed phrase.
Returns
boolean - True if the seed phrase is valid.
Properties
| Property | Type | Description |
|---|---|---|
seed | Uint8Array | The seed phrase of the wallet. |
WalletAccountReadOnlyTronGasfree
Extends @tetherto/wdk-wallet
Constructor
new WalletAccountReadOnlyTronGasfree(address, config)Parameters
address(string): The tron account's address.config(Omit<TronGasfreeWalletConfig, "transferMaxFee">): The configuration object.
Source
src/wallet-account-read-only-tron-gasfree.js#L75
Methods
| Method | Description | Returns | Throws |
|---|---|---|---|
_getGasfreeAccount() | Returns the gasfree provider's account. | Promise<TronGasfreeAccountInfo> | - |
_quoteTransferWithAccount(gasFreeAccount, options) | Quotes the costs of a transfer operation using a pre-fetched gasfree account. | Promise<Omit<TransferResult, "hash"> & TronActivationFee> | Yes |
_sendRequestToGasfreeProvider(method, path, body) | Sends a http request to the gasfree provider. | Promise<Response> | - |
getAddress() | Returns the account's address. | Promise<string> | - |
getBalance() | Returns the account's tronix balance. | Promise<bigint> | - |
getTokenBalance(tokenAddress) | Returns the account balance for a specific token. | Promise<bigint> | - |
getTransactionReceipt(hash) | Returns a transaction's receipt. | Promise<any> | - |
quoteSendTransaction(tx) | Quotes the costs of a send transaction operation. | Promise<Omit<TransactionResult, "hash">> | - |
quoteTransfer(options) | Quotes the costs of a transfer operation. | Promise<Omit<TransferResult, "hash"> & TronActivationFee> | - |
verify(message, signature) | Verifies a message's signature. | Promise<boolean> | - |
_getGasfreeAccount()
Returns the gasfree provider's account.
Returns
Promise<TronGasfreeAccountInfo> - The gasfree provider's account.
Source
src/wallet-account-read-only-tron-gasfree.js#L212
_quoteTransferWithAccount(gasFreeAccount, options)
Quotes the costs of a transfer operation using a pre-fetched gasfree account.
Parameters
gasFreeAccount(TronGasfreeAccountInfo): The pre-fetched gasfree account.options(TransferOptions): The transfer's options.
Returns
Promise<Omit<TransferResult, "hash"> & TronActivationFee> - The transfer's quotes.
Throws
If the provider doesn't support the given TRC-20 token.
Source
src/wallet-account-read-only-tron-gasfree.js#L156
_sendRequestToGasfreeProvider(method, path, body)
Sends a http request to the gasfree provider.
Parameters
method(string): The http request's method; available values: 'GET', 'POST', 'PUT', 'PATCH', 'DELETE'.path(string): The http request's url's path.body(any, optional): The http request's body.
Returns
Promise<Response> - The http response.
Source
src/wallet-account-read-only-tron-gasfree.js#L233
getAddress()
Returns the account's address.
Returns
Promise<string> - The account's address.
Source
src/wallet-account-read-only-tron-gasfree.js#L96
getBalance()
Returns the account's tronix balance.
Returns
Promise<bigint> - The tronix balance (in suns).
Source
src/wallet-account-read-only-tron-gasfree.js#L107
getTokenBalance(tokenAddress)
Returns the account balance for a specific token.
Parameters
tokenAddress(string): The smart contract address of the token.
Returns
Promise<bigint> - The token balance (in base unit).
Source
src/wallet-account-read-only-tron-gasfree.js#L119
getTransactionReceipt(hash)
Returns a transaction's receipt.
Parameters
hash(string): The transaction's hash.
Returns
Promise<any> - The receipt, or null if the transaction has not been included in a block yet.
Source
src/wallet-account-read-only-tron-gasfree.js#L196
quoteSendTransaction(tx)
Quotes the costs of a send transaction operation.
Parameters
tx(TronTransaction): The transaction.
Returns
Promise<Omit<TransactionResult, "hash">> - The transaction's quotes.
Source
src/wallet-account-read-only-tron-gasfree.js#L131
quoteTransfer(options)
Quotes the costs of a transfer operation.
Parameters
options(TransferOptions): The transfer's options.
Returns
Promise<Omit<TransferResult, "hash"> & TronActivationFee> - The transfer's quotes.
Source
src/wallet-account-read-only-tron-gasfree.js#L141
verify(message, signature)
Verifies a message's signature.
Parameters
message(string): The original message.signature(string): The signature to verify.
Returns
Promise<boolean> - True if the signature is valid.
Source
src/wallet-account-read-only-tron-gasfree.js#L184
Properties
| Property | Type | Description |
|---|---|---|
_address | string | The account's address. |
WalletAccountTronGasfree
Extends @tetherto/wdk-wallet-tron-gasfree
Constructor
new WalletAccountTronGasfree(seed, path, config)Parameters
seed(string | Uint8Array<ArrayBufferLike>): The wallet's BIP-39 seed phrase.path(string): The BIP-44 derivation path (e.g. "0'/0/0").config(TronGasfreeWalletConfig): The configuration object.
Source
src/wallet-account-tron-gasfree.js#L66
Methods
| Method | Description | Returns | Throws |
|---|---|---|---|
_getGasfreeAccount() | Returns the gasfree provider's account. | Promise<TronGasfreeAccountInfo> | - |
_quoteTransferWithAccount(gasFreeAccount, options) | Quotes the costs of a transfer operation using a pre-fetched gasfree account. | Promise<Omit<TransferResult, "hash"> & TronActivationFee> | Yes |
_sendRequestToGasfreeProvider(method, path, body) | Sends a http request to the gasfree provider. | Promise<Response> | - |
dispose() | Disposes the wallet account, erasing the private key from the memory. | void | - |
getAddress() | Returns the account's address. | Promise<string> | - |
getBalance() | Returns the account's tronix balance. | Promise<bigint> | - |
getTokenBalance(tokenAddress) | Returns the account balance for a specific token. | Promise<bigint> | - |
getTransactionReceipt(hash) | Returns a transaction's receipt. | Promise<any> | - |
quoteSendTransaction(tx) | Quotes the costs of a send transaction operation. | Promise<Omit<TransactionResult, "hash">> | - |
quoteTransfer(options) | Quotes the costs of a transfer operation. | Promise<Omit<TransferResult, "hash"> & TronActivationFee> | - |
sendTransaction(tx) | Sends a transaction. | Promise<TransactionResult> | - |
sign(message) | Signs a message. | Promise<string> | - |
signTransaction(tx) | Signs a transaction. | Promise<never> | - |
toReadOnlyAccount() | Returns a read-only copy of the account. | Promise<WalletAccountReadOnlyTronGasfree> | - |
transfer(options, config) | Transfers a token to another address, paying gas fees with the transferred token. | Promise<TransferResult & TronActivationFee> | - |
verify(message, signature) | Verifies a message's signature. | Promise<boolean> | - |
_getGasfreeAccount()
Returns the gasfree provider's account.
Returns
Promise<TronGasfreeAccountInfo> - The gasfree provider's account.
Source
src/wallet-account-read-only-tron-gasfree.js#L212
_quoteTransferWithAccount(gasFreeAccount, options)
Quotes the costs of a transfer operation using a pre-fetched gasfree account.
Parameters
gasFreeAccount(TronGasfreeAccountInfo): The pre-fetched gasfree account.options(TransferOptions): The transfer's options.
Returns
Promise<Omit<TransferResult, "hash"> & TronActivationFee> - The transfer's quotes.
Throws
If the provider doesn't support the given TRC-20 token.
Source
src/wallet-account-read-only-tron-gasfree.js#L156
_sendRequestToGasfreeProvider(method, path, body)
Sends a http request to the gasfree provider.
Parameters
method(string): The http request's method; available values: 'GET', 'POST', 'PUT', 'PATCH', 'DELETE'.path(string): The http request's url's path.body(any, optional): The http request's body.
Returns
Promise<Response> - The http response.
Source
src/wallet-account-read-only-tron-gasfree.js#L233
dispose()
Disposes the wallet account, erasing the private key from the memory.
Returns
void
Source
src/wallet-account-tron-gasfree.js#L219
getAddress()
Returns the account's address.
Returns
Promise<string> - The account's address.
Source
src/wallet-account-read-only-tron-gasfree.js#L96
getBalance()
Returns the account's tronix balance.
Returns
Promise<bigint> - The tronix balance (in suns).
Source
src/wallet-account-read-only-tron-gasfree.js#L107
getTokenBalance(tokenAddress)
Returns the account balance for a specific token.
Parameters
tokenAddress(string): The smart contract address of the token.
Returns
Promise<bigint> - The token balance (in base unit).
Source
src/wallet-account-read-only-tron-gasfree.js#L119
getTransactionReceipt(hash)
Returns a transaction's receipt.
Parameters
hash(string): The transaction's hash.
Returns
Promise<any> - The receipt, or null if the transaction has not been included in a block yet.
Source
src/wallet-account-read-only-tron-gasfree.js#L196
quoteSendTransaction(tx)
Quotes the costs of a send transaction operation.
Parameters
tx(TronTransaction): The transaction.
Returns
Promise<Omit<TransactionResult, "hash">> - The transaction's quotes.
Source
src/wallet-account-read-only-tron-gasfree.js#L131
quoteTransfer(options)
Quotes the costs of a transfer operation.
Parameters
options(TransferOptions): The transfer's options.
Returns
Promise<Omit<TransferResult, "hash"> & TronActivationFee> - The transfer's quotes.
Source
src/wallet-account-read-only-tron-gasfree.js#L141
sendTransaction(tx)
Sends a transaction.
Parameters
tx(TronTransaction): The transaction.
Returns
Promise<TransactionResult> - The transaction's result.
Source
src/wallet-account-tron-gasfree.js#L140
sign(message)
Signs a message.
Parameters
message(string): The message to sign.
Returns
Promise<string> - The message's signature.
Source
src/wallet-account-tron-gasfree.js#L120
signTransaction(tx)
Signs a transaction.
Parameters
tx(TronTransaction): The transaction.
Returns
Promise<never> - Never resolves; always throws.
Source
src/wallet-account-tron-gasfree.js#L130
toReadOnlyAccount()
Returns a read-only copy of the account.
Returns
Promise<WalletAccountReadOnlyTronGasfree> - The read-only account.
Source
src/wallet-account-tron-gasfree.js#L207
transfer(options, config)
Transfers a token to another address, paying gas fees with the transferred token.
Parameters
options(TransferOptions): The transfer's options.config(object, optional): A configuration object containing additional options.
Returns
Promise<TransferResult & TronActivationFee> - The transfer's result.
Source
src/wallet-account-tron-gasfree.js#L152
verify(message, signature)
Verifies a message's signature.
Parameters
message(string): The original message.signature(string): The signature to verify.
Returns
Promise<boolean> - True if the signature is valid.
Source
src/wallet-account-read-only-tron-gasfree.js#L184
Properties
| Property | Type | Description |
|---|---|---|
_address | string | The account's address. |
index | number | The derivation path's index of this account. |
keyPair | KeyPair | The account's key pair. The uint8 arrays are bound to the wallet account, so any external change will reflect to the internal representation. For this reason, it's strongly recommended to treat the key pair as a read-only view of the keys. While it's still technically possible to alter their content, client code should never do so. |
path | string | The derivation path of this account (see BIP-44). |
Types
TronGasfreeAccountInfo
| Property | Type | Description |
|---|---|---|
accountAddress | string | The owner's account address. |
active | boolean | Whether the gasfree account is active. |
allowSubmit | boolean | Whether the account is allowed to submit transactions. |
assets | TronGasfreeAssetInfo[] | The list of supported assets and their info. |
gasFreeAddress | string | The gasfree contract address for the account. |
nonce | number | The account's nonce. |
Source
src/wallet-account-read-only-tron-gasfree.js#L56
TronGasfreeAssetInfo
| Property | Type | Description |
|---|---|---|
activateFee | number | The fee to activate the account for this token. |
decimal | number | The token's decimals. |
frozen | number | Whether the token is frozen. |
tokenAddress | string | The token's smart contract address. |
tokenSymbol | string | The token's symbol. |
transferFee | number | The fee for transferring this token. |
Source
src/wallet-account-read-only-tron-gasfree.js#L46
TronGasfreeWalletConfig
| Property | Type | Description |
|---|---|---|
chainId | number | The blockchain's id. |
gasFreeApiKey? | string | The gasfree provider's api key. |
gasFreeApiSecret? | string | The gasfree provider's api secret. |
gasFreeProvider | string | The gasfree provider's url. |
provider | `string | TronWeb` |
serviceProvider | string | The address of the service provider. |
transferMaxFee? | `number | bigint` |
verifyingContract | string | The address of the verifying contract. |