Skip to content
项目

关于

A lightweight Java SDK for interacting with the TRON blockchain.

商业与金融

这些数字如何统计

可以做什么

  • Complete implementation of TRON's gRPC interfaces
  • Smart contract deployment and interaction
  • Wallet key management and address utilities
  • Transaction building and signing

实测星标增长

24小时
0
7天
+1
15天
+1
1个月
正在收集历史

各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。

README.md

原文

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

Build Trident with JDK 8 or 17 using the Gradle 8.14.8 Wrapper.

The latest version (built with JDK 1.8) can be found on Maven Central.

Gradle

implementation("io.github.tronprotocol:trident:1.0.1")

Maven

Add repo setting:

<dependency>
  <groupId>io.github.tronprotocol</groupId>
  <artifactId>trident</artifactId>
  <version>1.0.1</version>
</dependency>

Using local build

You can use locally built packages by the following steps:

  1. Copy the compiled jar file to your project's libs directory
  2. Add the following to your project's build.gradle:
dependencies {
    implementation files('libs/trident-1.0.1.jar')
    implementation "com.google.guava:guava:33.8.0-jre"
    implementation "io.grpc:grpc-netty-shaded:1.86.0"
    implementation "io.grpc:grpc-netty:1.86.0"
    implementation "io.grpc:grpc-okhttp:1.86.0"
    implementation "io.grpc:grpc-protobuf:1.86.0"
    implementation "io.grpc:grpc-stub:1.86.0"
    implementation "com.google.protobuf:protobuf-java-util:3.25.9"
    implementation "org.bouncycastle:bcprov-jdk18on:1.87"
    implementation "io.vertx:vertx-core:4.5.35"
    implementation platform("io.netty:netty-bom:4.2.21.Final")
    implementation "io.netty:netty-buffer"
    implementation "com.alibaba.fastjson2:fastjson2:2.0.55"
}

Note: If your code directly uses other netty modules (e.g. io.netty.channel.*, io.netty.handler.*, io.netty.codec.*), add the corresponding artifact after the BOM without specifying a version — the version will be resolved by netty-bom. For example: implementation "io.netty:netty-handler".

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");

// Or initialize with a custom grpc endpoint.
ApiWrapper client = new ApiWrapperBuilder("grpc endpoint")
    .withGrpcEndpointSolidity("solidity grpc endpoint")
    .withPrivateKey("private_key")
    .withApiKey("api_key")             // Optional: API key from TronGrid
    .withTLS()                         // Optional: or withTLS(new File("xxx.crt"))
    .withTimeout(5000)                 // Optional: request timeout in milliseconds
    .addInterceptors(interceptors)     // Optional: custom gRPC interceptors
    .build();

// 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:

  1. Uncomment the Disabled function in the unit test cases.
   //@Disabled("add private key to enable this case")
  1. 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: [email protected]

探索相关项目

加载中…