TronLink Docs
Homepage
  • Introduction
  • HD Wallets
  • TronLink App
    • Asset Management
      • Custom Token
    • DeepLink
      • Open Wallet
      • Open DApp
      • Login by TronLink
      • Transfer
      • Sign Transaction
      • Sign Message
      • Result Code
    • DApp Support
      • TronLink Integration
      • DApp Explorer
  • TronLink Wallet Extension
    • Request TronLink Extension
      • Connect Website
      • Add Token
    • Receive messages from TronLink
      • Account Change Message
      • Network Change Message
      • Successful connection message
      • Disconnect website message
      • Messages to Be Deprecated
        • User rejects connection
        • User disconnects from the website
        • User accepts connection
        • User requests to connect to the website
  • DApp
    • Start Developing
    • Multi-Signature Transfer
    • Message Signature
    • General Transfer
    • Stake2.0
Powered by GitBook
On this page
  1. DApp

General Transfer

Overview

DApp requires users to initiate a TRX transfer.

Prerequisite

The DApp developer completes the request to connect to the website, and the user approves to the connection. The DApp sends a request asking the user to connect the wallet to the website, and the user approves to the connection.

It takes 3 steps to initiate a transfer on the TRON network:

  1. Create a transfer transaction

  2. Sign the transaction

  3. Broadcast the signed transaction

In this process, Step 2 requires TronLink while both Step 1 and 3 happen on tronWeb.

Specification

Example

if (window.tronLink.ready) {
  const tronweb = tronLink.tronWeb;
  const fromAddress = tronweb.defaultAddress.base58;
  const toAddress = "TAHQdDiZajMMP26STUnfsiRMNyXdxAJakZ";
  const tx = await tronweb.transactionBuilder.sendTrx(toAddress, 10, fromAddress); // Step1
  try {
    const signedTx = await tronweb.trx.sign(tx); // Step2
    await tronweb.trx.sendRawTransaction(signedTx); // Step3
  } catch (e) {
    // error handling
  }
}

If the user chooses on “Reject” in the pop-up window, an exception will be thrown, which the developer can catch for further processing.

If the user chooses “Sign” in the pop-up window, the DApp receives and broadcasts the signed transaction.

PreviousMessage SignatureNextStake2.0

Last updated 2 years ago

When “await tronweb.trx.sign(tx);” is executed, a pop-up window will show in the TronLink wallet asking the user to confirm, as shown below: