Skip to main content

Crate primitives

Crate primitives 

Source
Expand description

Core TRON primitives: addresses, amounts, resource codes, signatures.

§tronz-primitives

Leaf primitive types for the tronz TRON SDK.

This crate performs no network I/O and contains no protobuf code. It only defines the small, widely-shared value types that every other crate in the workspace depends on.

§Types

TypeDescription
Address21-byte TRON address (0x41 prefix + 20-byte body); parses base58check (T…) and hex
TrxAmount denominated in sun (1 TRX = 1_000_000 sun); wraps i64 to match protobuf
ResourceCodeBandwidth, Energy, or TronPower — the stakeable network resources
RecoverableSignature65-byte r ‖ s ‖ v secp256k1 signature with embedded recovery id

Common byte/arithmetic types (U256, B256, Bytes, keccak256) are re-exported from alloy_primitives so the rest of the workspace has a single import surface.

§License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.

Structs§

Address
A TRON network address (0x41 prefix + 20-byte body).
Bytes
Wrapper type around bytes::Bytes to support “0x” prefixed hex strings.
RecoverableSignature
A secp256k1 ECDSA signature plus the recovery id needed to recover the signing public key.
Trx
An amount of TRX, stored internally as i64 sun.

Enums§

AddressError
Errors produced when parsing or validating a TRON Address.
AmountError
Errors produced when constructing a Trx amount.
ResourceCode
The kind of network resource obtained by staking TRX.
SignatureError
Errors produced when constructing a RecoverableSignature.

Constants§

ADDRESS_LEN
Length of a raw TRON address in bytes (prefix + 20-byte body).
ADDRESS_PREFIX
The TRON mainnet address prefix byte.
EVM_ADDRESS_LEN
Length of the EVM-style address body (without the 0x41 prefix).
SIGNATURE_LEN
Length of the serialized signature: r(32) || s(32) || v(1).
SUN_PER_TRX
Number of sun in one TRX.

Functions§

keccak256
Simple interface to the Keccak-256 hash function.

Type Aliases§

B256
32-byte fixed byte-array type.
TxId
A transaction id: sha256 of the protobuf-encoded raw transaction.
U256
256-bit unsigned integer type, consisting of 4, 64-bit limbs.