> ## 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.

# Sign TRON Transactions

> Learn how to sign TRON transactions using Dynamic's Node SDK

## Overview

This guide shows you how to sign TRON transactions using Dynamic's Node SDK. You build the unsigned transaction against a TRON full node, which returns a transaction object containing a `raw_data_hex` field. The SDK signs the SHA-256 digest of `raw_data_hex`, appends the signature to the transaction's `signature` array, and returns the complete transaction as a JSON string ready to broadcast.

## Prerequisites

* [Created a TRON wallet](/docs/node/tron/create-wallet)
* Access to a TRON full node (for example, [TronGrid](https://www.trongrid.io/))

## Step 1: Build the Unsigned Transaction

TRON transactions are assembled by a full node. Use `/wallet/createtransaction` for a TRX transfer, or `/wallet/triggersmartcontract` for smart contract calls such as TRC-20 transfers:

```typescript theme={"system"}
const unsignedResponse = await fetch(
  'https://api.trongrid.io/wallet/createtransaction',
  {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({
      owner_address: walletMetadata.accountAddress,
      to_address: 'RECIPIENT_TRON_ADDRESS',
      amount: 1_000_000, // 1 TRX in SUN
      visible: true,
    }),
  }
);

const unsignedTransaction = await unsignedResponse.json();
// unsignedTransaction.raw_data_hex is what gets signed
```

## Step 2: Sign the Transaction

The approach for signing transactions depends on how you created your wallet:

### With Automatic Backup (Recommended)

If you created your wallet with `backUpToDynamic: true`, you can sign directly without retrieving key shares, as long as you pass the password used at creation so the SDK can decrypt the backed-up shares:

```typescript theme={"system"}
import { authenticatedTronClient } from './client';

const tronClient = await authenticatedTronClient();

// ✅ Simple signing - no externalServerKeyShares needed
const signedTransaction = await tronClient.signTransaction({
  walletMetadata,
  password: 'your-secure-password',
  transaction: unsignedTransaction,
});

console.log('Signed transaction (JSON):', signedTransaction);
```

`signTransaction()` accepts either the transaction object or its JSON string form, as long as it contains a `raw_data_hex` field.

### With Manual Backup

If you created your wallet with `backUpToDynamic: false`, you must retrieve and provide external key shares:

```typescript theme={"system"}
// ⚠️ First, retrieve the key shares your app stored at wallet creation
// (required for manual backup). retrieveStoredKeyShares is a function
// you implement that reads the shares from your secrets vault.
const keyShares = await retrieveStoredKeyShares('YourTronWalletAddress');

const signedTransaction = await tronClient.signTransaction({
  walletMetadata,
  externalServerKeyShares: keyShares, // Required for manual backup!
  transaction: unsignedTransaction,
  password: 'your-password', // Only if wallet was created with password
});
```

**Password Handling Notes:**

* If your wallet was created **without a password**, omit the `password` parameter
* If your wallet was created **with a password**, you must provide it for all operations
* The password parameter is always optional in the API, but required if the wallet is password-protected

## Step 3: Broadcast the Transaction

`signTransaction()` returns the full transaction as a JSON string, with the new signature appended to `signature` and `txID` recomputed. Pass it directly to `/wallet/broadcasttransaction`:

```typescript theme={"system"}
const broadcastResponse = await fetch(
  'https://api.trongrid.io/wallet/broadcasttransaction',
  {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: signedTransaction,
  }
);

const result = await broadcastResponse.json();
console.log('Broadcast result:', result);
```

## Multi-Signature Transactions

Because `signTransaction()` appends to any existing `transaction.signature` entries, you can pass a transaction that already carries signatures and the new MPC signature is added alongside them for multi-sig flows.

## Next Steps

* [Sign TRON messages](/docs/node/tron/sign-messages)
* [Import existing TRON private keys](/docs/node/tron/import-private-keys)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.