Skip to main content
All methods require an existing wallet instance. Create or retrieve a wallet before accessing data.
Create transactions to send Toncoin, Jettons, and NFTs, or generate previews for users.

Creating a transaction

Before sending any transaction to the blockchain, initialize it for the appropriate asset: Toncoin, Jetton, or NFT.

Toncoin

// Transaction for 1 Toncoin
let amountFormatter = TONTokenAmountFormatter()

// Provide the user's input here
guard let amount = amountFormatter.amount(from: "1") else {
    return
}
let message = TONTransferMessage(
    // TON wallet address
    toAddress: address,
    amount: amount,
)
let transaction = try await wallet.transferTONTransaction(message: message)

Jettons

// Transaction for 1 Jetton of some kind (e.g., USDT)
let amountFormatter = TONTokenAmountFormatter()
amountFormatter.nanoUnitDecimalsNumber = 6

// Provide the user's input here
guard let amount = amountFormatter.amount(from: "1") else {
    return
}
let parameters = TONJettonTransferParams(
    // TON wallet address
    toAddress: address,
    // Address of a Jetton minter contract
    jettonAddress: jettonAddress,
    amount: amount,
)
let transaction = try await wallet.transferJettonTransaction(parameters: parameters)

NFTs

let parameters = TONNFTTransferParamsHuman(
    // TON wallet address
    toAddress: address,
    // Address of an NFT item contract
    nftAddress: nft.address,
)
let transaction = try await wallet.transferNFTTransaction(parameters: parameters)

Transaction Preview

Once a transaction object is created, present a preview to the user before sending it.
let preview = try await wallet.preview(transaction: transaction)

Sending a transaction

try await wallet.send(transaction: transaction)

Next steps