This is a Kotlin library for interacting with the Tron blockchain. It provides a set of functions to easily interact with Tron, including retrieving blocks, transactions, and other related information.
This library offers the following features for interacting with the Tron blockchain:
- /wallet/getblockbyid: Get block information by block ID Link.
- /wallet/getblockbylatestnum: Get the latest block information Link.
- /wallet/getnowblock: Get information about the current block Link.
- /wallet/getblockbynum: Get block information by block number Link.
- /wallet/getblock: Get a list of blocks Link.
- /wallet/gettransactioninfobyid: Get transaction information by transaction ID Link.
- /wallet/gettransactioninfobyblocknum: Get transaction information in a block by block number Link.
- /wallet/gettransactionbyid: Get transaction details by transaction ID Link.
- /wallet/triggersmartcontract: Trigger a smart contract Link.
- /wallet/getaccountresource: Get account resource information Link.
- /wallet/getaccount: Get account information Link.
- /wallet/broadcasttransaction: Broadcast a transaction Link.
- /wallet/broadcasthex: Broadcast a transaction in hex format Link.
You can reference this library using JitPack. Add the following code to your project's root build.gradle file:
allprojects {
repositories {
// Add the JitPack repository
maven { url 'https://jitpack.io' }
}
}Then, add the dependency to your app module's build.gradle file:
dependencies {
implementation 'com.github.Wenpiner:TronApi:1.0.3'
}
Here are some simple examples of using this library:
import com.github.wenpiner.tron.block.api.TronApi
fun main() {
val tronClient = TronApi() // Replace with the actual Tron API URL
// Get the latest block
val latestBlock = tronClient.getBlockByLatestNum()
println("Latest Block: $latestBlock")
// Get a block by block number
val blockByNumber = tronClient.getBlockByNum(12345)
println("Block #12345: $blockByNumber")
// Get transaction details
val transactionInfo = tronClient.getTransactionInfoById("your-transaction-id")
println("Transaction Info: $transactionInfo")
}
If you want to learn more about the Tron blockchain API, you can refer to the Tron Developer Documentation.
This library is licensed under the MIT License. See the LICENSE file for more information.