Skip to main content

sendTransaction

Sends a custom TON transaction with arbitrary message payloads. This is useful for smart contract calls, multi-message transactions, and contract deployment.

Usage

import { sendTransaction, isTonWalletAccount } from "@dynamic-labs-sdk/ton";
import { getPrimaryWalletAccount } from "@dynamic-labs-sdk/client";

const walletAccount = getPrimaryWalletAccount();

if (walletAccount && isTonWalletAccount(walletAccount)) {
  const { transactionHash } = await sendTransaction({
    walletAccount,
    request: {
      validUntil: Math.floor(Date.now() / 1000) + 60, // 60 seconds from now
      messages: [
        {
          address: "UQDrjaLahLkMB-hMCmkzOyBuHJ186Qg_CZQhrOhIPBr0oDkB",
          amount: "100000000", // 0.1 TON in nanotons
        },
      ],
    },
  });

  console.log("Transaction hash:", transactionHash);
}

Parameters

ParameterTypeDescription
request.messagesarrayArray of messages to send (see Message format below)
request.validUntilnumberTransaction deadline as a unix epoch timestamp in seconds
request.networkCHAIN (optional)Network identifier (-239 for mainnet, -3 for testnet)
request.fromstring (optional)Sender address
walletAccountTonWalletAccountThe wallet account to send from
clientDynamicClient (optional)The Dynamic client instance. Only required when using multiple clients.

Message format

FieldTypeDescription
addressstringReceiver’s address
amountstringAmount to send in nanotons
payloadstring (optional)Contract data as base64-encoded BOC
stateInitstring (optional)State init for contract deployment as base64-encoded BOC
extraCurrency{ [k: number]: string } (optional)Extra currencies to send

Returns

Promise<TonSendTransactionResponse> - A promise that resolves to an object containing:
  • transactionHash - The hash of the submitted transaction

Errors

ErrorDescription
NotTonProviderErrorThrown if the wallet account’s provider is not a TON provider