Usage

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

Installation

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

npm install @tetherto/wdk-wallet-to-gasless

Quick Start

Importing from @tetherto/wdk-wallet-ton-gasless

  1. WalletManagerTonGasless: Main class for managing wallets with gasless features

  2. WalletAccountTonGasless: Use this for full access accounts with gasless transactions

  3. WalletAccountReadOnlyTonGasless: Use this for read-only accounts

Creating a New Gasless Wallet

import WalletManagerTonGasless, { 
  WalletAccountTonGasless, 
  WalletAccountReadOnlyTonGasless 
} from '@tetherto/wdk-wallet-ton-gasless'


// 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'


// Create gasless wallet manager with TON RPC and TON API endpoints, and paymaster token config
const wallet = new WalletManagerTonGasless(seedPhrase, {
  tonClient: {
    url: 'https://toncenter.com/api/v3',
    secretKey: 'your-api-key' // Optional
  },
  tonApiClient: {
    url: 'https://tonapi.io/v3',
    secretKey: 'your-ton-api-key' // Optional
  },
  paymasterToken: {
    address: 'EQ...' // Paymaster token contract address
  }, // Paymaster Jetton master contract address
  transferMaxFee: 10000000 // Maximum fee for transfer operations (in paymaster Jetton base units)
})

// 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

⚠️ Direct transaction sending using sendTransaction() is not supported in WalletAccountTonGasless. This is a gasfree implementation that handles transactions through a gasfree provider instead of direct blockchain transactions.

For sending tokens, please use the transfer() method instead.

Jetton Token Transfers (Gasless)

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

Message Signing and Verification

Sign and verify messages using WalletAccountTonGasless.

Fee Management

Retrieve current fee rates using WalletManagerTonGasless.

Memory Management

Clear sensitive data from memory using dispose methods in WalletAccountTonGasless and WalletManagerTonGasless.

Complete Examples

Complete Wallet Setup

Multi-Account Management

Advanced Transaction Example

Token Transfer with Validation

Error Handling and Memory Management


Need Help?