Trident
A lightweight Java SDK for interacting with the TRON blockchain.
Install / Use
/learn @tronprotocol/TridentREADME
Trident - TRON Java SDK
Overview
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.
Features
- Complete implementation of TRON's gRPC interfaces
- Smart contract deployment and interaction
- Wallet key management and address utilities
- Transaction building and signing
- TRC10/TRC20/TRC721 token support
Adding Trident to your build
Since version 0.11.0, Trident can be built with JDK 1.8 or JDK17 on Gradle 8.5.
The latest version (built with JDK 1.8) can be found on Maven Central.
Gradle
implementation("io.github.tronprotocol:trident:0.11.0")
Maven
Add repo setting:
<dependency>
<groupId>io.github.tronprotocol</groupId>
<artifactId>trident</artifactId>
<version>0.11.0</version>
</dependency>
Using local build
You can use locally built packages by the following steps:
- Copy the compiled jar file to your project's
libsdirectory - Add the following to your project's
build.gradle:
dependencies {
implementation files('libs/trident-0.11.0.jar')
implementation "com.google.guava:guava:33.0.0-jre"
implementation "io.grpc:grpc-netty-shaded:1.75.0"
implementation "io.grpc:grpc-netty:1.75.0"
implementation "io.grpc:grpc-okhttp:1.75.0"
implementation "io.grpc:grpc-protobuf:1.75.0"
implementation "io.grpc:grpc-stub:1.75.0"
implementation "com.google.protobuf:protobuf-java-util:3.25.8"
implementation "org.bouncycastle:bcprov-jdk18on:1.78.1"
implementation "io.vertx:vertx-core:4.5.21"
implementation "io.netty:netty-all:4.1.125.Final"
implementation "com.alibaba.fastjson2:fastjson2:2.0.55"
}
Quick Start
Initialize client
// Initialize with TronGrid mainnet
ApiWrapper client = ApiWrapper.ofMainnet("private_key", "api_key"); //api_key from TronGrid
//Or Shasta test net
ApiWrapper client = ApiWrapper.ofShasta("private key");
// Or nile testnet
ApiWrapper client = ApiWrapper.ofNile("private_key");
//Initialize with special grpc endpoint
ApiWrapper client = new ApiWrapper("grpc endpoint", "solidity grpc endpoint", "private_key");
// Send TRX
TransactionExtention transactionExtention = client.transfer("fromAddress", "toAddress", 100_000_000L); //100TRX
// Sign
Transaction signedTxn = client.signTransaction(transactionExtention);
// Broadcast
String txId = client.broadcastTransaction(signedTxn);
System.out.println("txId is " + txId);
Documentation
Build instructions
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:
- Uncomment the Disabled function in the unit test cases.
//@Disabled("add private key to enable this case")
- Set the tron.private-key and tron.tokenId in the test configuration file in the core directory here.
tron.private-key=xxx
tron.tokenId=1000587
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.
Contribution
We're very glad and appreciate to have contributions from the community.
Refer to our contributing guide for more information.
Integrity Check
Starting from version 0.9.2, releases are published to Maven repository and signed with the gpg key:
pub: 3149 FCA5 6377 2D11 2624 9C36 CC3F 8CEA 7B0C 74D6
uid: buildtrident@tron.network
Related Skills
node-connect
346.8kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
107.6kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
346.8kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
346.8kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
