Skip to main content

Overview

The TonModule provides native TON blockchain operations including message signing, TON and Jetton transfers, balance queries, and network details. Access it via DynamicSDK.instance.ton.

Prerequisites

Get Balance

Query the TON balance for a wallet.
final sdk = DynamicSDK.instance;
final wallet = sdk.wallets.userWallets.first;

final balance = await sdk.ton.getBalance(
  walletId: wallet.id,
);
print('Balance: $balance');

Sign a Message

Sign a message using the connected TON wallet.
final signature = await sdk.ton.signMessage(
  walletId: wallet.id,
  message: 'Hello, TON!',
);
print('Signature: $signature');

Send TON

Send TON tokens to a recipient address. Returns a map containing the boc (bag of cells) and hash of the transaction.
final result = await sdk.ton.sendTon(
  walletId: wallet.id,
  recipientAddress: 'EQBYLTm4nsvoqJRxs2525chuMyfNIS0Tg98TYSLttqzK5YDv',
  amount: '1000000000', // 1 TON in nanotons
);
print('BOC: ${result['boc']}');
print('Hash: ${result['hash']}');
ParameterTypeDescription
walletIdStringThe wallet ID to send from
recipientAddressStringThe recipient TON address
amountStringAmount in nanotons (1 TON = 10^9 nanotons)

Send Jettons

Send Jetton tokens (TON’s fungible token standard, similar to ERC-20) to a recipient.
final result = await sdk.ton.sendJetton(
  walletId: wallet.id,
  recipientAddress: 'EQBYLTm4nsvoqJRxs2525chuMyfNIS0Tg98TYSLttqzK5YDv',
  amount: '1000000',
  jettonMasterAddress: 'EQBlqsm144Dq6SjbPI4jjZvA1hqTIP3CvHovbIfW_t-SCALE',
);
print('BOC: ${result['boc']}');
print('Hash: ${result['hash']}');
ParameterTypeDescription
walletIdStringThe wallet ID to send from
recipientAddressStringThe recipient TON address
amountStringAmount in the Jetton’s smallest unit
jettonMasterAddressStringThe Jetton contract master address

Get Network Details

Query the network information for the connected wallet.
final details = await sdk.ton.getNetworkDetails(
  walletId: wallet.id,
);
print('Chain ID: ${details['chainId']}');
print('Network: ${details['name']}');
Returns a map with:
  • chainId - The chain identifier (e.g., -239 for mainnet, -3 for testnet)
  • name - The network name (e.g., mainnet, testnet)

Complete Example

import 'package:dynamic_sdk/dynamic_sdk.dart';

Future<void> tonExample() async {
  final sdk = DynamicSDK.instance;
  final wallet = sdk.wallets.userWallets.first;

  // Check network
  final network = await sdk.ton.getNetworkDetails(walletId: wallet.id);
  print('Connected to: ${network['name']}');

  // Check balance
  final balance = await sdk.ton.getBalance(walletId: wallet.id);
  print('Balance: $balance nanotons');

  // Sign a message
  final signature = await sdk.ton.signMessage(
    walletId: wallet.id,
    message: 'Verify wallet ownership',
  );
  print('Signature: $signature');

  // Send TON
  final result = await sdk.ton.sendTon(
    walletId: wallet.id,
    recipientAddress: 'EQ...',
    amount: '500000000', // 0.5 TON
  );
  print('Transaction hash: ${result['hash']}');

  // Send Jettons
  final jettonResult = await sdk.ton.sendJetton(
    walletId: wallet.id,
    recipientAddress: 'EQ...',
    amount: '1000000',
    jettonMasterAddress: 'EQ...', // USDT or other Jetton
  );
  print('Jetton transfer hash: ${jettonResult['hash']}');
}

API Reference

MethodReturnsDescription
getBalanceFuture<String>Get wallet balance
signMessageFuture<String>Sign a message
sendTonFuture<Map<String, dynamic>>Send TON, returns {boc, hash}
sendJettonFuture<Map<String, dynamic>>Send Jettons, returns {boc, hash}
getNetworkDetailsFuture<Map<String, dynamic>>Get {chainId, name}

Next Steps