-
Notifications
You must be signed in to change notification settings - Fork 133
docs: add TRON adapter installation documentation #746
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
enesozturk
wants to merge
2
commits into
main
Choose a base branch
from
chore/ton-documents
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
105 changes: 105 additions & 0 deletions
105
snippets/appkit/javascript/tron/about/implementation.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,105 @@ | ||
| AppKit TRON is built on top of the AppKit library and provides a set of components and actions to easily connect TRON wallets with your decentralized application. | ||
|
|
||
| On top of your app set up the following configuration. | ||
|
|
||
| ```tsx | ||
| // App.tsx | ||
| import { createAppKit } from '@reown/appkit' | ||
| import { TronAdapter } from '@reown/appkit-adapter-tron' | ||
| import { tronMainnet, tronShastaTestnet } from '@reown/appkit/networks' | ||
|
|
||
| // Import wallet adapters you want to support | ||
| import { TronLinkAdapter } from '@tronweb3/tronwallet-adapter-tronlink' | ||
|
|
||
| // 1. Get projectId from https://dashboard.reown.com | ||
| const projectId = 'YOUR_PROJECT_ID' | ||
|
|
||
| // 2. Set the networks | ||
| const networks = [tronMainnet, tronShastaTestnet] | ||
|
|
||
| // 3. Set up TRON Adapter with wallet adapters | ||
| const tronAdapter = new TronAdapter({ | ||
| walletAdapters: [ | ||
| new TronLinkAdapter({ | ||
| openUrlWhenWalletNotFound: false, | ||
| checkTimeout: 3000 | ||
| }) | ||
| ] | ||
| }) | ||
|
|
||
| // 4. Create a metadata object - optional | ||
| const metadata = { | ||
| name: 'AppKit', | ||
| description: 'AppKit TRON Example', | ||
| url: 'https://example.com', // origin must match your domain & subdomain | ||
| icons: ['https://avatars.githubusercontent.com/u/179229932'] | ||
| } | ||
|
|
||
| // 5. Create modal | ||
| const modal = createAppKit({ | ||
| adapters: [tronAdapter], | ||
| networks, | ||
| metadata, | ||
| projectId, | ||
| features: { | ||
| analytics: true, // Optional - defaults to your Dashboard configuration | ||
| email: false, | ||
| socials: [] | ||
| } | ||
| }) | ||
|
|
||
| // 6. Trigger modal programaticaly | ||
| const openConnectModalBtn = document.getElementById('open-connect-modal') | ||
| const openNetworkModalBtn = document.getElementById('open-network-modal') | ||
|
|
||
| openConnectModalBtn.addEventListener('click', () => modal.open()) | ||
| openNetworkModalBtn.addEventListener('click', () => modal.open({ view: 'Networks' })) | ||
| ``` | ||
|
|
||
| ## Install Wallet Adapters | ||
|
|
||
| TRON adapter requires you to install wallet adapters separately. This gives you control over which wallets to support and reduces bundle size. | ||
|
|
||
| ```bash npm | ||
| npm install @tronweb3/tronwallet-adapter-tronlink | ||
| ``` | ||
|
|
||
| ```bash Yarn | ||
| yarn add @tronweb3/tronwallet-adapter-tronlink | ||
| ``` | ||
|
|
||
| ```bash Bun | ||
| bun add @tronweb3/tronwallet-adapter-tronlink | ||
| ``` | ||
|
|
||
| ```bash pnpm | ||
| pnpm add @tronweb3/tronwallet-adapter-tronlink | ||
| ``` | ||
|
|
||
| ### Additional Wallet Adapters | ||
|
|
||
| You can install additional TRON wallet adapters: | ||
|
|
||
| ```bash | ||
| npm install @tronweb3/tronwallet-adapter-metamask-tron | ||
| npm install @tronweb3/tronwallet-adapter-trust | ||
| npm install @tronweb3/tronwallet-adapter-okxwallet | ||
| npm install @tronweb3/tronwallet-adapter-bitkeep | ||
| npm install @tronweb3/tronwallet-adapter-binance | ||
| ``` | ||
|
|
||
| Then add them to the `walletAdapters` array: | ||
|
|
||
| ```tsx | ||
| import { TronLinkAdapter } from '@tronweb3/tronwallet-adapter-tronlink' | ||
| import { MetaMaskAdapter } from '@tronweb3/tronwallet-adapter-metamask-tron' | ||
| import { TrustAdapter } from '@tronweb3/tronwallet-adapter-trust' | ||
|
|
||
| const tronAdapter = new TronAdapter({ | ||
| walletAdapters: [ | ||
| new TronLinkAdapter({ openUrlWhenWalletNotFound: false, checkTimeout: 3000 }), | ||
| new MetaMaskAdapter(), | ||
| new TrustAdapter() | ||
| ] | ||
| }) | ||
| ``` | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤖 Auto Review Issue: Spelling error in JavaScript snippet
Severity: LOW
Category: code_quality
Tool: Claude Auto Review
Context:
Recommendation: Fix typo:
// 6. Trigger modal programmatically