Skip to content

Commit 7c5e49b

Browse files
committed
docs
1 parent 5b205d1 commit 7c5e49b

File tree

8 files changed

+101
-37
lines changed

8 files changed

+101
-37
lines changed

book/src/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
- [Solana](framework/components/blockchains/solana.md)
4040
- [Aptos](framework/components/blockchains/aptos.md)
4141
- [Sui](framework/components/blockchains/sui.md)
42+
- [TRON](framework/components/blockchains/tron.md)
4243
- [Optimism Stack]()
4344
- [Arbitrum Stack]()
4445
- [Chainlink](framework/components/chainlink.md)
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# TRON Blockchain Client
2+
3+
## Configuration
4+
```toml
5+
[blockchain_a]
6+
type = "tron"
7+
# image = "tronbox/tre" is default image
8+
```
9+
Default port is `9090`
10+
11+
## Usage
12+
```golang
13+
package examples
14+
15+
import (
16+
"github.com/smartcontractkit/chainlink-testing-framework/framework"
17+
"github.com/smartcontractkit/chainlink-testing-framework/framework/components/blockchain"
18+
"github.com/stretchr/testify/require"
19+
"testing"
20+
)
21+
22+
type CfgTron struct {
23+
BlockchainA *blockchain.Input `toml:"blockchain_a" validate:"required"`
24+
}
25+
26+
func TestTRONSmoke(t *testing.T) {
27+
in, err := framework.Load[CfgTron](t)
28+
require.NoError(t, err)
29+
30+
bc, err := blockchain.NewBlockchainNetwork(in.BlockchainA)
31+
require.NoError(t, err)
32+
33+
// all private keys are funded
34+
_ = blockchain.TRONAccounts.PrivateKeys[0]
35+
36+
t.Run("test something", func(t *testing.T) {
37+
// use internal URL to connect Chainlink nodes
38+
_ = bc.Nodes[0].DockerInternalHTTPUrl
39+
// use host URL to interact
40+
_ = bc.Nodes[0].HostHTTPUrl
41+
42+
// use bc.Nodes[0].HostHTTPUrl + "/wallet" to access full node
43+
// use bc.Nodes[0].HostHTTPUrl + "/walletsolidity" to access Solidity node
44+
})
45+
}
46+
```
47+
48+
## More info
49+
50+
Follow the [guide](https://developers.tron.network/reference/tronbox-quickstart) if you want to work with `TRONBox` environment via JS
51+
52+
## Golang HTTP Client
53+
54+
TRON doesn't have any library to interact with it in `Golang` but we maintain our internal fork [here](https://github.com/smartcontractkit/chainlink-internal-integrations/tree/69e35041cdea0bc38ddf642aa93fd3cc3fb5d0d9/tron/relayer/gotron-sdk)
55+
56+
Check TRON [HTTP API](https://tronprotocol.github.io/documentation-en/api/http/)
57+
58+
Full node is on `:9090/wallet`
59+
```
60+
curl -X POST http://127.0.0.1:9090/wallet/createtransaction -d '{
61+
"owner_address": "TRGhNNfnmgLegT4zHNjEqDSADjgmnHvubJ",
62+
"to_address": "TJCnKsPa7y5okkXvQAidZBzqx3QyQ6sxMW",
63+
"amount": 1000000,
64+
"visible": true
65+
}'
66+
```
67+
68+
Solidity node is on `:9090/walletsolidity`
69+
```
70+
curl -X POST http://127.0.0.1:9090/walletsolidity/getaccount -d '{"address": "41E552F6487585C2B58BC2C9BB4492BC1F17132CD0"}'
71+
```

framework/cmd/observability/compose/docker-compose.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ services:
1919
- /var/run/docker.sock:/var/run/docker.sock
2020
- ./conf/prometheus.yml:/etc/prometheus/prometheus.yml
2121
ports:
22-
- "9090:9090"
22+
- "9999:9090"
2323
loki:
2424
image: grafana/loki:2.5.0
2525
volumes:

framework/components/blockchain/tron.go

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,25 @@ type Accounts struct {
2020
More []string `json:"more"`
2121
}
2222

23+
var TRONAccounts = Accounts{
24+
HDPath: "m/44'/195'/0'/0/",
25+
Mnemonic: "resemble birth wool happy sun burger fatal trumpet globe purity health ritual",
26+
PrivateKeys: []string{
27+
"932a39242805a1b1095638027f26af9664d1d5bf8ab3b7527ee75e7efb2946dd",
28+
"1c17c9c049d36cde7e5ea99df6c86e0474b04f0e258ab619a1e674f397a17152",
29+
"458130a239671674746582184711a6f8d633355df1a491b9f3b323576134c2e9",
30+
"2676fd1427968e07feaa9aff967d4ba7607c5497c499968c098d0517cd75cfbb",
31+
"d26b24a691ff2b03ee6ab65bf164def216f73574996b9ca6299c43a9a63767ac",
32+
"55df6adf3d081944dbe4688205d94f236fb4427ac44f3a286a96d47db0860667",
33+
"8a9a60ddd722a40753c2a38edd6b6fa38e806d681c9b08a520ba4912e62b6458",
34+
"75eb182fb623acf5e53d9885c4e8578f2530533a96c753481cc4277ecc6022de",
35+
"6c4b22b1d9d68ef7a8ecd151cd4ffdd4ecc2a7b3a3f8a9f9f9bbdbcef6671f10",
36+
"e578d66453cb41b6c923b9caa91c375a0545eeb171ccafc60b46fa834ce5c200",
37+
},
38+
// should not be empty, otherwise TRE will panic
39+
More: []string{},
40+
}
41+
2342
const (
2443
DefaultTronPort = "9090"
2544
)
@@ -44,24 +63,7 @@ func newTron(in *Input) (*Output, error) {
4463
if err != nil {
4564
return nil, err
4665
}
47-
accountsData, err := json.Marshal(Accounts{
48-
HDPath: "m/44'/195'/0'/0/",
49-
Mnemonic: "resemble birth wool happy sun burger fatal trumpet globe purity health ritual",
50-
PrivateKeys: []string{
51-
"932a39242805a1b1095638027f26af9664d1d5bf8ab3b7527ee75e7efb2946dd",
52-
"1c17c9c049d36cde7e5ea99df6c86e0474b04f0e258ab619a1e674f397a17152",
53-
"458130a239671674746582184711a6f8d633355df1a491b9f3b323576134c2e9",
54-
"2676fd1427968e07feaa9aff967d4ba7607c5497c499968c098d0517cd75cfbb",
55-
"d26b24a691ff2b03ee6ab65bf164def216f73574996b9ca6299c43a9a63767ac",
56-
"55df6adf3d081944dbe4688205d94f236fb4427ac44f3a286a96d47db0860667",
57-
"8a9a60ddd722a40753c2a38edd6b6fa38e806d681c9b08a520ba4912e62b6458",
58-
"75eb182fb623acf5e53d9885c4e8578f2530533a96c753481cc4277ecc6022de",
59-
"6c4b22b1d9d68ef7a8ecd151cd4ffdd4ecc2a7b3a3f8a9f9f9bbdbcef6671f10",
60-
"e578d66453cb41b6c923b9caa91c375a0545eeb171ccafc60b46fa834ce5c200",
61-
},
62-
// should not be empty, otherwise TRE will panic
63-
More: []string{},
64-
})
66+
accountsData, err := json.Marshal(TRONAccounts)
6567
if err != nil {
6668
return nil, err
6769
}

framework/components/blockchain/tron/accounts.json

Lines changed: 0 additions & 17 deletions
This file was deleted.

framework/examples/myproject/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ require (
1414
github.com/blocto/solana-go-sdk v1.30.0
1515
github.com/ethereum/go-ethereum v1.14.11
1616
github.com/go-resty/resty/v2 v2.15.3
17-
github.com/smartcontractkit/chainlink-testing-framework/framework v0.4.1
17+
github.com/smartcontractkit/chainlink-testing-framework/framework v0.4.4
1818
github.com/smartcontractkit/chainlink-testing-framework/seth v1.50.10
1919
github.com/smartcontractkit/chainlink-testing-framework/wasp v1.50.2
2020
github.com/stretchr/testify v1.10.0
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
[blockchain_a]
22
type = "tron"
3+
image = "tronbox/tre"

framework/examples/myproject/smoke_tron_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,16 @@ func TestTRONSmoke(t *testing.T) {
1818
bc, err := blockchain.NewBlockchainNetwork(in.BlockchainA)
1919
require.NoError(t, err)
2020

21+
// all private keys are funded
22+
_ = blockchain.TRONAccounts.PrivateKeys[0]
23+
2124
t.Run("test something", func(t *testing.T) {
2225
// use internal URL to connect Chainlink nodes
2326
_ = bc.Nodes[0].DockerInternalHTTPUrl
2427
// use host URL to interact
2528
_ = bc.Nodes[0].HostHTTPUrl
29+
30+
// use bc.Nodes[0].HostHTTPUrl + "/wallet" to access full node
31+
// use bc.Nodes[0].HostHTTPUrl + "/walletsolidity" to access Solidity node
2632
})
2733
}

0 commit comments

Comments
 (0)