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,
to: 'EQBYLTm4nsvoqJRxs2525chuMyfNIS0Tg98TYSLttqzK5YDv',
amount: '1000000000', // 1 TON in nanotons
comment: 'user-12345', // optional text comment (memo)
);
print('BOC: ${result['boc']}');
print('Hash: ${result['hash']}');
| Parameter | Type | Description |
|---|
walletId | String | The wallet ID to send from |
to | String | The recipient TON address |
amount | String | Amount in nanotons (1 TON = 10^9 nanotons) |
comment | String? | Optional plain-text comment (memo) attached to the transfer. Required by exchanges that use shared deposit addresses to credit the deposit to the correct user. |
Exchanges routinely share one TON deposit address across many users and map an incoming deposit to a user via the transaction’s text comment. Pass that identifier as comment (native TON) or forwardPayload (Jettons), or the deposit won’t be credited.
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',
jettonAmount: '1000000',
jettonMasterAddress: 'EQBlqsm144Dq6SjbPI4jjZvA1hqTIP3CvHovbIfW_t-SCALE',
forwardPayload: 'user-12345', // optional text comment (memo)
forwardTonAmount: '1', // nanotons forwarded with the notification
);
print('BOC: ${result['boc']}');
print('Hash: ${result['hash']}');
| Parameter | Type | Description |
|---|
walletId | String | The wallet ID to send from |
recipientAddress | String | The recipient TON address |
jettonAmount | String | Amount in the Jetton’s smallest unit |
jettonMasterAddress | String | The Jetton contract master address |
forwardPayload | String? | Optional plain-text comment (memo) forwarded to the recipient. Use this for the deposit memo required by exchanges. |
forwardTonAmount | String? | Optional nanotons forwarded with the transfer notification. Defaults to 1 when omitted — enough to deliver the notification. |
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 (with an optional comment / memo)
final result = await sdk.ton.sendTon(
walletId: wallet.id,
to: 'EQ...',
amount: '500000000', // 0.5 TON
comment: 'user-12345',
);
print('Transaction hash: ${result['hash']}');
// Send Jettons (forwardPayload carries the comment / memo)
final jettonResult = await sdk.ton.sendJetton(
walletId: wallet.id,
recipientAddress: 'EQ...',
jettonAmount: '1000000',
jettonMasterAddress: 'EQ...', // USDT or other Jetton
forwardPayload: 'user-12345',
);
print('Jetton transfer hash: ${jettonResult['hash']}');
}
API Reference
| Method | Returns | Description |
|---|
getBalance | Future<String> | Get wallet balance |
signMessage | Future<String> | Sign a message |
sendTon | Future<Map<String, dynamic>> | Send TON, returns {boc, hash} |
sendJetton | Future<Map<String, dynamic>> | Send Jettons, returns {boc, hash} |
getNetworkDetails | Future<Map<String, dynamic>> | Get {chainId, name} |
Next Steps