Expand description
§tronz
tronz connects applications to the TRON network.
An idiomatic, async-first Rust SDK for TRON — inspired by alloy.
§Installation
Add the tronz crate with the full feature flag:
cargo add tronz --features fullOr in your Cargo.toml:
tronz = { version = "0.2", features = ["full"] }A full list of available features can be found in the
tronz crate’s Cargo.toml.
§Examples
§Querying the latest block
use tronz::{ProviderBuilder, TronProvider, TRONGRID_MAINNET};
let provider = ProviderBuilder::new().on_grpc(TRONGRID_MAINNET).await?;
let block = provider.get_now_block().await?;
println!("Latest block: {} ({}ms)", block.number, block.timestamp);§Sending TRX
use tronz::{LocalSigner, ProviderBuilder, TronProvider, TronSigner, Trx, TRONGRID_NILE};
let signer = LocalSigner::from_hex("PRIVATE_KEY_HEX").expect("valid key");
let from = signer.address();
let provider = ProviderBuilder::new()
.with_recommended_fillers()
.with_signer(signer)
.on_grpc(TRONGRID_NILE)
.await?;
let pending = provider
.send_trx()
.to(from)
.amount(Trx::from_sun_unchecked(1_000_000))
.send()
.await?;
let receipt = pending.get_receipt().await?;
println!("Status: {:?}", receipt.status);For more examples, see the examples/ directory.
§Crates
| Crate | Description |
|---|---|
tronz | Meta-crate re-exporting all sub-crates |
tronz-primitives | Address, Trx, ResourceCode, signatures |
tronz-signer | TronSigner trait and LocalSigner implementation |
tronz-provider | Transport, provider, fillers, and domain types |
tronz-contract | TRC20 / TRC721 ABI bindings |
§Supported Rust Versions (MSRV)
The minimum supported Rust version is 1.85.
§Contributing
See CONTRIBUTING.md.
§License
Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Re-exports§
pub use primitives::Address;pub use primitives::Trx;pub use primitives::U256;pub use tronz_signer::LocalSigner;pub use tronz_signer::TronSigner;pub use tronz_provider::ProviderBuilder;pub use tronz_provider::TronProvider;pub use tronz_provider::transport::grpc::TRONGRID_MAINNET;pub use tronz_provider::transport::grpc::TRONGRID_NILE;
Modules§
- contract
contract - TRC20 / TRC721 contract bindings and provider-bound instances.
- primitives
- Core TRON primitives: addresses, amounts, resource codes, signatures.
- providers
- Interface with a TRON node.
- signers
- TRON signer abstraction and local key implementation.
- transports
- Low-level gRPC transport and well-known endpoint constants.