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:

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.signTransaction({
  organizationId: process.env.ORGANIZATION_ID,
  signWith: turnkeyAddress,
  payload: unsignedTx.raw_data_hex,
  encoding: "hex",
});

// 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

Networks

Turnkey supports both:

  • Tron Mainnet
  • Tron Shasta Testnet

Integration with Tron Tools

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

  • TronWeb - The official JavaScript API for interacting with the Tron network
  • 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

If you have any questions about using Turnkey with Tron or need assistance with integration, feel free to contact us at hello@turnkey.com, on X, or on Slack.