pub struct Address(/* private fields */);
Expand description
Unique identifier for an Account on the Sui blockchain.
An Address
is a 32-byte pseudonymous identifier used to uniquely identify an account and
asset-ownership on the Sui blockchain. Often, human-readable addresses are encoded in
hexadecimal with a 0x
prefix. For example, this is a valid Sui address:
0x02a212de6a9dfa3a69e22387acfbafbb1a9e591bd9d636e7895dcfc8de05f331
.
use sui_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. For each authenticator, this
domain-separator is the single byte-value of its SignatureScheme
flag. E.g. hash(signature schema flag || authenticator bytes)
.
Each authenticator includes a convince 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
ObjectId
s and Address
es share the same 32-byte addressable space but are derived
leveraging different domain-separator values to ensure, cryptographically, that there won’t be
any overlap, e.g. there can’t be a valid Object
whose 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 = 32OCTET
Implementations§
Source§impl Address
impl Address
pub const LENGTH: usize = 32usize
pub const ZERO: Self = _
pub const TWO: Self = _
pub const THREE: 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 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§
§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 moreSource§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> 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
)