tronz-contract
ABI bindings and contract instances for the tronz TRON SDK.
TRON smart contracts are EVM-compatible, so this crate reuses alloy's
sol! macro and ABI codec directly rather than
hand-rolling an encoder.
Features
| Feature | What it enables |
|---|---|
| (none) | Static ABI encode/decode via sol! (no I/O, no provider dep) |
provider |
ContractInstance, Interface, Trc20Instance, and extension traits |
Interacting with arbitrary contracts (dynamic ABI)
Load a JSON ABI at runtime and call any function by name:
use ;
let abi: JsonAbi = from_str.unwrap;
let contract = provider.contract;
// read-only call
let values = contract.call.await?;
// state-changing call
let pending = contract.send.await?;
let receipt = pending.get_receipt.await?;
Deploying with ABI metadata
DeployBuilder accepts Alloy's typed JsonAbi and converts it to native
TronAbi metadata before sending the protobuf request:
use ;
let abi: JsonAbi = from_str?;
let pending = provider
.deploy
.abi
.name
.send
.await?;
Provider queries return native TronAbi so all node metadata remains readable,
including unknown entry types and incomplete tuples. Convert explicitly when a
dynamic Alloy interface is needed:
let info = provider.get_contract_info.await?;
let json_abi = info.abi.try_to_json_abi?;
let contract = provider.contract;
Use .tron_abi(abi) instead of .abi(abi) to deploy already-native metadata
without an Alloy conversion.
Standard token interfaces (static ABI)
Use the typed wrappers for well-known standards:
use Trc20Ext;
let token = provider.trc20;
println!;
println!;
let pending = token.transfer.await?;
let receipt = pending.get_receipt.await?;
Crate layout
trc20— staticsol!bindings +Trc20Instancehigh-level wrapperInterfacewrappingJsonAbiwith O(1) selector lookupContractInstance— generic contract handleContractErrorandResulttype alias
License
Licensed under either of Apache License, Version 2.0 or MIT license at your option.