Understanding TronLink 

TronWatch-image

Today we are releasing the beta version of TronLink, our chrome extension. This is a version that mainly targets developers since it will only support testnet use until smart contracts launch on the mainnet.

Here we will be explaining how it works, how developers can use it, and how you can help us improve it.

Because the nodes on the current network have not migrated to the new TVM build, TronLink will initially be running on TronWatch’s private network. It will later be changed to use the official Tron test network until the main network nodes support the TVM.

We will be adding the functionality to change the node within the extension before the mainnet releases the TVM. This will allow developers to test and integrate their dApps without using actual funds.

Components

The extension consists of three mostly separate components that communicate with each other while keeping the background state strictly separate from websites that interact with the API. Most of the interesting communication happens under the hood.
Here is the description of the most interesting components, and how they interact with websites and each other.

Background Script

The background script is where all the actual wallet functionality takes place. It’s an essential script that manages a persistent state while the browser is running. It receives a request for confirmation from the website and sends it to the user to be displayed.

The background script also manages the private keys of the users, which are encrypted and safely stored. This could be considered the Backend of the extension.

Page Hook

The page hook is what connects the TronLink extension to the website. It provides an API that gets injected into the page, enabling it to ask the user to sign transactions, call smart contracts, send TRX to a certain address, or even cast votes.
It also comes with utility functions that make life easier for developers.

Here are the currently available API methods:

Node

  • getLastestBlock()
  • getWitnesses()
  • getTokens()
  • getBlock(blockID)
  • getTransaction(transactionID)
  • getAccount(address)

Wallet

  • sendTron(recipient, amount)
  • sendAsset(recipient, amount, assetID)
  • sendTransaction(transaction)
  • signTransaction(transaction)
  • simulateSmartContract(address, data)
  • getAccount()
  • createSmartContract(options)
  • triggerSmartContract(options)

Utils

  • validateAddress(input)
  • sunToTron(sun)
  • tronToSun(tron)

Below is an example that asks the user to send 5000 SUN to an address:

let response = await window.TronLink.v1().sendTrx(“TDGmmTC7xDgQGwH4FYRGuE7SFH2MePHYeH”, 5000);

If you have the extension installed, you can test it here: https://tronwatch.github.io/TronLink-Examples/

We are currently waiting for the TRON developers to add HTTP service endpoints for smart contract-related methods to java-tron. This allows us to completely move away from protobufs, improving many aspects of our extension.

The next step for the API is to make it fully web3 compatible.

Popup

The popup is what the user interacts with. It provides wallet functionality and is used to present the user with confirmation requests from websites.
It is written in Reactjs and should be fairly straightforward to understand.

On a Final Note

While we encourage users to test out and play around with the extension, please keep in mind that TronLink is still in active development. We are running on a private TestNet for the time being, and because of that, we recommend users to be very careful when handling transactions.

For help with integration, or if you just want to get involved, we would like to invite everyone to join us on our Telegram: https://t.me/TronWatch.

If you find any bugs, have feature requests or would like to leave a comment, please open an issue in our TronLink Github repository.

Be aware that this is a Beta version of the extension, and is currently built to only function on the Tron TestNet.
We do not take responsibility for any funds sent from the MainNet to your TronLink address.

TronWatch is currently running for Super Representative.
Make sure to vote for us if you like what we do and want to support our future projects!

To get access to the TronLink Extension, please visit:

https://github.com/TronWatch/TronLink/

Our repository where you can see examples for TronLink :

https://github.com/TronWatch/TronLink-Examples

Social Media:

Twitter: https://twitter.com/TronWatch

Telegram: https://t.me/TronWatch

Facebook: https://www.facebook.com/tronwatch/