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

Start Developing

PreviousUser requests to connect to the websiteNextMulti-Signature Transfer

Last updated 7 days ago

This document will guide you to connect your DApp with the TronLink application in the easiest way. After the DApp is loaded, TronLink will inject the “window.tronLink” object into it.

  1. A user who has connected to this DApp can directly get tronLink.tronWeb.

  2. If the user has not been connected to this DApp before, a request can be invoked to establish the connection before getting tronLink.tronWeb.

async function getTronWeb() {
  let tronWeb;
  if (window.tronLink.ready) {
    tronWeb = tronLink.tronWeb;
  } else {
    const res = await tronLink.request({ method: 'tron_requestAccounts' });
    if (res.code === 200) {
      tronWeb = tronLink.tronWeb;
    }
  }
  return tronWeb;
}

After getting the tronWeb instance, you can perform on-chain interactive actions such as signing transfers, multi-signature transactions, and messages. For use cases of the tronWeb instance, please refer to the following document:

Reference:

https://tronweb.network/docu/docs/intro/
https://developers.tron.network/docs/introduction