Struct hedera::ContractId
source · pub struct ContractId {
pub shard: u64,
pub realm: u64,
pub num: u64,
pub checksum: Option<Checksum>,
pub evm_address: Option<[u8; 20]>,
}
Expand description
A unique identifier for a smart contract on Hedera.
Fields§
§shard: u64
A non-negative number identifying the shard containing this contract instance.
realm: u64
A non-negative number identifying the realm within the shard containing this contract instance.
num: u64
A non-negative number identifying the entity within the realm containing this contract instance.
Note: Exactly one of evm_address
and num
must exist.
checksum: Option<Checksum>
A checksum if the contract ID was read from a user inputted string which inclueded a checksum
evm_address: Option<[u8; 20]>
EVM address identifying the entity within the realm containing this contract instance.
Note: Exactly one of evm_address
and num
must exist.
Implementations§
source§impl ContractId
impl ContractId
sourcepub const fn new(shard: u64, realm: u64, num: u64) -> Self
pub const fn new(shard: u64, realm: u64, num: u64) -> Self
Create a ContractId
from the given shard/realm/num
sourcepub fn from_evm_address_bytes(
shard: u64,
realm: u64,
evm_address: [u8; 20]
) -> Self
pub fn from_evm_address_bytes( shard: u64, realm: u64, evm_address: [u8; 20] ) -> Self
Create a ContractId
from a shard.realm.evm_address
set.
sourcepub fn from_evm_address(shard: u64, realm: u64, address: &str) -> Result<Self>
pub fn from_evm_address(shard: u64, realm: u64, address: &str) -> Result<Self>
Create a ContractId
from a shard.realm.evm_address
set.
§Errors
Error::BasicParse
if address
is invalid hex, or the wrong length.
sourcepub fn from_solidity_address(address: &str) -> Result<Self>
pub fn from_solidity_address(address: &str) -> Result<Self>
Create a ContractId
from a solidity address.
§Errors
Error::BasicParse
ifaddress
cannot be parsed as a solidity address.
sourcepub fn from_bytes(bytes: &[u8]) -> Result<Self>
pub fn from_bytes(bytes: &[u8]) -> Result<Self>
Create a new ContractId
from protobuf-encoded bytes
.
§Errors
Error::FromProtobuf
if decoding the bytes fails to produce a valid protobuf.Error::FromProtobuf
if decoding the protobuf fails.
sourcepub fn to_solidity_address(&self) -> Result<String>
pub fn to_solidity_address(&self) -> Result<String>
Convert self
into a solidity address
.
§Errors
Error::BasicParse
ifself.shard
is larger thanu32::MAX
.
sourcepub fn to_string_with_checksum(&self, client: &Client) -> Result<String, Error>
pub fn to_string_with_checksum(&self, client: &Client) -> Result<String, Error>
Convert self
to a string with a valid checksum.
§Errors
Error::CannotCreateChecksum
if self has anevm_address
.
sourcepub fn validate_checksum(&self, client: &Client) -> Result<(), Error>
pub fn validate_checksum(&self, client: &Client) -> Result<(), Error>
Validates self.checksum
(if it exists) for client
.
§Errors
Error::BadEntityId
if there is a checksum, and the checksum is not valid for the client’sledger_id
.
Trait Implementations§
source§impl Clone for ContractId
impl Clone for ContractId
source§fn clone(&self) -> ContractId
fn clone(&self) -> ContractId
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for ContractId
impl Debug for ContractId
source§impl Display for ContractId
impl Display for ContractId
source§impl From<ContractId> for Key
impl From<ContractId> for Key
source§fn from(id: ContractId) -> Self
fn from(id: ContractId) -> Self
source§impl From<EntityId> for ContractId
impl From<EntityId> for ContractId
source§impl From<u64> for ContractId
impl From<u64> for ContractId
source§impl FromStr for ContractId
impl FromStr for ContractId
source§impl Hash for ContractId
impl Hash for ContractId
source§impl PartialEq for ContractId
impl PartialEq for ContractId
source§fn eq(&self, other: &ContractId) -> bool
fn eq(&self, other: &ContractId) -> bool
self
and other
values to be equal, and is used
by ==
.impl Copy for ContractId
impl Eq for ContractId
impl StructuralPartialEq for ContractId
Auto Trait Implementations§
impl Freeze for ContractId
impl RefUnwindSafe for ContractId
impl Send for ContractId
impl Sync for ContractId
impl Unpin for ContractId
impl UnwindSafe for ContractId
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<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.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
key
and return true
if they are equal.source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request