Documentation Index
Fetch the complete documentation index at: https://docs.dynamic.xyz/docs/llms.txt
Use this file to discover all available pages before exploring further.
In this example, we are going to send a raw transaction using the TON Connect SendTransactionRequest format.
import { useDynamicContext } from '@dynamic-labs/sdk-react-core';
import { isTonWallet, SendTransactionRequest, CHAIN } from '@dynamic-labs/ton';
const SendRawTransactionButton = () => {
const { primaryWallet } = useDynamicContext();
const onSendRawTransaction = async () => {
if (!primaryWallet || !isTonWallet(primaryWallet)) {
throw new Error('TON wallet not found');
}
// Build a raw transaction request (TON Connect format)
const request: SendTransactionRequest = {
validUntil: Math.floor(Date.now() / 1000) + 60, // 60 seconds from now
network: CHAIN.MAINNET, // or CHAIN.TESTNET
messages: [
{
address: 'UQDrjaLahLkMB-hMCmkzOyBuHJ186Qg_CZQhrOhIPBr0oDkB',
amount: '100000000', // Amount in nanotons (0.1 TON)
// Optional: payload for smart contract calls (base64 encoded BOC)
// payload: 'te6cckEBAQEADgAAGEhlbGxvLCBXT1JMRCFdy+Mw',
// Optional: state init for contract deployment (base64 encoded BOC)
// stateInit: '...',
},
],
};
// Send the transaction
const transactionHash = await primaryWallet.sendTransaction(request);
console.log('Transaction hash:', transactionHash);
};
return <button onClick={onSendRawTransaction}>Send Raw Transaction</button>;
};
| Field | Type | Required | Description |
|---|
from | string | No | Sender address |
validUntil | number | Yes | Transaction deadline (unix epoch seconds) |
network | CHAIN | No | Network identifier (-239 for mainnet, -3 for testnet) |
messages | Message[] | Yes | Array of 1-4 messages |
| Field | Type | Required | Description |
|---|
address | string | Yes | Receiver’s address |
amount | string | Yes | Amount to send in nanotons |
payload | string | No | Contract data (base64 encoded BOC) |
stateInit | string | No | State init for deployment (base64 encoded BOC) |
extraCurrency | { [k: number]: string } | No | Extra currencies to send |