Skip to main content

Documentation Index

Fetch the complete documentation index at: https://www.dynamic.xyz/docs/llms.txt

Use this file to discover all available pages before exploring further.

Overview

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

Prerequisites

Get a TON Wallet

If TON is enabled in the dashboard, the user gets a TON wallet on signup. Find it via userWallets, or create one explicitly with EmbeddedWalletChain.TON:
val sdk = DynamicSDK.getInstance()

// Filter existing
val tonWallet = sdk.wallets.userWallets.firstOrNull { it.chain == "TON" }

// Or create
val wallet = sdk.wallets.embedded.createWallet(chain = EmbeddedWalletChain.TON)

Get Balance

Query the TON balance for a wallet. Returned as a string (nanotons) to preserve precision.
val balance = sdk.ton.getBalance(walletId = wallet.id)
println("Balance: $balance nanotons")

Sign a Message

Sign a message using the connected TON wallet:
val signature = sdk.ton.signMessage(
  walletId = wallet.id,
  message = "Hello, TON!"
)
println("Signature: $signature")

Send TON

Send TON tokens to a recipient address. Returns a TonTransactionResult containing the BOC and transaction hash.
val result = sdk.ton.sendTon(
  walletId = wallet.id,
  to = "EQBYLTm4nsvoqJRxs2525chuMyfNIS0Tg98TYSLttqzK5YDv",
  amount = "1000000000", // 1 TON in nanotons
  comment = null         // optional
)
println("BOC: ${result.boc}")
println("Hash: ${result.hash}")
ParameterTypeDescription
walletIdStringThe wallet ID to send from
toStringRecipient TON address
amountStringAmount in nanotons (1 TON = 10⁹ nanotons)
commentString?Optional comment to attach to the transaction

Send Jettons

Send Jetton tokens (TON’s fungible token standard, similar to ERC-20):
val result = sdk.ton.sendJetton(
  walletId = wallet.id,
  to = "EQBYLTm4nsvoqJRxs2525chuMyfNIS0Tg98TYSLttqzK5YDv",
  amount = "1000000",
  jettonMasterAddress = "EQBlqsm144Dq6SjbPI4jjZvA1hqTIP3CvHovbIfW_t-SCALE",
  comment = null
)
println("Hash: ${result.hash}")
ParameterTypeDescription
walletIdStringThe wallet ID to send from
toStringRecipient TON address
amountStringAmount in the Jetton’s smallest unit
jettonMasterAddressStringJetton master (contract) address
commentString?Optional comment

Get Network Details

Query the chain ID and network name for the connected wallet:
val details = sdk.ton.getNetworkDetails(walletId = wallet.id)
println("Chain ID: ${details.chainId}")
println("Network:  ${details.name}")
Returned data class:
  • chainId-239 for mainnet, -3 for testnet
  • name"mainnet" or "testnet"

API Reference

MethodReturnsDescription
getBalanceStringGet wallet balance (nanotons)
signMessageStringSign a message
sendTonTonTransactionResultSend TON, returns {boc, hash}
sendJettonTonTransactionResultSend Jettons, returns {boc, hash}
getNetworkDetailsTonNetworkDetailsGet {chainId, name}

Next Steps