Skip to content

Commit

Permalink
feat: add Tron integration docs
Browse files Browse the repository at this point in the history
  • Loading branch information
HoangVD2 committed Jul 4, 2024
1 parent 01f3a5f commit af131d9
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 7 deletions.
16 changes: 10 additions & 6 deletions .vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -430,10 +430,18 @@ function sidebarHome() {
text: "Bitcoin Cash",
link: "/developers/extension-bitcoin-cash",
},
{
text: "Cosmos",
link: "/developers/extension-cosmos",
},
{
text: "Dogecoin",
link: "/developers/extension-dogecoin",
},
{
text: "Ethereum (EVM's)",
link: "/developers/extension-evms",
},
{
text: "Litecoin",
link: "/developers/extension-litecoin",
Expand All @@ -455,12 +463,8 @@ function sidebarHome() {
link: "/developers/extension-thorchain",
},
{
text: "Ethereum (EVM's)",
link: "/developers/extension-evms",
},
{
text: "Cosmos",
link: "/developers/extension-cosmos",
text: "Tron",
link: "/developers/extension-tron",
},
],
},
Expand Down
2 changes: 1 addition & 1 deletion developers/extension-solana.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Develop Solana dApps

Example dApp using Solana: [https://xdefi-example-dapps.herokuapp.com/multichain/](https://xdefi-example-dapps.herokuapp.com/multichain/) ( [https://github.com/XDeFi-tech/examples-dapps-sdk](https://github.com/XDeFi-tech/examples-dapps-sdk) )
Example dApp using Solana: [https://main.d2ladgp2r2c4c2.amplifyapp.com/](https://main.d2ladgp2r2c4c2.amplifyapp.com/)

### Solana Provider

Expand Down
78 changes: 78 additions & 0 deletions developers/extension-tron.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Extension Wallet Tron Integration

Develop Tron dApps

Example dApp using Tron: [https://main.d2ladgp2r2c4c2.amplifyapp.com/](https://main.d2ladgp2r2c4c2.amplifyapp.com/)

### Tron Provider

XDEFI Wallet provider exposes different methods in `window.xfi.tron` or `window.tron`

Below are functions supported by the provider `window.tron` or `window.xfi.tron`.

### Accounts Request

::: code-group

```javascript [Request]
const accounts = await window.xfi.tron.request({
method: 'eth_requestAccounts',
})
console.log(accounts)
```

```json [Response]
["TQXoXrsGLVhPM9jp2DNyQhnuZn2UcnSm8m"]
```
:::

### Sign Message V2

`signMessageV2(message: string, privateKey?: string): Promise<string>;`

::: code-group

```javascript [Request]
const signature = await window.xfi.tron.tronWeb.trx.signMessageV2('Hello World');

console.log(signature);

```

```json [Response]
"0xb6a8a33133bcc490ac028f85aa370ada2b7368e55cf274ab5cce246365e2e8724566a388293b21c03dbfbe71ee1cf2df02487e54176ea09cce602e134ff87d8d1c"
```
:::

### Get Block By Number

`getBlockByNumber(index: number): Promise<{ blockID: string }>;`

::: code-group

```javascript [Request]

const response = await window.xfi.tron.tronWeb.trx.getBlockByNumber(1000);

console.log(response);

```

```json [Response]
{
"blockID": "00000000000000644df09e6883a3a7900814f8d78cf47b255b7ed284527a773d",
"block_header": {
"raw_data": {
"number": 100,
"txTrieRoot": "0000000000000000000000000000000000000000000000000000000000000000",
"witness_address": "414b4778beebb48abe0bc1df42e92e0fe64d0c8685",
"parentHash": "0000000000000063ed8544c4c17fc053dfc729e610673c783bcdc3cf0781b07f",
"timestamp": 1529891811000
},
"witness_signature": "277d4440e2feb552b6d2d557ba407f68310887020fcc7ef6e2733286a0d13c703ebf2306293bda9d2ddac09835be67583c736a65494115825b6f4ab6a15f1e0f01"
}
}
```
:::

More features coming soon...
1 change: 1 addition & 0 deletions developers/extension-wallet.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ XDEFI Wallet injects into the window object to dapps multiple wallet providers t
- window.xfi.solana : [Solana provider](./extension-solana)
- window.xfi.terra : [Terra provider](./extension-terra)
- window.xfi.thorchain: [Thorchain provider](./extension-thorchain)
- window.xfi.tron: [Tron provider](./extension-tron)
- window.ethereum : [Ethereum provider](./extension-evms)
- window.keplr : [Keplr/Cosmos chains provider](./extension-cosmos)

0 comments on commit af131d9

Please sign in to comment.