> ## Documentation Index
> Fetch the complete documentation index at: https://turnkey-0e7c1f5b-iframe-stamper-docs-update.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Tron support on Turnkey

export const SupportCallout = ({prompt = "Need help with your Turnkey integration?"}) => <>
    {prompt} Reach out through any of our{" "}
    <a href="/solutions/support/overview">support channels</a>.
  </>;

## Address derivation

Turnkey supports Tron address derivation with `ADDRESS_TYPE_TRON`. Tron addresses are derived from the same SECP256k1 curve that is used for Ethereum addresses, but with a different address encoding format.

## Transaction construction and signing

Tron's transaction format is supported for signing in Turnkey. You can use the core signing capabilities to sign Tron transactions by constructing the transaction following the Tron protocol specifications and then using Turnkey's signing API.

## Example

Here's a more complete example of how to integrate Turnkey with TronWeb for transaction signing:

```typescript [expandable] theme={null}
import { Turnkey } from "@turnkey/sdk-server";
import { TronWeb } from "tronweb";

// Initialize Turnkey client
const turnkeyClient = new Turnkey({
  apiBaseUrl: "https://api.turnkey.com",
  apiPrivateKey: process.env.API_PRIVATE_KEY,
  apiPublicKey: process.env.API_PUBLIC_KEY,
  defaultOrganizationId: process.env.ORGANIZATION_ID,
});

// Initialize TronWeb without a private key
const tronWeb = new TronWeb({
  fullHost: "https://api.shasta.trongrid.io", // Testnet
});

const turnkeyAddress = process.env.TRON_ADDRESS; // Your Tron address in Turnkey
const recipientAddress = "TYour_Recipient_Address";
const amount = 100; // Amount in SUN (1 TRX = 1,000,000 SUN)

// 1. Create an unsigned transaction
const unsignedTx = await tronWeb.transactionBuilder.sendTrx(
  recipientAddress,
  amount,
  turnkeyAddress
);

// Sign with Turnkey
const { r, s, v } = await turnkeyClient.apiClient().signRawPayload({
  organizationId: process.env.ORGANIZATION_ID,
  signWith: turnkeyAddress,
  payload: unsignedTx.raw_data_hex,
  encoding: "PAYLOAD_ENCODING_HEXADECIMAL",
});

// Add the signature to the transaction
unsignedTx["signature"] = r + s + v;

// 3. Broadcast the signed transaction
const result = await tronWeb.trx.sendRawTransaction(unsignedTx);

console.log("Transaction sent! ID:", result.txid);
```

## Tron transaction types

You can use Turnkey to sign various Tron transaction types:

* TRX transfers
* TRC10 token transfers
* TRC20 token transfers (smart contract interactions)
* Smart contract deployments
* Smart contract function calls
* Delegate/UnDelegate resource to another user
* Freeze/Unfreeze TRX to receives resources
* Update account permission to implement multisig

## Networks

Turnkey supports:

* Tron Mainnet
* Tron Shasta Testnet
* Tron Nile Testnet

## Policy engine integration

The policy engine currently supports the following Tron contract types:

* TransferContract - TRX transfers
* TriggerSmartContract - Smart contract, including but not limited to TRC-20, invocations
* DelegateResourceContract - Delegate resources, bandwidth or energy, to another user, use for gas sponsorship
* UnDelegateResourceContract - UnDelegate the resources delegated to an user
* FreezeBalanceV2Contract - Freeze TRX to receive bandwidth or energy
* UnfreezeBalanceV2Contract - Unfreeze frozen TRX
* AccountPermissionUpdateContract - Update permissions on an account, can be used for [multisig](https://developers.tron.network/docs/multi-signature)

A full field breakdown can be found in our [policy language definition](/features/policies/language) and examples can be found in [Tron policy examples](/features/policies/examples/tron)

To reference a Tron contract in the policy language you must specify the index of the contract in the contracts array: `tron.tx.contract[0]`. While Tron only currently supports 1 contract in this array, this could change in the future.

## Integration with Tron tools

Turnkey can be integrated with popular Tron development tools such as:

* [TronWeb](https://github.com/tronprotocol/tronweb) - The official JavaScript API for interacting with the Tron network
* [TronBox](https://github.com/tronprotocol/tronbox) - A development framework for Tron smart contracts

## Benefits of using Turnkey with Tron

* **Enhanced Security**: Private keys never leave Turnkey's secure infrastructure
* **Policy Controls**: Apply transaction policies to control what can be signed
* **Simplified Key Management**: No need to manage private keys in your application code
* **Multi-signature Support**: Enable quorum-based approvals for transactions

<SupportCallout prompt="Building on Tron and need help with your Turnkey integration?" />
