#[repr(u8)]pub enum DeterministicAccountStateInit {
V1(DeterministicAccountStateInitV1),
}Expand description
State initialization data for NEP-616 deterministic accounts.
The account ID is derived from: "0s" + hex(keccak256(borsh(state_init))[12..32])
Variants§
V1(DeterministicAccountStateInitV1)
Version 1 of the state init format.
Implementations§
Source§impl DeterministicAccountStateInit
impl DeterministicAccountStateInit
Sourcepub fn derive_account_id(&self) -> AccountId
pub fn derive_account_id(&self) -> AccountId
Derive the deterministic account ID from this state init.
The account ID is derived as: "0s" + hex(keccak256(borsh(state_init))[12..32])
This produces a 42-character account ID that:
- Starts with “0s” prefix (distinguishes from Ethereum implicit accounts “0x”)
- Followed by 40 hex characters (20 bytes from the keccak256 hash)
§Example
use near_kit::types::{DeterministicAccountStateInit, DeterministicAccountStateInitV1, GlobalContractIdentifier, CryptoHash};
use std::collections::BTreeMap;
let state_init = DeterministicAccountStateInit::V1(DeterministicAccountStateInitV1 {
code: GlobalContractIdentifier::CodeHash(CryptoHash::default()),
data: BTreeMap::new(),
});
let account_id = state_init.derive_account_id();
assert!(account_id.as_str().starts_with("0s"));
assert_eq!(account_id.as_str().len(), 42);Trait Implementations§
Source§impl BorshDeserialize for DeterministicAccountStateInit
impl BorshDeserialize for DeterministicAccountStateInit
fn deserialize_reader<__R: Read>(reader: &mut __R) -> Result<Self, Error>
Source§fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>
fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>
Deserializes this instance from a given slice of bytes.
Updates the buffer to point at the remaining bytes.
Source§fn try_from_slice(v: &[u8]) -> Result<Self, Error>
fn try_from_slice(v: &[u8]) -> Result<Self, Error>
Deserialize this instance from a slice of bytes.
fn try_from_reader<R>(reader: &mut R) -> Result<Self, Error>where
R: Read,
Source§impl Clone for DeterministicAccountStateInit
impl Clone for DeterministicAccountStateInit
Source§fn clone(&self) -> DeterministicAccountStateInit
fn clone(&self) -> DeterministicAccountStateInit
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl PartialEq for DeterministicAccountStateInit
impl PartialEq for DeterministicAccountStateInit
Source§fn eq(&self, other: &DeterministicAccountStateInit) -> bool
fn eq(&self, other: &DeterministicAccountStateInit) -> bool
Tests for
self and other values to be equal, and is used by ==.impl Eq for DeterministicAccountStateInit
impl StructuralPartialEq for DeterministicAccountStateInit
Auto Trait Implementations§
impl Freeze for DeterministicAccountStateInit
impl RefUnwindSafe for DeterministicAccountStateInit
impl Send for DeterministicAccountStateInit
impl Sync for DeterministicAccountStateInit
impl Unpin for DeterministicAccountStateInit
impl UnsafeUnpin for DeterministicAccountStateInit
impl UnwindSafe for DeterministicAccountStateInit
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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
Compare self to
key and return true if they are equal.