Docs
Docs
Home
Getting Started
Agent Tooling
CLI
Supported Chains
Acala
Aptos
Arbitrum
Arc
Asset Hub
Astar
Avalanche
Base
Berachain
Bifrost
Binance Smart Chain
Bittensor
Blast
Boba Network
Bridge Hub
Celo
Centrifuge
Chiliz
Cronos
Enjin
Ethereum
Etherlink
Flow EVM Gateway
Gnosis
Hydration
Hyperliquid
Immutable
Ink
IoTeX
Kusama
Linea
LISK
Manta Atlantic
Manta Pacific
Mantle
MegaETH
Monad
Movement
Neuroweb
opBNB
Optimism
Plasma
Polkadot
Polygon
Pulsechain
Robinhood
Ronin
Scroll
Sonic
Starknet
Taiko
Tempo
Sui
TRON
Unichain
Viction
World Chain
XDC Network
XX Network
Zetachain
zkSync Era
Zora
Supported ChainsTRONTRON HTTP API

wallet/createtransaction - Create TRON Transact...

Create TRX transfer transactions on TRON network with optimized bandwidth usage and fee estimation via Dwellir's high-performance RPC endpoints.

TRON RPC endpoint: endpoint URLs, plans and pricing.

Lightning-Fast Transaction Creation

Dwellir's TRON endpoints create transactions in under 30ms with automatic fee optimization. Build instant payment apps with our optimized transaction creation API.

Get your free API key

Creates a TRX transfer transaction that can be signed and broadcast to the TRON network. This method generates the transaction object with all necessary parameters.

When to Use This Method

wallet/createtransaction is essential for:

  • TRX Transfers - Send TRX between accounts
  • Payment Processing - Build payment systems and wallets
  • Batch Transactions - Create multiple transfers efficiently
  • Multi-Signature Wallets - Generate transactions for signing
  • Transaction Templates - Pre-build transactions for later execution
JSON-RPC request
{
  "to_address": "TRX6Q82wMqWNbCCmJPLz9mR8AZwqvUU2pN",
  "owner_address": "TJmmqjb1DK9TTZbQXzRQ2AuA94z4gKAPFh", 
  "amount": 1000000,
  "visible": true
}

Implementation Examples

Response Examples

Successful Transaction Creation

JSON
{
  "visible": true,
  "txID": "94eea63bb6774c8fc4f4c9d1b62c1e8c2f7c8c2e4d3a2b1c0d9e8f7a6b5c4d3e2f1",
  "raw_data": {
    "contract": [
      {
        "parameter": {
          "value": {
            "amount": 1000000,
            "owner_address": "TJmmqjb1DK9TTZbQXzRQ2AuA94z4gKAPFh",
            "to_address": "TRX6Q82wMqWNbCCmJPLz9mR8AZwqvUU2pN"
          },
          "type_url": "type.googleapis.com/protocol.TransferContract"
        },
        "type": "TransferContract"
      }
    ],
    "ref_block_bytes": "4a7b",
    "ref_block_hash": "e15e44aa73bd9e15",
    "expiration": 1734567890000,
    "timestamp": 1734567830000
  },
  "raw_data_hex": "0a024a7b2208e15e44aa73bd9e1540d0c7e7e7e7e32d5a68080112640a2d747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e5472616e73666572436f6e747261637412330a15418e9e8b7a4b5c6d3e2f1a0b9c8d7e6f5a4b3c2d1e0f12154142b5e01c8c59a25d78acdbec2bfc7e89e5e86318c0843d70a0b7c6d5e4f3a2b1c0"
}

Error Response (Insufficient Balance)

JSON
{
  "Error": "balance is not sufficient",
  "code": "CONTRACT_VALIDATE_ERROR"
}

Common Use Cases

1. Payment Gateway Integration

JavaScript
class TronPaymentGateway {
  constructor(apiKey, merchantAddress) {
    this.apiKey = apiKey;
    this.merchantAddress = merchantAddress;
    this.apiUrl = `https://api-tron-mainnet.n.dwellir.com/${apiKey}`;
  }
  
  async createPayment(customerAddress, amountUSD, usdToTrxRate) {
    const amountTRX = amountUSD / usdToTrxRate;
    const amountSUN = Math.floor(amountTRX * 1_000_000);
    
    const transaction = await this.createTransaction(
      customerAddress,
      this.merchantAddress,
      amountSUN
    );
    
    return {
      paymentId: transaction.txID,
      amountTRX: amountTRX,
      amountUSD: amountUSD,
      transaction: transaction,
      expiresAt: Date.now() + (15 * 60 * 1000) // 15 minutes
    };
  }
  
  async createTransaction(from, to, amount) {
    const response = await fetch(`${this.apiUrl}/wallet/createtransaction`, {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({
        to_address: to,
        owner_address: from,
        amount: amount,
        visible: true
      })
    });
    
    return await response.json();
  }
}

2. Wallet-to-Wallet Transfer

