Provider API

Connect Accounts

NaboxWallet.tronLink.request({ method: 'tron_requestAccounts' });

tronWeb

For specific API methods, please refer to the official documentation of TRONWeb

Signing and broadcasting transactions

const tronProvider = NaboxWallet.tronLink.tronWeb;
const transaction = await tronProvider.transactionBuilder.triggerSmartContract('toAddress', 'functionName', options, parameter, 'fromAddress');
// Signing transactions
const signedTx = await tronProvider.trx.sign(transaction.transaction);
// Broadcasting transactions
const res = await tronProvider.trx.sendRawTransaction(signedTransaction);

signMessage(Message Signature)

const tronProvider = NaboxWallet.tronLink.tronWeb;
const message = 'message'; // Signed Message
const result = await tronProvider.trx.sign(message);

Event

The event monitoring of the TRON chain is different from that of other chains. It is implemented by monitoring messages.

// Connection Events
window.addEventListener('message', function (e) {
  if (e.data.message && e.data.message.action == "connect") {
    console.log('connect: ', e.data)
  }
});

// Disconnection Event
window.addEventListener('message', function (e) {
  if (e.data.message && e.data.message.action == "disconnect") {
    console.log('disconnect: ', e.data)
  }
});

// Account Changes
window.addEventListener('message', function (e) {
  if (e.data.message && e.data.message.action === "accountsChanged") {
    console.log('accountsChanged: ', e.data)
  }
})

Last updated