pub struct Address(/* private fields */);Expand description
A TRON network address (0x41 prefix + 20-byte body).
Implementations§
Source§impl Address
impl Address
Sourcepub fn from_bytes(bytes: [u8; 21]) -> Result<Self, AddressError>
pub fn from_bytes(bytes: [u8; 21]) -> Result<Self, AddressError>
Construct from the full 21-byte representation, validating the prefix.
Sourcepub fn from_slice(slice: &[u8]) -> Result<Self, AddressError>
pub fn from_slice(slice: &[u8]) -> Result<Self, AddressError>
Construct from a 21-byte slice, validating length and prefix.
Sourcepub fn from_evm_bytes(evm: [u8; 20]) -> Self
pub fn from_evm_bytes(evm: [u8; 20]) -> Self
Construct from the 20-byte EVM-style body, prepending the 0x41 prefix.
Sourcepub fn from_public_key(key: &VerifyingKey) -> Self
pub fn from_public_key(key: &VerifyingKey) -> Self
Derive the address from a secp256k1 public key.
address = 0x41 || keccak256(uncompressed_pubkey[1..])[12..]
Sourcepub fn from_base58(s: &str) -> Result<Self, AddressError>
pub fn from_base58(s: &str) -> Result<Self, AddressError>
Parse a base58check (T...) address string.
Sourcepub fn from_hex(s: &str) -> Result<Self, AddressError>
pub fn from_hex(s: &str) -> Result<Self, AddressError>
Parse a hex address string (with or without 0x / 41 semantics is
preserved: the bytes must already include the 0x41 prefix).
Sourcepub fn as_bytes(&self) -> &[u8; 21]
pub fn as_bytes(&self) -> &[u8; 21]
The full 21-byte representation, including the 0x41 prefix.
Sourcepub fn as_evm_bytes(&self) -> &[u8; 20]
pub fn as_evm_bytes(&self) -> &[u8; 20]
The 20-byte EVM-style body (prefix stripped). Use this when bridging to
alloy / ABI encoding.
Trait Implementations§
impl Copy for Address
Source§impl<'de> Deserialize<'de> for Address
impl<'de> Deserialize<'de> for Address
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
impl Eq for Address
Source§impl FromStr for Address
impl FromStr for Address
Source§fn from_str(s: &str) -> Result<Self, Self::Err>
fn from_str(s: &str) -> Result<Self, Self::Err>
Accepts either a base58check (T...) or a hex (41... / 0x41...)
address. Hex is detected when every character is a hex digit and the
string is the right length for a 21-byte address.