|
1 | | -# trident |
| 1 | +# Trident - TRON Java SDK |
2 | 2 |
|
3 | | -trident is a SDK that includes libraries for working with TRON, it makes it easy to build TRON applications with multi-language. |
| 3 | +## Overview |
4 | 4 |
|
5 | | -## Contribution |
| 5 | +Trident is a lightweight Java SDK for interacting with the TRON blockchain. It provides a simple and efficient way to integrate TRON functionality into your Java applications. |
| 6 | + |
| 7 | +## Features |
| 8 | + |
| 9 | +- Complete implementation of TRON's gRPC interfaces |
| 10 | +- Smart contract deployment and interaction |
| 11 | +- Wallet key management and address utilities |
| 12 | +- Transaction building and signing |
| 13 | +- TRC10/TRC20/TRC721 token support |
| 14 | + |
| 15 | +## Adding Trident to your build |
| 16 | + |
| 17 | +Trident-java is compiled with java version 1.8 and gradle 7.6. |
| 18 | + |
| 19 | +### Gradle |
| 20 | + |
| 21 | +```groovy |
| 22 | + implementation("io.github.tronprotocol:trident:0.9.2") |
| 23 | +``` |
| 24 | + |
| 25 | +### Maven |
| 26 | + |
| 27 | +Add repo setting: |
| 28 | + |
| 29 | +```xml |
| 30 | +<dependency> |
| 31 | + <groupId>io.github.tronprotocol</groupId> |
| 32 | + <artifactId>trident</artifactId> |
| 33 | + <version>0.9.2</version> |
| 34 | +</dependency> |
| 35 | +``` |
| 36 | + |
| 37 | +### Using local build |
6 | 38 |
|
7 | | -We're very glad and appreciate to have contributions from the community. |
| 39 | +You can use locally built packages by follow steps: |
8 | 40 |
|
9 | | -Refer to our [contributing guide](./CONTRIBUTING.md) for more information. |
| 41 | +1. Copy the compiled jar file to your project's `libs` directory |
| 42 | +2. Add the following to your project's `build.gradle`: |
| 43 | +```groovy |
| 44 | +dependencies { |
| 45 | + implementation files('libs/trident-0.9.2.jar') |
| 46 | + implementation "com.google.guava:guava:33.0.0-jre" |
| 47 | + implementation "io.grpc:grpc-netty-shaded:1.60.0" |
| 48 | + implementation "io.grpc:grpc-netty:1.60.0" |
| 49 | + implementation "io.grpc:grpc-okhttp:1.60.0" |
| 50 | + implementation "io.grpc:grpc-protobuf:1.60.0" |
| 51 | + implementation "io.grpc:grpc-stub:1.60.0" |
| 52 | + implementation "com.google.protobuf:protobuf-java-util:3.25.5" |
| 53 | + implementation "org.bouncycastle:bcprov-jdk18on:1.78.1" |
| 54 | + implementation "io.vertx:vertx-core:4.5.10" |
| 55 | + implementation "io.netty:netty-all:4.1.118.Final" |
| 56 | + implementation "com.alibaba.fastjson2:fastjson2:2.0.55" |
| 57 | +} |
| 58 | +``` |
10 | 59 |
|
11 | | -[Join our Telegram group](https://t.me/TronOfficialDevelopersGroupEn) |
| 60 | +## Quick Start |
12 | 61 |
|
13 | | -## trident-java |
| 62 | +**Initialize client** |
| 63 | +```java |
| 64 | +// Initialize with TronGrid mainnet |
| 65 | +ApiWrapper client = ApiWrapper.ofMainnet("private_key", "api_key"); //api_key from TronGrid |
14 | 66 |
|
15 | | -trident-java is a lightweight SDK that includes libraries for working with TRON network. |
| 67 | +//Or Shasta test net |
| 68 | +ApiWrapper client = ApiWrapper.ofShasta("private key"); |
16 | 69 |
|
17 | | -Functions include: |
| 70 | +// Or nile testnet |
| 71 | +ApiWrapper client = ApiWrapper.ofNile("private_key"); |
18 | 72 |
|
19 | | -- Offline address generation |
| 73 | +//Initialize with special grpc endpoint |
| 74 | +ApiWrapper client = new ApiWrapper("grpc endpoint", "solidity grpc endpoint", "private_key"); |
| 75 | + |
| 76 | +// Send TRX |
| 77 | +TransactionExtention transactionExtention = client.transfer("fromAddress", "toAddress", 100_000_000L); //100TRX |
| 78 | +// Sign |
| 79 | +Transaction signedTxn = client.signTransaction(transactionExtention); |
| 80 | +// Broadcast |
| 81 | +String txId = client.broadcastTransaction(signedTxn); |
| 82 | +System.out.println("txId is " + txId); |
| 83 | +``` |
| 84 | + |
| 85 | +## Documentation |
| 86 | + |
| 87 | +- [Official Documentation](https://developers.tron.network/docs/trident-java) |
| 88 | + |
| 89 | + |
| 90 | +## Build instructions |
| 91 | +Trident includes integration tests for running on the Nile testnet. If you want to run test cases involving write operations on the blockchain, such as transfer or deploy contract and so on, please follow the steps: |
| 92 | + |
| 93 | +1. Uncomment the Disabled function in the unit test cases. |
| 94 | +``` |
| 95 | + //@Disabled("add private key to enable this case") |
| 96 | +``` |
| 97 | +2. Set the tron.private-key and tron.tokenId in the test configuration file in the core directory [here](trident-java/core/src/test/resources/application-test.properties). |
| 98 | + |
| 99 | + |
| 100 | +``` |
| 101 | +tron.private-key=xxx |
| 102 | +tron.tokenId=1000587 |
| 103 | +``` |
| 104 | + |
| 105 | +**Note:** The account should have at least 1000 TRX, 100 USDT, and 1000 TRC10 token on the Nile testnet. you can get testCoin from [nileex.io](https://nileex.io/join/getJoinPage). |
| 106 | + |
| 107 | +## Contribution |
20 | 108 |
|
21 | | -- Offline transaction construct |
| 109 | +We're very glad and appreciate to have contributions from the community. |
22 | 110 |
|
23 | | -- Offline transaction signature |
| 111 | +Refer to our [contributing guide ](CONTRIBUTING.md)for more information. |
24 | 112 |
|
25 | | -- java-tron full node API support |
| 113 | +## Licence |
26 | 114 |
|
27 | | -For more informations refer to : [trident-java document](https://developers.tron.network/docs/trident-java) |
| 115 | +Trident is distributed under a MIT licence. |
0 commit comments