Usage

Installation, quick start, and usage examples for @tetherto/wdk-wallet-ton

Installation

To install the @tetherto/wdk-wallet-ton package, follow these instructions:

npm install @tetherto/wdk-wallet-ton

Quick Start

Importing from @tetherto/wdk-wallet-ton

  1. WalletManagerTon: Main class for managing wallets

  2. WalletAccountTon: Use this for full access accounts

  3. WalletAccountReadOnlyTon: Use this for read-only accounts

Creating a New Wallet

import WalletManagerTon, { WalletAccountTon, WalletAccountReadOnlyTon } from '@tetherto/wdk-wallet-ton'

// Use a BIP-39 seed phrase (replace with your own secure phrase)
const seedPhrase = 'abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about' // Replace with actual seed generation

// Create wallet manager with TON client config
const wallet = new WalletManagerTon(seedPhrase, {
  tonClient: {
    url: 'https://toncenter.com/api/v3',
    secretKey: 'your-api-key' // Optional
  }
})

// Get a full access account
const account = await wallet.getAccount(0)

// Convert to a read-only account
const readOnlyAccount = await account.toReadOnlyAccount()

Managing Multiple Accounts

Checking Balances

Owned Account

For accounts where you have the seed phrase and full access:

Read-Only Account

For addresses where you don't have the seed phrase:

Sending Transactions

Send TON and estimate fees using WalletAccountTon. Requires TON Center client configuration.

Token Transfers

Transfer Jetton tokens and estimate fees using WalletAccountTon. Requires TON Center client configuration.

Message Signing and Verification

Sign and verify messages using WalletAccountTon.

Fee Management

Retrieve current fee rates using WalletManagerTon.

Memory Management

Clear sensitive data from memory using dispose methods in WalletAccountTon and WalletManagerTon.

Complete Examples

Complete Wallet Setup

Multi-Account Management

Advanced Transaction Example

Token Transfer with Validation

Error Handling and Memory Management


Need Help?