tronz-sol-macro 0.3.0

The `tron_sol!` procedural macro for the tronz TRON SDK — generates provider-bound, type-safe contract bindings from Solidity.
Documentation

The [tron_sol!] procedural macro — a TRON-aware superset of alloy's sol!.

tron_sol! forwards its entire input to alloy_sol_types::sol! to generate the Solidity type layer (…Call structs, events, errors, custom types, free-standing struct/enum/type definitions, …) and additionally generates a provider-bound Instance for every contract/interface carrying #[sol(rpc)], wired to tronz's TronProvider.

It also accepts a JSON ABI file path (or inline JSON) in the same abigen-style form that alloy's sol! supports:

// Load ABI from a file path (relative to the crate root).
tron_sol! {
    #[sol(rpc)]
    MyContract, "abi/MyContract.json"
}

// Both raw ABI arrays `[...]` and Forge artifacts `{"abi":[...]}` are accepted.

It accepts everything sol! does for the inline-Solidity form, including:

  • multiple items in one invocation (several contracts, or contracts mixed with bare struct/enum/error/event/type definitions);
  • attribute passthrough: any attribute other than the TRON-specific ones (#[sol(rpc)], #[sol(bytecode = …)], #[sol(deployed_bytecode = …)], #[tron_sol(…)]) is forwarded verbatim to sol! — so #[derive(…)], #[sol(all_derives)], #[sol(extra_derives(…))], doc comments, etc. all work on the generated type layer.

TRON-specific attributes:

  • #[sol(rpc)] — also generate a TronProvider-bound Instance.
  • #[sol(bytecode = "0x…")] — embed creation bytecode and generate deploy_builder / deploy helpers (requires #[sol(rpc)]).
  • #[sol(deployed_bytecode = "0x…")] — embed the runtime bytecode as a DEPLOYED_BYTECODE constant.
  • #[tron_sol(tronz_crate = <path>)] — override the runtime crate path.
// Type layer only (same as sol!) — bare types and multiple items are fine.
tron_sol! {
    struct Foo { uint256 x; }
    enum Bar { A, B }
}

// Type layer + TRON RPC bindings, with derive passthrough.
tron_sol! {
    #[derive(Debug)]
    #[sol(rpc)]
    interface IERC20 {
        function balanceOf(address owner) external view returns (uint256);
        function transfer(address to, uint256 amount) external returns (bool);
    }
}

let contract = IERC20::new(usdt_addr, provider);
let balance = contract.balanceOf(owner).call().await?;