githubEdit

codeAPI Reference

Complete API documentation for @tetherto/wdk-wallet-tron-gasfree

Table of Contents

Class
Description
Methods

Main class for managing gas-free Tron wallets. Extends WalletManager from @tetherto/wdk-wallet.

Individual gas-free Tron wallet account implementation. Extends WalletAccountReadOnlyTronGasfree.

Read-only gas-free Tron wallet account.

WalletManagerTronGasfree

The main class for managing gas-free Tron wallets. Extends WalletManager from @tetherto/wdk-wallet.

Constructor

new WalletManagerTronGasfree(seed, config)

Parameters:

  • seed (string | Uint8Array): BIP-39 mnemonic seed phrase or seed bytes

  • config (object): Configuration object

    • chainId (number): The blockchain's id

    • provider (string): Tron RPC endpoint URL

    • gasFreeProvider (string): Gas-free service endpoint

    • gasFreeApiKey (string): API key for gas-free provider

    • gasFreeApiSecret (string): API secret for gas-free provider

    • serviceProvider (string): Service provider Tron address

    • verifyingContract (string): Gas-free verifying contract address

    • transferMaxFee (number | bigint, optional): Maximum fee for transfer operations

Example:

Methods

Method
Description
Returns

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: bigint, fast: bigint}>

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: bigint, fast: bigint}> - Object containing fee rates in sun

  • normal: Fee rate for normal priority transactions

  • fast: 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 bytes

  • path (string): BIP-44 derivation path (e.g., "0'/0/0")

  • config (object): Same configuration object as WalletManagerTronGasfree

Methods

Method
Description
Returns

getAddress()

Returns the account's address

Promise<string>

getBalance()

Returns the native TRX balance (in sun)

Promise<bigint>

getTokenBalance(tokenAddress)

Returns the balance of a specific TRC20 token

Promise<bigint>

sendTransaction(tx)

Sends a Tron transaction

Promise<{hash: string, fee: bigint}>

transfer(options, config?)

Transfers TRC20 tokens gas-free

Promise<{hash: string, fee: bigint}>

quoteSendTransaction(tx)

Estimates the fee for a Tron transaction

Promise<{fee: bigint}>

quoteTransfer(options)

Estimates the fee for a TRC20 transfer

Promise<{fee: bigint}>

sign(message)

Signs a message using the account's private key

Promise<string>

verify(message, signature)

Verifies a message signature

Promise<boolean>

getTransactionReceipt(hash)

Returns a transaction's receipt

Promise<TronTransactionReceipt | null>

toReadOnlyAccount()

Returns a read-only copy of the account

Promise<WalletAccountReadOnlyTronGasfree>

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<bigint> - 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<bigint> - Token balance in base units

Example:

transfer(options, config?)

Transfers TRC20 tokens to another address using the gas-free service.

Parameters:

  • options (TransferOptions): Transfer options

    • token (string): TRC20 contract address

    • recipient (string): Recipient's Tron address

    • amount (number | bigint): Amount in token base units

  • config (object, optional): Additional configuration

    • transferMaxFee (number | bigint, optional): Maximum fee for this transfer (overrides wallet-level setting)

Returns: Promise<{hash: string, fee: bigint}> - Object containing transaction hash and fee paid in token base units

Example:

sendTransaction(tx)

Sends a TRX transaction.

Parameters:

  • tx (TronTransaction): The transaction object

    • to (string): Recipient Tron address

    • value (number | bigint): Amount in sun

Returns: Promise<{hash: string, fee: bigint}> - Transaction hash and fee

Example:

quoteSendTransaction(tx)

Estimates the fee for a Tron transaction.

Parameters:

  • tx (TronTransaction): The transaction object

Returns: Promise<{fee: bigint}> - Fee estimate in sun

Example:

quoteTransfer(options)

Estimates the fee for a TRC20 token transfer.

Parameters:

  • options (TransferOptions): Transfer options (same as transfer method)

Returns: Promise<{fee: bigint}> - 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 message

  • signature (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:

getTransactionReceipt(hash)

Returns a transaction's receipt if it has been processed.

Parameters:

  • hash (string): The transaction hash

Returns: Promise<TronTransactionReceipt | null> - Transaction receipt or null

Example:

toReadOnlyAccount()

Returns a read-only copy of the account.

Returns: Promise<WalletAccountReadOnlyTronGasfree> - Read-only account instance

Example:

Properties

Property
Type
Description

index

number

The derivation path's index of this account

path

string

The full BIP-44 derivation path of this account

keyPair

{publicKey: Uint8Array, privateKey: Uint8Array | null}

The account's key pair (⚠️ Contains sensitive data)

⚠️ Security Note: The keyPair property contains sensitive cryptographic material. Never log, display, or expose the private key.

WalletAccountReadOnlyTronGasfree

Read-only gas-free Tron wallet account.

Constructor

Parameters:

  • address (string): The account's Tron address

  • config (object): Configuration object

    • chainId (number): The blockchain's id

    • provider (string): Tron RPC endpoint URL

    • gasFreeProvider (string): Gas-free service endpoint

    • gasFreeApiKey (string): API key for gas-free provider

    • gasFreeApiSecret (string): API secret for gas-free provider

    • serviceProvider (string): Service provider Tron address

    • verifyingContract (string): Gas-free verifying contract address

Methods

Method
Description
Returns

getAddress()

Returns the account's address

Promise<string>

getBalance()

Returns the native TRX balance (in sun)

Promise<bigint>

getTokenBalance(tokenAddress)

Returns the balance of a specific TRC20 token

Promise<bigint>

quoteSendTransaction(tx)

Estimates the fee for a Tron transaction

Promise<{fee: bigint}>

quoteTransfer(options)

Estimates the fee for a TRC20 transfer

Promise<{fee: bigint}>

verify(message, signature)

Verifies a message signature

Promise<boolean>

getTransactionReceipt(hash)

Returns a transaction's receipt

Promise<TronTransactionReceipt | null>

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<bigint> - 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<bigint> - Token balance in base units

Example:

quoteTransfer(options)

Estimates the fee for a TRC20 token transfer without requiring private keys.

Parameters:

  • options (TransferOptions): Transfer options

    • token (string): TRC20 contract address

    • recipient (string): Recipient's Tron address

    • amount (number | bigint): Amount in token base units

Returns: Promise<{fee: bigint}> - Estimated fee in token base units

Example:

quoteSendTransaction(tx)

Estimates the fee for a Tron transaction.

Parameters:

  • tx (TronTransaction): The transaction object

Returns: Promise<{fee: bigint}> - Fee estimate in sun

verify(message, signature)

Verifies a message signature.

Parameters:

  • message (string): The original message

  • signature (string): The signature to verify

Returns: Promise<boolean> - True if the signature is valid

Example:

getTransactionReceipt(hash)

Returns a transaction's receipt if it has been processed.

Parameters:

  • hash (string): The transaction hash

Returns: Promise<TronTransactionReceipt | null> - Transaction receipt or null

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.


Need Help?