Skip to main content

Crate tronz_primitives

Crate tronz_primitives 

Source
Expand description

§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
LogSmart-contract event log containing an emitter address, indexed topics, and data

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
Types re-used directly from alloy-primitives. Wrapper type around bytes::Bytes to support “0x” prefixed hex strings.
Log
An EVM-style event log emitted during contract execution.
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.
UnknownResourceCode
Error produced when a protobuf discriminant does not name a known ResourceCode.

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.
TRON_MESSAGE_PREFIX
The TRON personal-message prefix used by TronWeb signMessageV2.

Functions§

format_trx
Format a Trx amount as a decimal string with exactly 6 fractional digits.
hash_message
Hash a message the way TronWeb signMessageV2 does.
keccak256
Types re-used directly from alloy-primitives. Simple interface to the Keccak-256 hash function.
parse_trx
Parse a decimal TRX string (e.g. "1.5" or "100") into a Trx amount.
recover_message_address
Recover the TRON address that signed message (TronWeb verifyMessageV2).
verify_message
Verify that signature over message was produced by address.

Type Aliases§

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