TronLink currently supports sidechains and mainchains. Developers can detect the event message sent by TronLink in DAPP, what we can learn from this event message contain the sidechain or mainchain currently selected by TronLink, and which account is currently selected. Let's learn it with a simple example.
The above code involves three events: tabReply, setAccount, and setNode. The following are the triggering scenarios of these events:
Column Title | Column Title |
The completing TronLink initialization(after page load) | tabReply |
Main chain and side chain switching in TronLink: | setAccount、setNode |
Setting nodes in TronLink | setAccount、setNode |
Before the DAPP page is loaded, you can judge the data.message.data.data.node.chain field of the tabReply event to determine whether TronLink chose the side chain or the main chain when the page was loaded. If it is '_', it means the main chain. , Otherwise it is the side chain, and the number of the side chain represented by chain, the number of each side chain is unique.
After the DAPP page is loaded, you can judge the data.message.data.data.node.chain field of the setNode event to determine whether the user manually selected the side chain or the main chain in TronLink. If it is '_', it means the main chain , Otherwise it is the side chain, and the number of the side chain represented by chain, the number of each side chain is unique.
When `MainChain
` is selected, the node in the returned message event is the selected network.

When `DAppChain
` is selected, the node in the returned message event is the selected network.

When the `Shasta
` test network is selected, the node in the returned message event is the selected network.

## Add an initialization event
Note:
Tronlink chrome v3.22.0 starts to support this initialization injection event, and Tronlink APP Android and IOS versions will start to support this initialization injection event in v4.3.4.
When the variables are injected, the `tronLink#initialized
` event is sent and the dapp developer can listen to this event to use the `tronWeb
` and `tronLink
` variables.
## New notification event
Note:
Tronlink chrome v3.22.0 starts to support this initialization injection event, and Tronlink APP Android and IOS versions will start to support this initialization injection event in v4.3.4.
### `accountsChanged
` event
Tronlink sends the `accountsChanged
` event when switching accounts
### `connectWeb
` event
Tronlink sends this event when the `active connection
` dapp is made in the plugin popup page
### `acceptWeb
` event
Tronlink sends this event when a user `accepts
` an authorization request initiated by dapp in the plugin whitelist authorization page
### `disconnectWeb
` event
Tronlink sends this event when the `active reject
` dapp is in the plugin popup page
### `rejectWeb
` event
Tronlink sends this event when a user `rejects
` a dapp initiated authorization request on the plugin whitelist authorization page
Note:
Tronlink chrome v3.22.1 & Tronlink APP v4.3.4 (Android & IOS) start to support connect & disconnect notification events.
### `connect
`event
When the popup screen actively connects to the dapp and whitelist authorization screens, the input variable will be updated and Tronlink will send a connect event when the update is complete.
### `disconnect
`event
When the popup screen actively rejects a request from a user in the dapp and whitelist authorization screens, the input variable will be updated, and Tronlink will send a disconnect event when the update is complete.