sendTransaction
Sends a Tron transaction to transfer TRX to a recipient address.
Usage
import { sendTransaction, isTronWalletAccount } from "@dynamic-labs-sdk/tron";
import { getPrimaryWalletAccount } from "@dynamic-labs-sdk/client";
const walletAccount = getPrimaryWalletAccount();
if (walletAccount && isTronWalletAccount(walletAccount)) {
const result = await sendTransaction({
walletAccount,
transaction: {
to: "RECIPIENT_TRON_ADDRESS",
amount: 10, // Amount in TRX
},
});
console.log("Transaction result:", result);
}
Parameters
| Parameter | Type | Description |
|---|
transaction.to | string | The recipient’s Tron address |
transaction.amount | number | The amount to send in TRX (will be converted to SUN internally) |
walletAccount | TronWalletAccount | The wallet account to send from |
client | DynamicClient (optional) | The Dynamic client instance. Only required when using multiple clients. |
Returns
Promise<TronBroadcastReturnSignedTransaction> - A promise that resolves to the broadcast result of the signed transaction.
Errors
| Error | Description |
|---|
NotTronProviderError | Thrown if the wallet account’s provider is not a Tron provider |
| Signing unavailable error | Thrown if the wallet account is not available for signing |
Notes
- The amount is specified in TRX and is automatically converted to SUN (Tron’s smallest unit) internally
- The function verifies that the wallet account is available for signing before sending the transaction
React
import { sendTransaction, isTronWalletAccount } from '@dynamic-labs-sdk/tron';
import { useGetWalletAccounts } from '@dynamic-labs-sdk/react-hooks';
import { useState } from 'react';
function SendTronButton({ recipientAddress, amount }) {
const { data: walletAccounts = [] } = useGetWalletAccounts();
const walletAccount = walletAccounts.find(isTronWalletAccount);
const [status, setStatus] = useState('');
const handleSend = async () => {
if (!walletAccount) return;
await sendTransaction({
walletAccount,
transaction: { to: recipientAddress, amount },
});
setStatus('Transaction sent');
};
return (
<div>
<button onClick={handleSend} disabled={!walletAccount}>Send TRX</button>
{status && <p>{status}</p>}
</div>
);
}
Last modified on June 24, 2026