githubEdit

codeAPI Reference

Complete API documentation for @tetherto/wdk-wallet-ton

API Reference

Table of Contents

Class
Description
Methods

Main class for managing TON wallets

Individual TON wallet account implementation

Read-only TON wallet account

WalletManagerTon

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

Constructor

new WalletManagerTon(seed, config)

Parameters:

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

  • config (object, optional): Configuration object

    • tonClient (object | TonClient, optional): TON client configuration or instance

      • url (string): TON Center API URL (e.g., 'https://toncenter.com/api/v3')

      • secretKey (string, optional): API key for TON Center

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

Example:

Methods

Method
Description
Returns

getAccount(index)

Returns a wallet account at the specified index

Promise<WalletAccountTon>

getAccountByPath(path)

Returns a wallet account at the specified BIP-44 derivation path

Promise<WalletAccountTon>

getFeeRates()

Returns current fee rates for transactions

Promise<{normal: bigint, fast: bigint}>

dispose()

Disposes all wallet accounts, clearing private keys from memory

void

getAccount(index)

Returns a wallet account at the specified index.

Parameters:

  • index (number, optional): The index of the account to get (default: 0)

Returns: Promise<WalletAccountTon> - The wallet account

Example:

getAccountByPath(path)

Returns a wallet account at the specified BIP-44 derivation path.

Parameters:

  • path (string): The derivation path (e.g., "0'/0/0")

Returns: Promise<WalletAccountTon> - The wallet account

Example:

getFeeRates()

Returns current fee rates for normal and fast transactions.

Returns: Promise<FeeRates> - Object containing normal and fast fee rates (as bigint values)

Example:

dispose()

Disposes all wallet accounts, clearing private keys from memory.

Example:

Properties

seed

The wallet's seed bytes.

Type: Uint8Array

Example:

WalletAccountTon

Individual TON wallet account implementation. Extends WalletAccountReadOnlyTon and implements IWalletAccount.

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, optional): Configuration object

    • tonClient (object | TonClient, optional): TON client configuration or instance

      • url (string): TON Center API URL

      • secretKey (string, optional): API key for TON Center

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

Example:

Methods

Method
Description
Returns

getAddress()

Returns the account's TON address

Promise<string>

sign(message)

Signs a message using the account's private key

Promise<string>

verify(message, signature)

Verifies a message signature

Promise<boolean>

sendTransaction(tx)

Sends a TON transaction

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

quoteSendTransaction(tx)

Estimates the fee for a TON transaction

Promise<{fee: bigint}>

transfer(options)

Transfers Jetton tokens to another address

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

quoteTransfer(options)

Estimates the fee for a Jetton transfer

Promise<{fee: bigint}>

getBalance()

Returns the native TON balance (in nanotons)

Promise<bigint>

getTokenBalance(tokenAddress)

Returns the balance of a specific Jetton token

Promise<bigint>

getTransactionReceipt(hash)

Returns a transaction's receipt

