pub struct Address(/* private fields */);Expand description
Unique identifier for an Account on the IOTA blockchain.
An Address is a 32-byte pseudonymous identifier used to uniquely identify
an account and asset-ownership on the IOTA blockchain. Often, human-readable
addresses are encoded in hexadecimal with a 0x prefix. For example, this
is a valid IOTA address:
0x02a212de6a9dfa3a69e22387acfbafbb1a9e591bd9d636e7895dcfc8de05f331.
use iota_sdk_types::Address;
let hex = "0x02a212de6a9dfa3a69e22387acfbafbb1a9e591bd9d636e7895dcfc8de05f331";
let address = Address::from_hex(hex).unwrap();
println!("Address: {}", address);
assert_eq!(hex, address.to_string());§Deriving an Address
Addresses are cryptographically derived from a number of user account
authenticators, the simplest of which is an
Ed25519PublicKey.
Deriving an address consists of the Blake2b256 hash of the sequence of bytes
of its corresponding authenticator, prefixed with a domain-separator (except
ed25519, for compatibility reasons). For each other authenticator, this
domain-separator is the single byte-value of its
SignatureScheme flag. E.g. hash(signature schema flag || authenticator bytes).
Each authenticator has a method for deriving its Address as well as
documentation for the specifics of how the derivation is done. See
Ed25519PublicKey::derive_address for an example.
§Relationship to ObjectIds
ObjectIds and Addresses share the same 32-byte addressable space but
are derived leveraging different domain-separator values to ensure that,
cryptographically, there won’t be any overlap, e.g. there can’t be a
valid Object who’s ObjectId is equal to that of the Address of a user
account.
§BCS
An Address’s BCS serialized form is defined by the following:
address = 32OCTETImplementations§
Source§impl Address
impl Address
pub const LENGTH: usize = 32usize
pub const ZERO: Self
pub const STD_LIB: Self
pub const FRAMEWORK: Self
pub const SYSTEM: Self
pub const fn new(bytes: [u8; 32]) -> Self
pub fn generate<R>(rng: R) -> Self
rand only.Sourcepub const fn into_inner(self) -> [u8; 32]
pub const fn into_inner(self) -> [u8; 32]
Return the underlying byte array of a Address.
pub const fn inner(&self) -> &[u8; 32]
pub const fn as_bytes(&self) -> &[u8] ⓘ
pub fn from_hex<T: AsRef<[u8]>>(hex: T) -> Result<Self, AddressParseError>
pub fn to_hex(&self) -> String
pub fn from_bytes<T: AsRef<[u8]>>(bytes: T) -> Result<Self, AddressParseError>
Trait Implementations§
Source§impl Arbitrary for Address
impl Arbitrary for Address
Source§type Parameters = ()
type Parameters = ()
arbitrary_with accepts for configuration
of the generated Strategy. Parameters must implement Default.Source§type Strategy = BoxedStrategy<Address>
type Strategy = BoxedStrategy<Address>
Strategy used to generate values of type Self.Source§fn arbitrary_with(args: <Self as Arbitrary>::Parameters) -> Self::Strategy
fn arbitrary_with(args: <Self as Arbitrary>::Parameters) -> Self::Strategy
Source§impl<'de> Deserialize<'de> for Address
impl<'de> Deserialize<'de> for Address
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl JsonSchema for Address
Available on crate feature schemars only.
impl JsonSchema for Address
schemars only.Source§fn schema_name() -> String
fn schema_name() -> String
Source§fn json_schema(_: &mut SchemaGenerator) -> Schema
fn json_schema(_: &mut SchemaGenerator) -> Schema
Source§fn is_referenceable() -> bool
fn is_referenceable() -> bool
$ref keyword. Read moreSource§impl Ord for Address
impl Ord for Address
Source§impl PartialOrd for Address
impl PartialOrd for Address
impl Copy for Address
impl Eq for Address
impl StructuralPartialEq for Address
Auto Trait Implementations§
impl Freeze for Address
impl RefUnwindSafe for Address
impl Send for Address
impl Sync for Address
impl Unpin for Address
impl UnwindSafe for Address
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> ToHex for T
impl<T> ToHex for T
Source§fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
self into the result. Lower case
letters are used (e.g. f9b4ca)Source§fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
self into the result. Upper case
letters are used (e.g. F9B4CA)