Tron Provider

After setting up your wallet, you can have access to the Tron provider:

// react
const { providers } = useTomo()
const { tronProvider } = providers;

// pure js
const tronProvider = window.tomo_tron

Get Tron Address

the Tron address from the wallet state or provider. In React framework:

// get address from wallet state
const { walletState } = useTomo()
const tronAddress = walletState.tronAddress

// or get address from provider
const { providers } = useTomo()
const tronAddress = await providers.tronProvider.getAddress()

Or Pure JS:

/** pure js */
import { getWalletState } from '@tomo-inc/tomo-web-sdk';
// get from wallet state
const walletState = getWalletState()
const tronAddress = walletState.tronAddress

// or get from provider
const tronAddress = await window.tomo_tron.getAddress()

Provider Functions

Signing a Message

It uses the Tron provider to sign a plain text offchain message, which returns the signature of the given message.

Sign Transaction

To sign a transaction, you need first initiate a client withtronweb for connecting to the network.

Then, create the transaction and sign with our tronProvider . Eventually, you need to send the transaction again through the tronWeb client.

Example

We provide an example of a tron provider as follows:

React

Pure JavaScript

Last updated