JavaScript
async function createWalletTransfer(fromWallet, toWallet, amount, memo = '') {
  try {
    // Validate inputs
    if (!isValidTronAddress(fromWallet) || !isValidTronAddress(toWallet)) {
      throw new Error('Invalid wallet address');
    }
    
    if (amount <= 0) {
      throw new Error('Amount must be positive');
    }
    
    // Check sender balance first
    const senderAccount = await fetch(`${TRON_API}/wallet/getaccount`, {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({ address: fromWallet, visible: true })
    }).then(res => res.json());
    
    const balanceTRX = (senderAccount.balance || 0) / 1_000_000;
    
    if (balanceTRX < amount) {
      throw new Error(`Insufficient balance. Have: ${balanceTRX} TRX, Need: ${amount} TRX`);
    }
    
    // Create transaction
    const transaction = await createTRXTransfer(fromWallet, toWallet, amount);
    
    return {
      transaction,
      summary: {
        from: fromWallet,
        to: toWallet,
        amount: amount,
        fee: 'Free (using bandwidth)',
        memo: memo,
        requiresSigning: true
      }
    };
  } catch (error) {
    throw new Error(`Transfer creation failed: ${error.message}`);
  }
}

3. Subscription Payment System

JavaScript
class TronSubscriptionManager {
  constructor(apiKey) {
    this.apiKey = apiKey;
    this.subscriptions = new Map();
  }
  
  async createSubscriptionPayment(subscriberAddress, planPrice, planId) {
    const subscriptionId = `sub_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
    
    const transaction = await createTRXTransfer(
      subscriberAddress,
      'TJmmqjb1DK9TTZbQXzRQ2AuA94z4gKAPFh', // Merchant address
      planPrice
    );
    
    this.subscriptions.set(subscriptionId, {
      id: subscriptionId,
      planId: planId,
      subscriberAddress: subscriberAddress,
      amount: planPrice,
      transaction: transaction,
      status: 'pending',
      createdAt: Date.now()
    });
    
    return {
      subscriptionId,
      transaction,
      expiresAt: Date.now() + (30 * 60 * 1000) // 30 minutes to pay
    };
  }
  
  getSubscription(subscriptionId) {
    return this.subscriptions.get(subscriptionId);
  }
}

4. Multi-Recipient Airdrop

JavaScript
async function createAirdropTransactions(distributorAddress, recipients, amountPerRecipient) {
  const results = {
    successful: [],
    failed: [],
    totalRecipients: recipients.length,
    totalAmount: recipients.length * amountPerRecipient
  };
  
  console.log(`Creating airdrop for ${recipients.length} recipients...`);
  
  for (let i = 0; i < recipients.length; i++) {
    const recipient = recipients[i];
    
    try {
      const transaction = await createTRXTransfer(
        distributorAddress,
        recipient,
        amountPerRecipient
      );
      
      results.successful.push({
        recipient: recipient,
        transaction: transaction,
        amount: amountPerRecipient
      });
      
      console.log(`✓ Created transaction ${i + 1}/${recipients.length} for ${recipient}`);
      
    } catch (error) {
      results.failed.push({
        recipient: recipient,
        error: error.message,
        amount: amountPerRecipient
      });
      
      console.log(`✗ Failed transaction ${i + 1}/${recipients.length} for ${recipient}: ${error.message}`);
    }
    
    // Rate limiting - wait 100ms between requests
    if (i < recipients.length - 1) {
      await new Promise(resolve => setTimeout(resolve, 100));
    }
  }
  
  return results;
}

Performance Tips

  1. Batch Creation - Create multiple transactions concurrently but respect rate limits
  2. Pre-validation - Check balances and addresses before creating transactions
  3. Caching - Cache account data to avoid repeated balance checks
  4. Error Recovery - Implement retry logic for transient failures
JavaScript
// Rate limited transaction creation
class RateLimitedTransactionBuilder {
  constructor(apiKey, requestsPerSecond = 10) {
    this.apiKey = apiKey;
    this.requestQueue = [];
    this.isProcessing = false;
    this.requestsPerSecond = requestsPerSecond;
  }
  
  async createTransaction(fromAddress, toAddress, amount) {
    return new Promise((resolve, reject) => {
      this.requestQueue.push({ fromAddress, toAddress, amount, resolve, reject });
      this.processQueue();
    });
  }
  
  async processQueue() {
    if (this.isProcessing || this.requestQueue.length === 0) return;
    
    this.isProcessing = true;
    
    while (this.requestQueue.length > 0) {
      const request = this.requestQueue.shift();
      
      try {
        const result = await createTRXTransfer(
          request.fromAddress,
          request.toAddress,
          request.amount
        );
        request.resolve(result);
      } catch (error) {
        request.reject(error);
      }
      
      // Rate limiting delay
      await new Promise(resolve => setTimeout(resolve, 1000 / this.requestsPerSecond));
    }
    
    this.isProcessing = false;
  }
}

Need help? Contact our support team or check the TRON documentation.

wallet/validateaddress

Validate TRON address format and encoding, check if address is valid Base58 or Hex format via Dwellir's reliable RPC endpoint.

wallet/broadcasttransaction

Broadcast signed TRON transactions to the network with instant confirmation and detailed result tracking via Dwellir's high-performance endpoints.

On this page

When to Use This MethodImplementation ExamplesResponse ExamplesSuccessful Transaction CreationError Response (Insufficient Balance)Common Use Cases1. Payment Gateway Integration2. Wallet-to-Wallet Transfer3. Subscription Payment System4. Multi-Recipient AirdropPerformance Tips