`Promise<TonTransactionReceipt

toReadOnlyAccount()

Returns a read-only copy of the account

Promise<WalletAccountReadOnlyTon>

dispose()

Disposes the wallet account, clearing private keys from memory

void

getAddress()

Returns the account's address.

Returns: Promise<string> - The account's TON address

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:

sendTransaction(tx)

Sends a TON transaction and returns the result with hash and fee.

Parameters:

  • tx (object): The transaction object

    • to (string): Recipient TON address (e.g., 'EQ...')

    • value (number | bigint): Amount in nanotons (1 TON = 1,000,000,000 nanotons)

    • bounceable (boolean, optional): Whether the address is bounceable (TON-specific, optional)

    • body (string | Cell, optional): Optional message body

Returns: Promise<{hash: string, fee: bigint}> - Object containing hash and fee (in nanotons)

Example:

quoteSendTransaction(tx)

Estimates the fee for a transaction.

Parameters:

  • tx (object): The transaction object (same as sendTransaction)

    • to (string): Recipient TON address (e.g., 'EQ...')

    • value (number | bigint): Amount in nanotons (1 TON = 1,000,000,000 nanotons)

    • bounceable (boolean, optional): Whether the address is bounceable (TON-specific, optional)

    • body (string | Cell, optional): Optional message body

Returns: Promise<{fee: bigint}> - Object containing fee estimate (in nanotons)

Example:

transfer(options)

Transfers Jettons (TON tokens) to another address.

Parameters:

  • options (object): Transfer options

    • token (string): Jetton master contract address (TON format, e.g., 'EQ...')

    • recipient (string): Recipient TON address (e.g., 'EQ...')

    • amount (number | bigint): Amount in Jetton's base units

Returns: Promise<{hash: string, fee: bigint}> - Object containing hash and fee (in nanotons)

Example:

quoteTransfer(options)

Estimates the fee for a Jetton (TON token) transfer.

Parameters:

  • options (object): Transfer options (same as transfer)

    • token (string): Jetton master contract address (TON format, e.g., 'EQ...')

    • recipient (string): Recipient TON address (e.g., 'EQ...')

    • amount (number | bigint): Amount in Jetton's base units

Returns: Promise<{fee: bigint}> - Object containing fee estimate (in nanotons)

Example:

getBalance()

Returns the native TON balance (in nanotons).

Returns: Promise<bigint> - Balance in nanotons

Example:

getTokenBalance(tokenAddress)

Returns the balance of a specific Jetton (TON token).

Parameters:

  • tokenAddress (string): The Jetton master contract address (TON format, e.g., 'EQ...')

Returns: Promise<bigint> - Token balance in base units

Example:

getTransactionReceipt(hash)

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

Parameters:

  • hash (string): The transaction hash

Returns: Promise<TonTransactionReceipt | null> - Transaction receipt or null if not yet mined

Example:

toReadOnlyAccount()

Returns a read-only copy of the account.

Returns: Promise<WalletAccountReadOnlyTon> - The read-only account

Example:

dispose()

Disposes the wallet account, clearing private keys from memory.

Example:

Properties

Property
Type
Description

index

number

The derivation path's index of this account

path

string

The full derivation path of this account

keyPair

{publicKey: Uint8Array, privateKey: Uint8Array | null}

The account's public and private key pair

Example:

WalletAccountReadOnlyTon

Read-only TON wallet account. Extends WalletAccountReadOnly from @tetherto/wdk-wallet.

Constructor

Parameters:

  • publicKey (string | Uint8Array): The account's public key

  • config (object, optional): Configuration object (Omit<TonWalletConfig, 'transferMaxFee'>)

    • tonClient (object | TonClient, optional): TON client configuration or instance

      • url (string): TON Center API URL

      • secretKey (string, optional): API key for TON Center

Example:

Methods

Method
Description
Returns

getAddress()

Returns the account's TON address

Promise<string>

verify(message, signature)

Verifies a message signature

Promise<boolean>

getBalance()

Returns the native TON balance (in nanotons)

Promise<bigint>

getTokenBalance(tokenAddress)

Returns the balance of a specific Jetton token

Promise<bigint>

quoteSendTransaction(tx)

Estimates the fee for a TON transaction

Promise<{fee: bigint}>

quoteTransfer(options)

Estimates the fee for a Jetton transfer

Promise<{fee: bigint}>

getTransactionReceipt(hash)

Returns a transaction's receipt

Promise<TonTransactionReceipt | null>

getAddress()

Returns the account's address.

Returns: Promise<string> - The account's TON address

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:

getBalance()

Returns the native TON balance (in nanotons).

Returns: Promise<bigint> - Balance in nanotons

Example:

getTokenBalance(tokenAddress)

Returns the balance of a specific Jetton (TON token).

Parameters:

  • tokenAddress (string): The Jetton master contract address (TON format, e.g., 'EQ...')

Returns: Promise<bigint> - Token balance in base units

Example:

quoteSendTransaction(tx)

Estimates the fee for a transaction.

Parameters:

  • tx (object): The transaction object

    • to (string): Recipient TON address

    • value (number | bigint): Amount in nanotons

    • bounceable (boolean, optional): Whether the address is bounceable

    • body (string | Cell, optional): Optional message body

Returns: Promise<{fee: bigint}> - Object containing fee estimate (in nanotons)

Example:

quoteTransfer(options)

Estimates the fee for a Jetton (TON token) transfer.

Parameters:

  • options (object): Transfer options

    • token (string): Jetton master contract address

    • recipient (string): Recipient TON address

    • amount (number | bigint): Amount in Jetton's base units

Returns: Promise<{fee: bigint}> - Object containing fee estimate (in nanotons)

Example:

getTransactionReceipt(hash)

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

Parameters:

  • hash (string): The transaction hash

Returns: Promise<TonTransactionReceipt | null> - Transaction receipt or null if not yet mined

Example:

Types

TonTransaction

TransferOptions

TransactionResult

TransferResult

FeeRates

KeyPair

TonWalletConfig


Need Help?