Struct IotaAddress
pub struct IotaAddress(/* 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§
§impl Address
impl Address
pub const LENGTH: usize = 32
pub const ZERO: Address
pub const MAX: Address
pub const STD: Address
pub const FRAMEWORK: Address
pub const SYSTEM: Address
pub const GENESIS_BRIDGE: Address
pub const STARDUST: Address
pub const SYSTEM_STATE: Address
pub const CLOCK: Address
pub const AUTHENTICATOR_STATE: Address
pub const RANDOMNESS_STATE: Address
pub const GENESIS_IOTA_BRIDGE: Address
pub const DENY_LIST: Address
pub const fn new(bytes: [u8; 32]) -> Address
pub const fn from_u16(suffix: u16) -> Address
pub const fn from_u16(suffix: u16) -> Address
Creates an Address from a u16 suffix by setting the last two bytes.
pub fn is_system_package(&self) -> bool
pub fn is_system_package(&self) -> bool
Checks if the address is one of the system package addresses. The system packages are:
- STD
- FRAMEWORK
- SYSTEM
- GENESIS_BRIDGE
- STARDUST
pub fn generate<R>(rng: R) -> Address
pub fn random() -> Address
pub const fn into_bytes(self) -> [u8; 32]
pub const fn into_bytes(self) -> [u8; 32]
Return the underlying byte array of a Address.
pub const fn bytes(&self) -> &[u8; 32]
pub const fn as_bytes(&self) -> &[u8] ⓘ
pub const fn from_object_id(object_id: ObjectId) -> Address
pub fn from_hex<T>(hex: T) -> Result<Address, AddressParseError>
pub fn from_hex<T>(hex: T) -> Result<Address, AddressParseError>
Parses an Address from a full-length hex string (64 hex characters),
with or without a 0x prefix. Will return an error if the string is not
exactly 64 hex characters long (excluding the 0x prefix).
pub fn from_prefixed_hex<T>(hex: T) -> Result<Address, AddressParseError>
pub fn from_prefixed_hex<T>(hex: T) -> Result<Address, AddressParseError>
Parses an Address from a full-length hex string (64 hex characters),
with a mandatory 0x prefix. Will return an error if the string is not
exactly 64 hex characters long (excluding the 0x prefix).
pub fn from_short_hex<T>(hex: T) -> Result<Address, AddressParseError>
pub fn from_short_hex<T>(hex: T) -> Result<Address, AddressParseError>
Parses an Address from a hex string, with or without a 0x prefix.
The string can be of variable length; if it’s shorter than 64 hex
characters, it will be left-padded with 0s.
pub fn from_prefixed_short_hex<T>(hex: T) -> Result<Address, AddressParseError>
pub fn from_prefixed_short_hex<T>(hex: T) -> Result<Address, AddressParseError>
Parses an Address from a hex string with a mandatory 0x prefix.
The string can be of variable length; if it’s shorter than 64 hex
characters, it will be left-padded with 0s.
pub fn to_hex(&self) -> String
pub fn to_hex(&self) -> String
Returns the string representation of this address in hex format with
0x prefix.
pub fn to_raw_hex(&self) -> String
pub fn to_raw_hex(&self) -> String
Returns the string representation of this address in hex format without
0x prefix.
pub fn to_short_hex(&self) -> String
pub fn to_short_hex(&self) -> String
Returns the shortest possible string representation of the address (i.e. with leading zeroes trimmed).
pub fn to_raw_short_hex(&self) -> String
pub fn to_raw_short_hex(&self) -> String
Returns the shortest possible string representation of the address (i.e.
with leading zeroes trimmed), without 0x prefix.
pub fn to_canonical_string(&self, with_prefix: bool) -> String
pub fn to_canonical_string(&self, with_prefix: bool) -> String
Returns the string representation of this address using the
canonical display, with or without a 0x prefix.
pub fn from_bytes<T>(bytes: T) -> Result<Address, AddressParseError>
pub const fn next_lexicographical(&self) -> Address
pub const fn next_lexicographical(&self) -> Address
Returns the next address in byte-increasing order.
pub const fn next_lexicographical_opt(&self) -> Option<Address>
pub const fn next_lexicographical_opt(&self) -> Option<Address>
Returns the next address in byte-increasing order, or None if the
result would overflow.
Trait Implementations§
§impl Arbitrary for Address
impl Arbitrary for Address
§type Parameters = ()
type Parameters = ()
arbitrary_with accepts for configuration
of the generated Strategy. Parameters must implement Default.§fn arbitrary_with(
args_shared: <Address as Arbitrary>::Parameters,
) -> <Address as Arbitrary>::Strategy
fn arbitrary_with( args_shared: <Address as Arbitrary>::Parameters, ) -> <Address as Arbitrary>::Strategy
§impl<'de> Deserialize<'de> for Address
impl<'de> Deserialize<'de> for Address
§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Address, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Address, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl From<&MultiSigPublicKey> for IotaAddress
impl From<&MultiSigPublicKey> for IotaAddress
Source§fn from(multisig_pk: &MultiSigPublicKey) -> Self
fn from(multisig_pk: &MultiSigPublicKey) -> Self
Derive a IotaAddress from [struct MultiSigPublicKey]. A MultiSig address
is defined as the 32-byte Blake2b hash of serializing the flag, the
threshold, concatenation of all n flag, public keys and
its weight. flag_MultiSig || threshold || flag_1 || pk_1 || weight_1 || ... || flag_n || pk_n || weight_n.
Source§impl From<&PublicKey> for IotaAddress
impl From<&PublicKey> for IotaAddress
Source§impl MoveTypeTagTrait for IotaAddress
impl MoveTypeTagTrait for IotaAddress
fn get_type_tag() -> TypeTag
§impl Ord for Address
impl Ord for Address
§impl PartialOrd for Address
impl PartialOrd for Address
§impl Serialize for Address
impl Serialize for Address
§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Source§impl TryFrom<&GenericSignature> for IotaAddress
impl TryFrom<&GenericSignature> for IotaAddress
Source§fn try_from(sig: &GenericSignature) -> IotaResult<Self>
fn try_from(sig: &GenericSignature) -> IotaResult<Self>
Derive a IotaAddress from a serialized signature in IOTA GenericSignature.
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§
§impl<U> As for U
impl<U> As for U
§fn as_<T>(self) -> Twhere
T: CastFrom<U>,
fn as_<T>(self) -> Twhere
T: CastFrom<U>,
self to type T. The semantics of numeric casting with the as operator are followed, so <T as As>::as_::<U> can be used in the same way as T as U for numeric conversions. Read more§impl<A, T> AsBits<T> for A
impl<A, T> AsBits<T> for A
§impl<T, U> AsByteSlice<T> for U
impl<T, U> AsByteSlice<T> for U
fn as_byte_slice(&self) -> &[u8] ⓘ
§impl<U> AsSliceOf for U
impl<U> AsSliceOf for U
fn as_slice_of<T>(&self) -> Result<&[T], Error>where
T: FromByteSlice,
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
§impl<T> Base32Len for T
impl<T> Base32Len for T
§fn base32_len(&self) -> usize
fn base32_len(&self) -> usize
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,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<T> Conv for T
impl<T> Conv for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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 more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a Request§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.§impl<T> ToBase32 for T
impl<T> ToBase32 for T
Source§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)§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.