@dynamic-labs/tron package, enabling seamless integration with Tron network wallets using the industry-standard TronWallet Adapter. This provides access to 9+ Tron wallets through a single, unified interface.
Installation
First, install the Tron wallet connector package:Supported Wallets
This package supports the following Tron wallets through TronWallet Adapter:| Wallet | Type | Description |
|---|---|---|
| OKX Wallet | Browser Extension | Multi-chain wallet with Tron support |
| Bitget Wallet | Browser Extension | Formerly BitKeep |
| TokenPocket | Mobile/Extension | Multi-chain wallet |
| Trust Wallet | Mobile/Extension | Popular multi-chain wallet |
Supported Networks
| Network | Chain ID | Description | Block Explorer |
|---|---|---|---|
| Tron Mainnet | 728126428 | Production network | Tronscan |
| Shasta Testnet | 728126429 | Test network | Shasta Tronscan |
| Nile Testnet | 728126430 | Test network | Nile Tronscan |
Basic Integration
To use Tron wallets in your app, add the Tron wallet connectors to your Dynamic configuration:React
Check if a wallet is a Tron wallet
The first thing you should do is check if the wallet is a Tron wallet. You can use theisTronWallet helper method for that. That way, TypeScript will know which methods etc. are available to you.
React
Fetch the wallet address
You can get the wallet address using thewallet.address property:
React
Send TRX
To send TRX (the native Tron currency) to another address, use thesendTrx method:
React
Send TRC20 Tokens
To send TRC20 tokens (like USDT) to another address, use thesendTrc20 method:
React
Sign Messages
Tron wallets support message signing for authentication usingsignMessageV2:
React
Get Balance
To get the TRX balance of an address, use thegetBalance method:
React
Get Token Balance
To get the balance of a TRC20 token, use thegetTokenBalance method:
React
Access TronWeb
You can get direct access to the TronWeb instance for advanced operations:React
Get Network Details
To get information about the current network, use thegetNetworkDetails method:
React
API Reference
Core Methods
getAddress(): Promise<string>- Get the wallet addressgetNetwork(): Promise<string | number | undefined>- Get current networksignMessage(message: string | Uint8Array): Promise<string>- Sign a messagegetBalance(address?: string): Promise<string | undefined>- Get TRX balance (in SUN)sendTrx(to: string, amount: number, options?: { from?: string }): Promise<BroadcastReturn>- Send TRXsendTrc20(params): Promise<string | undefined>- Send TRC20 tokensgetTokenBalance(tokenId: string, address?: string): Promise<number>- Get TRC20 token balancegetNetworkDetails(): Promise<{ chainId: string; name: string }>- Get network infogetTronWeb(): TronWeb | undefined- Get TronWeb instance
Type Definitions
TronWallet- The main wallet class for Tron walletsisTronWallet- Type guard to check if a wallet is a Tron wallet
Resources
- TronWallet Adapter Docs: https://walletadapter.org/docs/
- TronWeb Docs: https://developers.tron.network/docs
- Tron Network: https://tron.network