Skip to content
Logo

Providers

A provider is your handle to a TRON node. It exposes read methods (account state, blocks, resources), lazy builders for write operations, and the low-level send/broadcast primitives. The whole surface is defined by the TronProvider trait.

use tronz::{ProviderBuilder, TronProvider};

Anatomy

tronz separates concerns into layers — closely mirroring alloy:

PieceRole
ProviderBuilderAssembles fillers + signer, then binds a transport
RootProviderThe base provider over a transport — reads only
FilledProviderA RootProvider wrapped with a filler chain; this is what you use
transportThe gRPC connection to the node

ProviderBuilder::new().on_grpc(uri) produces a FilledProvider, which implements TronProvider.

What you can do

use tronz::{ProviderBuilder, TronProvider, TRONGRID_MAINNET};
 
# async fn run() -> anyhow::Result<()> {
let provider = ProviderBuilder::new().on_grpc(TRONGRID_MAINNET).await?;
 
// Reads (no signer required)
let block = provider.get_now_block().await?;
let account = provider.get_account("TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t".parse()?).await?;
 
// Lazy write builders (require a signer to `.send()`)
// provider.send_trx()...
// provider.freeze_balance()...
// provider.delegate_resource()...
# Ok(()) }

Cloning

TronProvider requires Clone + Send + Sync + 'static. Providers are cheap to clone (the transport is shared), so pass clones freely across tasks rather than wrapping in Arc yourself.