> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dynamic.xyz/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Tron Wallet Integration Guide

> Step-by-step guide for integrating your Tron wallet with Dynamic using TronWallet Adapter

<Card title="Recommended: JavaScript SDK with React Hooks" icon="react" color="#4779FE">
  For new React apps, we recommend the JavaScript SDK with React Hooks (`@dynamic-labs-sdk/react-hooks`) instead of the legacy React SDK documented here. The JS SDK comes with many benefits such as a much smaller bundle size and other optimizations. Use the [React quickstart (JavaScript SDK)](/javascript/reference/react-quickstart) to get started.
</Card>

This guide walks you through integrating your Tron wallet with the Dynamic SDK using the industry-standard [TronWallet Adapter](https://walletadapter.org) pattern. By creating a TronWallet Adapter and a Dynamic connector, your wallet will be compatible with Dynamic's Tron network support.

## Overview

To integrate your Tron wallet with Dynamic, you'll need to follow these steps:

For general information about custom wallet connectors, see our [Integrate your Wallet](/overview/wallets-and-chains/wallets#custom-wallet-connectors) guide.

<Steps>
  <Step title="Create a TronWallet Adapter">
    Dynamic uses the [TronWallet Adapter](https://walletadapter.org) standard, which provides a unified interface for Tron wallets. Your first step is to create a TronWallet Adapter that implements the adapter interface.

    ### TronWallet Adapter Documentation

    The TronWallet Adapter project provides comprehensive documentation for creating adapters:

    * **[TronWallet Adapter Docs](https://walletadapter.org/docs/)** - Complete guide to creating TronWallet Adapters
    * **[TronWallet Adapter GitHub](https://github.com/tronweb3/tronwallet-adapter)** - Source code and examples
    * **[Adapter Interface](https://walletadapter.org/docs/adapters)** - Specification for adapter implementation

    ### Key Requirements

    Your TronWallet Adapter must implement the `Adapter` interface from `@tronweb3/tronwallet-abstract-adapter`, which includes:

    * `name` - The name of your wallet
    * `icon` - Wallet icon URL
    * `url` - Wallet website URL
    * `readyState` - Connection readiness state
    * `connect()` - Establishes connection to the wallet
    * `disconnect()` - Disconnects from the wallet
    * `signMessage()` - Signs messages for authentication
    * `signTransaction()` - Signs transactions
    * `network()` - Gets the current network
    * `wallet` - The wallet provider instance (e.g., `window.tronWeb`)

    ### Example Adapter Structure

    ```typescript title="Your TronWallet Adapter" theme={"system"}
    import { Adapter } from '@tronweb3/tronwallet-abstract-adapter';

    export class YourTronAdapter extends Adapter {
      name = 'Your Wallet';
      url = 'https://yourwallet.com';
      icon = 'https://yourwallet.com/icon.png';

      async connect(): Promise<void> {
        // Your wallet connection logic
        if (!window.yourWallet) {
          throw new Error('Your wallet not found');
        }
        
        // Connect to wallet and get address
        const address = await window.yourWallet.request({ method: 'tron_requestAccounts' });
        this.emit('connect', { address });
      }

      async disconnect(): Promise<void> {
        // Your wallet disconnection logic
        await window.yourWallet.disconnect();
        this.emit('disconnect');
      }

      async signMessage(message: string): Promise<string> {
        // Your message signing logic
        return await window.yourWallet.signMessage(message);
      }

      async signTransaction(transaction: any): Promise<any> {
        // Your transaction signing logic
        return await window.yourWallet.signTransaction(transaction);
      }

      async network(): Promise<Network> {
        // Get current network
        return await window.yourWallet.getNetwork();
      }
    }
    ```

    For complete implementation details, refer to the [TronWallet Adapter documentation](https://walletadapter.org/docs/adapters).
  </Step>

  <Step title="Create a Dynamic Connector">
    Once you have a TronWallet Adapter, you need to create a Dynamic connector that extends `TronWalletAdapterConnector`.

    ### Connector Structure

    Your connector should extend `TronWalletAdapterConnector` and provide your adapter:

    ```typescript title="YourTronConnector Implementation" theme={"system"}
    import { TronWalletAdapterConnector } from '@dynamic-labs/tron';
    import { YourTronAdapter } from './YourTronAdapter';

    export class YourTronConnector extends TronWalletAdapterConnector {
      /**
       * The name of the wallet connector
       * @override Required override from the base connector class
       */
      override name = 'Your Wallet Name';

      /**
       * Unique identifier for your wallet
       * This should match the key used in the wallet book
       * @override Required override from the base connector class
       */
      override overrideKey = 'yourwallettron';

      /**
       * Create the TronWallet Adapter instance
       * @override Required override from the base connector class
       */
      protected override createAdapter() {
        return new YourTronAdapter();
      }

      /**
       * The constructor for the connector, with the relevant metadata
       * @param props The options for the connector
       */
      constructor(props: any) {
        super({
          ...props,
          metadata: {
            id: 'yourwallettron',
            name: 'Your Wallet Name',
            icon: 'https://your-wallet.com/icon.png',
          },
          overrideKey: 'yourwallettron',
          tronNetworks: props.tronNetworks,
        });
      }
    }
    ```

    ### Registering Your Adapter

    If you want your adapter to be automatically detected, you can add it to the adapter registry. However, for custom connectors, you can also create them directly:

    ```typescript title="Using Your Custom Connector" theme={"system"}
    import { DynamicContextProvider } from '@dynamic-labs/sdk-react-core';
    import { YourTronConnector } from './YourTronConnector';

    function App() {
      return (
        <DynamicContextProvider
          settings={{
            environmentId: 'your-environment-id',
            walletConnectors: [
              new YourTronConnector({
                walletBook: walletBookInstance,
                tronNetworks: tronNetworksConfig,
              }),
            ],
          }}
        >
          {/* Your app content */}
        </DynamicContextProvider>
      );
    }
    ```
  </Step>

  <Step title="Test Your Integration">
    Before submitting, thoroughly test your integration:

    1. **Connection Testing** - Verify wallet connects and disconnects properly
    2. **Address Retrieval** - Ensure addresses are returned correctly
    3. **Message Signing** - Test message signing with `signMessageV2`
    4. **Transaction Testing** - Test TRX and TRC20 token transfers
    5. **Network Switching** - Verify network detection and switching
    6. **Error Handling** - Verify proper error handling for all methods

    ### Testing Checklist

    * [ ] Wallet connects successfully
    * [ ] Wallet address is retrieved correctly
    * [ ] Messages can be signed and verified
    * [ ] TRX transfers work on mainnet and testnets
    * [ ] TRC20 token transfers work correctly
    * [ ] Network detection works (mainnet, Shasta, Nile)
    * [ ] Error cases are handled gracefully
    * [ ] Wallet disconnects cleanly
  </Step>

  <Step title="Submit Your Connector">
    Once your implementation is complete and tested:

    1. Submit your connector following the [Custom Wallet Connectors](/overview/wallets-and-chains/wallets#custom-wallet-connectors) process
    2. Fill out the submission form to get allowlisted
    3. Our team will review and integrate your connector

    ### Submission Requirements

    * Working TronWallet Adapter implementation
    * Dynamic connector extending `TronWalletAdapterConnector`
    * Test coverage for all wallet operations
    * Documentation for your wallet integration
  </Step>
</Steps>

## Supported Networks

| Network            | Chain ID  | Description        | Block Explorer                                  |
| ------------------ | --------- | ------------------ | ----------------------------------------------- |
| **Tron Mainnet**   | 728126428 | Production network | [Tronscan](https://tronscan.org/)               |
| **Shasta Testnet** | 728126429 | Test network       | [Shasta Tronscan](https://shasta.tronscan.org/) |
| **Nile Testnet**   | 728126430 | Test network       | [Nile Tronscan](https://nile.tronscan.org/)     |

## TronWallet Adapter Interface

The TronWallet Adapter interface is defined in `@tronweb3/tronwallet-abstract-adapter`. Key methods include:

```typescript title="TronWallet Adapter Interface" theme={"system"}
interface Adapter {
  name: string;
  icon: string;
  url: string;
  readyState: AdapterState;
  
  connect(): Promise<void>;
  disconnect(): Promise<void>;
  signMessage(message: string): Promise<string>;
  signTransaction(transaction: any): Promise<any>;
  network(): Promise<Network>;
  
  // Event emitters
  on(event: 'connect' | 'disconnect' | 'accountChanged', handler: Function): void;
  off(event: 'connect' | 'disconnect' | 'accountChanged', handler: Function): void;
}
```

For the complete interface specification, see the [TronWallet Adapter documentation](https://walletadapter.org/docs/adapters).

## Resources

* **[TronWallet Adapter Docs](https://walletadapter.org/docs/)** - Official TronWallet Adapter documentation
* **[TronWallet Adapter GitHub](https://github.com/tronweb3/tronwallet-adapter)** - Source code and examples
* **[TronWeb Documentation](https://developers.tron.network/docs)** - TronWeb API reference
* **[Dynamic Custom Wallet Connectors](/overview/wallets-and-chains/wallets#custom-wallet-connectors)** - General guide for custom connectors
* **[Tron Network](https://tron.network)** - Official Tron network website

## Need Help?

If you need assistance integrating your Tron wallet:

* Check the [TronWallet Adapter documentation](https://walletadapter.org/docs/) for adapter implementation details
* Review existing adapter implementations in the [TronWallet Adapter repository](https://github.com/tronweb3/tronwallet-adapter)
* Join our [Discord community](https://discord.gg/dynamic) for support
