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

Stake2.0

PreviousGeneral Transfer

Last updated 2 years ago

When generating stake 2.0 transactions for DApps, for transactions of the DelegateResourceContract or UnDelegateResourceContract type, in order to display the estimated results during signature using the Tronlink extension, it is necessary to add the "__options" field to the transaction body.

Inside "__options", there are two values: estimatedBandwidth and estimatedEnergy, which correspond to the estimated energy and bandwidth of the delegate and reclaim operations, respectively.

When generating stake 2.0 transactions using a non-tronlink extension injected tronweb, in order to display the corresponding type of resource for DelegateResourceContract or UnDelegateResourceContract type transactions during signature, the "__resource" field needs to be added to the transaction body. (Adding “resource” is only necessary for tronWeb that is not injected by a tronlink extension. TronWeb that is injected by tronlink extension does not require.)

The "__resource" field corresponds to the values "BANDWIDTH" and "ENERGY".

For example:

const transaction = await tronWeb.transactionBuilder.delegateResource(10e6, 'receiverAddress', 'BANDWIDTH', 'ownerAddress', false);
transaction.raw_data.contract[0].parameter.value.resource = "BANDWIDTH"
transaction.__options = {"estimatedBandwidth": 1}

The specific calculation logic of estimatedEnergy and estimatedBandwidth can be found in the last chapter of the "": "How to convert resource share to amount?"

Stake 2.0 Adaptation FAQ