API Reference
Complete API documentation for @tetherto/wdk-wallet-tron-gasfree
Table of Contents
Main class for managing gas-free Tron wallets. Extends WalletManagerTron.
Individual gas-free Tron wallet account implementation. Extends WalletAccountReadOnlyTronGasfree.
WalletManagerTronGasfree
The main class for managing gas-free Tron wallets.
Constructor
new WalletManagerTronGasfree(seed, config)Parameters:
seed(string | Uint8Array): BIP-39 mnemonic seed phrase or seed bytesconfig(object): Configuration objectchainId(string): The blockchain's idprovider(string): Tron RPC endpoint URLgasFreeProvider(string): Gas-free service endpointgasFreeApiKey(string): API key for gas-free providergasFreeApiSecret(string): API secret for gas-free providerserviceProvider(string): Service provider Tron addressverifyingContract(string): Gas-free verifying contract addresstransferMaxFee(number, optional): Maximum fee for transfer operations
Example:
Methods
getAccount(index)
Returns a wallet account at the specified index
Promise<WalletAccountTronGasfree>
getAccountByPath(path)
Returns a wallet account at the specified BIP-44 derivation path
Promise<WalletAccountTronGasfree>
getFeeRates()
Returns current fee rates for normal and fast transactions
Promise<{normal: number, fast: number}>
dispose()
Disposes all wallet accounts, clearing private keys from memory
void
getAccount(index)
Returns a gas-free wallet account at the specified index.
Parameters:
index(number, optional): The index of the account to get (default: 0)
Returns: Promise<WalletAccountTronGasfree> - The wallet account
Example:
getAccountByPath(path)
Returns a gas-free wallet account at the specified BIP-44 derivation path.
Parameters:
path(string): The derivation path (e.g., "0'/0/0")
Returns: Promise<WalletAccountTronGasfree> - The wallet account
Example:
getFeeRates()
Returns current fee rates for normal and fast transactions.
Returns: Promise<{normal: number, fast: number}> - Object containing fee rates in sun
normal: Fee rate for normal priority transactionsfast: Fee rate for high priority transactions
Example:
dispose()
Disposes all wallet accounts, clearing private keys from memory. This method should be called when you're done using the wallet to ensure sensitive data is removed.
Example:
WalletAccountTronGasfree
Individual gas-free Tron wallet account implementation.
Constructor
Parameters:
seed(string | Uint8Array): BIP-39 mnemonic seed phrase or seed bytespath(string): BIP-44 derivation path (e.g., "0'/0/0")config(object): Same configuration object as WalletManagerTronGasfree
Methods
getAddress()
Returns the account's address
Promise<string>
getBalance()
Returns the native TRX balance (in sun)
Promise<number>
getTokenBalance(tokenAddress)
Returns the balance of a specific TRC20 token
Promise<number>
transfer(options)
Transfers TRC20 tokens to another address
Promise<{hash: string, fee: number}>
quoteTransfer(options)
Estimates the fee for a TRC20 transfer
Promise<{fee: number}>
sign(message)
Signs a message using the account's private key
Promise<string>
verify(message, signature)
Verifies a message signature
Promise<boolean>
dispose()
Disposes the wallet account, clearing private keys from memory
void
getAddress()
Returns the account's gas-free Tron address.
Returns: Promise<string> - The account's Tron address
Example:
getBalance()
Returns the native TRX balance in sun units.
Returns: Promise<number> - Balance in sun
Example:
getTokenBalance(tokenAddress)
Returns the balance of a specific TRC20 token.
Parameters:
tokenAddress(string): The TRC20 contract address (e.g., 'T...')
Returns: Promise<number> - Token balance in base units
Example:
transfer(options)
Transfers TRC20 tokens to another address using the gas-free service.
Parameters:
options(TransferOptions): Transfer optionstoken(string): TRC20 contract addressrecipient(string): Recipient's Tron addressamount(number): Amount in token base units
Returns: Promise<{hash: string, fee: number}> - Object containing transaction hash and fee paid in token base units
Example:
quoteTransfer(options)
Estimates the fee for a TRC20 token transfer.
Parameters:
options(TransferOptions): Transfer options (same as transfer method)
Returns: Promise<{fee: number}> - Estimated fee in token base units
Example:
sign(message)
Signs a message using the account's private key.
Parameters:
message(string): The message to sign
Returns: Promise<string> - The message signature
Example:
verify(message, signature)
Verifies a message signature.
Parameters:
message(string): The original messagesignature(string): The signature to verify
Returns: Promise<boolean> - True if the signature is valid
Example:
dispose()
Disposes the wallet account, clearing private keys from memory.
Example:
WalletAccountReadOnlyTronGasfree
Read-only gas-free Tron wallet account.
Constructor
Parameters:
address(string): The account's Tron addressconfig(object): Configuration objectchainId(string): The blockchain's idprovider(string): Tron RPC endpoint URLgasFreeProvider(string): Gas-free service endpointgasFreeApiKey(string): API key for gas-free providergasFreeApiSecret(string): API secret for gas-free providerserviceProvider(string): Service provider Tron addressverifyingContract(string): Gas-free verifying contract address
Methods
getAddress()
Returns the account's address
Promise<string>
getBalance()
Returns the native TRX balance (in sun)
Promise<number>
getTokenBalance(tokenAddress)
Returns the balance of a specific TRC20 token
Promise<number>
quoteTransfer(options)
Estimates the fee for a TRC20 transfer
Promise<{fee: number}>
getAddress()
Returns the account's gas-free Tron address.
Returns: Promise<string> - The account's Tron address
Example:
getBalance()
Returns the native TRX balance in sun units.
Returns: Promise<number> - Balance in sun
Example:
getTokenBalance(tokenAddress)
Returns the balance of a specific TRC20 token.
Parameters:
tokenAddress(string): The TRC20 contract address (e.g., 'T...')
Returns: Promise<number> - Token balance in base units
Example:
quoteTransfer(options)
Estimates the fee for a TRC20 token transfer without requiring private keys.
Parameters:
options(TransferOptions): Transfer optionstoken(string): TRC20 contract addressrecipient(string): Recipient's Tron addressamount(number): Amount in token base units
Returns: Promise<{fee: number}> - Estimated fee in token base units
Example:
Types
TransferOptions
Configuration options for token transfers.
TransferResult
Result object returned by transfer operations.
FeeRates
Fee rate information for transactions.
TronGasfreeWalletConfig
Configuration options for wallet initialization.
KeyPair
Account key pair information.

