Skip to content

Commit 1456c4b

Browse files
committed
Rolled back changes to tron
1 parent 16d1adf commit 1456c4b

File tree

1 file changed

+111
-12
lines changed
  • docs/connect-blockchain/evm/tron

1 file changed

+111
-12
lines changed

docs/connect-blockchain/evm/tron/web.mdx

Lines changed: 111 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,7 @@ description: "Integrate Web3Auth with the Tron Blockchain in JavaScript | Docume
88
---
99

1010
import Tabs from "@theme/Tabs";
11-
import JsBlockchainMethods from "@site/src/common/docs/_js-blockchain-methods.mdx";
12-
import ReactWagmiIntegration from "@site/src/common/docs/_react-wagmi-blockchain-methods.mdx";
13-
import VueWagmiIntegration from "@site/src/common/docs/_vue-wagmi-blockchain-methods.mdx";
1411
import TabItem from "@theme/TabItem";
15-
import ChainDetailsTron from "@site/src/common/docs/general-connect-blockchain/_tron.mdx";
1612

1713
## Overview
1814

@@ -35,9 +31,74 @@ npm install @web3auth/no-modal @web3auth/ethereum-provider @web3auth/auth-adapte
3531

3632
---
3733

38-
## Chain Details for Tron
34+
## Getting the ChainConfig
35+
36+
For different Tron networks, you can use the appropriate chain configuration.
37+
38+
<Tabs defaultValue="testnet" groupId="chainConfig">
39+
<TabItem value="mainnet" label="Mainnet">
40+
```typescript
41+
const TRON_MAINNET = {
42+
chainNamespace: "eip155",
43+
chainId: "0x2b6653dc", // Tron Mainnet Chain ID
44+
rpcTarget: "https://api.trongrid.io",
45+
displayName: "TRON Mainnet",
46+
blockExplorerUrl: "https://tronscan.org",
47+
ticker: "TRX",
48+
tickerName: "TRON",
49+
logo: "https://cryptologos.cc/logos/tron-trx-logo.png",
50+
};
51+
```
52+
</TabItem>
53+
<TabItem value="testnet" label="Testnet (Shasta)">
54+
```typescript
55+
const TRON_SHASTA_TESTNET = {
56+
chainNamespace: "eip155",
57+
chainId: "0x94a9059e", // Tron Shasta Testnet Chain ID
58+
rpcTarget: "https://api.shasta.trongrid.io/jsonrpc",
59+
displayName: "TRON Shasta Testnet",
60+
blockExplorerUrl: "https://shasta.tronscan.org",
61+
ticker: "TRX",
62+
tickerName: "TRON",
63+
logo: "https://cryptologos.cc/logos/tron-trx-logo.png",
64+
};
65+
```
66+
</TabItem>
67+
</Tabs>
3968

40-
<ChainDetailsTron />
69+
---
70+
71+
## Initializing and Instantiating the Web3Auth SDK
72+
73+
We will now initialize Web3Auth with the TRON configuration.
74+
75+
```typescript
76+
import { Web3AuthNoModal } from "@web3auth/no-modal";
77+
import { EthereumPrivateKeyProvider } from "@web3auth/ethereum-provider";
78+
import { AuthAdapter } from "@web3auth/auth-adapter";
79+
import { TRON_SHASTA_TESTNET } from "./chainConfig";
80+
import TronRpc from "./tronRPC";
81+
82+
const clientId = "YOUR_CLIENT_ID"; // Replace with your Web3Auth client ID
83+
84+
const privateKeyProvider = new EthereumPrivateKeyProvider({
85+
config: { chainConfig: TRON_SHASTA_TESTNET },
86+
});
87+
88+
const web3auth = new Web3AuthNoModal({
89+
clientId, // Your Web3Auth Client ID
90+
chainConfig: TRON_SHASTA_TESTNET, // Using Tron Shasta Testnet
91+
privateKeyProvider,
92+
});
93+
94+
const authAdapter = new AuthAdapter({
95+
adapterSettings: {
96+
uxMode: "redirect",
97+
},
98+
});
99+
web3auth.configureAdapter(authAdapter);
100+
await web3auth.init();
101+
```
41102

42103
---
43104

@@ -68,14 +129,52 @@ console.log(user);
68129

69130
---
70131

71-
## React Wagmi Integration
132+
## Get Account and Balance
133+
134+
Once logged in, we can use `tronRpc.ts` to fetch the user’s account and balance.
72135

73-
<ReactWagmiIntegration />
136+
```typescript
137+
// tronRpc.ts should be implemented as per previous example
138+
const tronRpc = new TronRpc(provider);
139+
await tronRpc.init();
140+
141+
// Get the user's Tron account address
142+
const accounts = await tronRpc.getAccounts();
143+
console.log("Account: ", accounts[0]);
144+
145+
// Get the balance
146+
const balance = await tronRpc.getBalance();
147+
console.log("Balance: ", balance);
148+
```
149+
150+
---
74151

75-
## Vue Wagmi Integration
152+
## Send Transaction
153+
154+
You can send a transaction using the user's private key.
155+
156+
```typescript
157+
const transaction = await tronRpc.sendTransaction();
158+
console.log("Transaction Hash: ", transaction);
159+
```
160+
161+
This will send a transaction from the user's Tron account.
162+
163+
---
164+
165+
## Sign a Message
166+
167+
You can also sign a message using the private key of the logged-in user.
168+
169+
```typescript
170+
const signedMessage = await tronRpc.signMessage("Hello Tron!");
171+
console.log("Signed Message: ", signedMessage);
172+
```
76173

77-
<VueWagmiIntegration />
174+
This will return the signature of the message.
78175

79-
## For VanillaJS, Angular and other frameworks
176+
## Conclusion
80177

81-
<JsBlockchainMethods />
178+
With Web3Auth, you can easily integrate Tron blockchain capabilities into your application. By using
179+
the TronWeb library, you can perform various blockchain operations such as fetching accounts,
180+
sending transactions, signing messages, and interacting with smart contracts.

0 commit comments

Comments
 (0)