Expand description
§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 tronz_contract::{Interface, instance::ContractExt};
use alloy_json_abi::JsonAbi;
let abi: JsonAbi = serde_json::from_str(ABI_JSON).unwrap();
let contract = provider.contract(address, abi.into());
// read-only call
let values = contract.call("balanceOf", &[account.into()]).await?;
// state-changing call
let pending = contract.send("transfer", &[to.into(), amount.into()]).await?;
let receipt = pending.get_receipt().await?;§Standard token interfaces (static ABI)
Use the typed wrappers for well-known standards:
ⓘ
use tronz_contract::trc20::Trc20Ext;
let token = provider.trc20(usdt_address);
println!("name : {}", token.name().await?);
println!("balance : {}", token.balance_of(my_address).await?);
let pending = token.transfer(recipient, amount).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.
Modules§
- event
- Event log decoding helpers for TRON smart contracts. Event log decoding for TRON smart contracts.
- trc20
- Static TRC20 ABI bindings and encode/decode helpers.
TRC20 ABI bindings and (optionally) the provider-bound [
Trc20Instance]. - trc721
- Static TRC721 ABI bindings and encode/decode helpers.
TRC721 ABI bindings and (optionally) the provider-bound [
Trc721Instance].
Structs§
- Address
- A TRON network address (
0x41prefix + 20-byte body). - Bytes
- Wrapper type around
bytes::Bytesto support “0x” prefixed hex strings.
Traits§
- SolCall
- Re-exported alloy ABI types for use with generated calls. A Solidity function call.
- SolError
- Re-exported alloy ABI types for use with generated calls. A Solidity custom error.
- SolEvent
- Re-exported alloy ABI types for use with generated calls. Solidity event.
- SolInterface
- Re-exported alloy ABI types for use with generated calls.
A collection of ABI-encodable call-like types. This currently includes
SolCallandSolError. - SolValue
- Re-exported alloy ABI types for use with generated calls. A Solidity value.
Type Aliases§
- U256
- 256-bit unsigned integer type, consisting of 4, 64-bit limbs.