Class EntityId
Identifies a Hedera Address, Token, File, Topics, or Contract, typically
in the native format of
shard.realm.num
, but can also hold a Key Alias or EVM Payer if such an Entity TransactionId type is required.
Implements
Inherited Members
Namespace: Hiero
Assembly: Hiero.dll
Syntax
[JsonConverter(typeof(EntityIdConverter))]
public sealed record EntityId : IEquatable<EntityId>
Constructors
| Edit this page View SourceEntityId(long, long, Endorsement)
Constructor creating a form of Entity TransactionId that represents a Key Alias.
Declaration
public EntityId(long shardNum, long realmNum, Endorsement keyAlias)
Parameters
| Type | Name | Description |
|---|---|---|
| long | shardNum | The shard number for this Entity ID. |
| long | realmNum | The realm number for this Entity ID. |
| Endorsement | keyAlias | The Ed25519 or ECDSA Secp 256K1 Endorsement this Entity TransactionId will encapsulate. |
EntityId(long, long, EvmAddress)
Constructor creating a form of Entity TransactionId that represents an EVM Address.
Declaration
public EntityId(long shardNum, long realmNum, EvmAddress evmAddress)
Parameters
| Type | Name | Description |
|---|---|---|
| long | shardNum | The shard number for this Entity ID. |
| long | realmNum | The realm number for this Entity ID. |
| EvmAddress | evmAddress | The EVM Address this Entity TransactionId will encapsulate. |
EntityId(long, long, long)
Public Constructor, an
EntityId
is immutable after creation.
Declaration
public EntityId(long shardNum, long realmNum, long accountNum)
Parameters
| Type | Name | Description |
|---|---|---|
| long | shardNum | Network Shard Number |
| long | realmNum | Network Realm Number |
| long | accountNum | Network Address Number |
Properties
| Edit this page View SourceAccountNum
Network Address Number for this Entity,
Declaration
public long AccountNum { get; }
Property Value
| Type | Description |
|---|---|
| long |
IsEvmAddress
Indicates if this Entity TransactionId contains an EVM Payer (EIP-1014) format.
Declaration
public bool IsEvmAddress { get; }
Property Value
| Type | Description |
|---|---|
| bool |
IsKeyAlias
Indicates if this Entity TransactionId contains a Key Alias format.
Declaration
public bool IsKeyAlias { get; }
Property Value
| Type | Description |
|---|---|
| bool |
IsShardRealmNum
Indicates if this Entity TransactionId contains a [shard.realm.num] native address.
Declaration
public bool IsShardRealmNum { get; }
Property Value
| Type | Description |
|---|---|
| bool |
None
A special designation of an Entity TransactionId that can't be created. It represents the absence of a valid Entity TransactionId. The network will interpret as "no account/file/topic/token/contract" when applied to change parameters. (typically the value null is interpreted as "make no change"). In this way, it is possible to remove a auto-renew account from a topic for example.
Declaration
public static EntityId None { get; }
Property Value
| Type | Description |
|---|---|
| EntityId |
RealmNum
Network Realm Number for this Entity
Declaration
public long RealmNum { get; }
Property Value
| Type | Description |
|---|---|
| long |
ShardNum
Network Shard Number for this Entity
Declaration
public long ShardNum { get; }
Property Value
| Type | Description |
|---|---|
| long |
Methods
| Edit this page View SourceCastToEvmAddress()
Casts this Entity ID into the Evm Payer format.
If this ID already represents an underlying Evm Payer,
that instance value will be returned, otherwise the
equivalent long-zero format of an EVM Payer will
be computed from shard.realm.num values, or an EOA 20-byte
address will be computed from the Key Alias if it
represents an ECDSA public key.
Declaration
public EvmAddress CastToEvmAddress()
Returns
| Type | Description |
|---|---|
| EvmAddress | An EVM Payer compatible for use with smart contracts. |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | If this Entity TransactionId represents a Key Alias form of an Entity ID, this will throw an exception, if the underlying key is not a single ECDSA public key. |
Equals(EntityId?)
Determines if this Entity TransactionId is equal to another Entity TransactionId.
Declaration
public bool Equals(EntityId? other)
Parameters
| Type | Name | Description |
|---|---|---|
| EntityId | other |
object to compare. |
Returns
| Type | Description |
|---|---|
| bool | True if these represent the same entity TransactionId, otherwise false. |
GetHashCode()
Equality implementation.
Declaration
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| int |
|
Overrides
| Edit this page View SourceToString()
Outputs a string representation of the Entity TransactionId
(
shard.realm.keyAlias
), Key Alias or Evm Payer.
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| string | String representation of this account identifier in its entityId, keyAlias or evmAddress format. |
Overrides
| Edit this page View SourceTryGetEvmAddress(out EvmAddress)
Attempts to retrieve the Evm Payer wrapped by this Entity TransactionId instance. Will return false if this Entity TransactionId does not hold an Evm Payer.
Declaration
public bool TryGetEvmAddress(out EvmAddress evmAddress)
Parameters
| Type | Name | Description |
|---|---|---|
| EvmAddress | evmAddress |
. |
Returns
| Type | Description |
|---|---|
| bool |
if the entityId holds an Evm Address, otherwise false. |
TryGetKeyAlias(out Endorsement)
Attempts to retrieve the Key Alias Endorsement wrapped by this Entity TransactionId instance. Will return false if this Entity TransactionId does not hold a Key Alias.
Declaration
public bool TryGetKeyAlias(out Endorsement keyAlias)
Parameters
| Type | Name | Description |
|---|---|---|
| Endorsement | keyAlias |
. |
Returns
| Type | Description |
|---|---|
| bool |
if the entityId holds a Key Alias, otherwise false. |
TryParseShardRealmNum(ReadOnlySpan<char>, out EntityId?)
Attempts to parse a span of characters (string) from in the [shard.realm.num] format to convert into a Hedera Entity TransactionId.
Declaration
public static bool TryParseShardRealmNum(ReadOnlySpan<char> value, out EntityId? entityId)
Parameters
| Type | Name | Description |
|---|---|---|
| ReadOnlySpan<char> | value | The sequence of characters in the form ([shard.realm.num]) of an Entity ID. |
| EntityId | entityId | The resulting Entity TransactionId if convertible, otherwise null. |
Returns
| Type | Description |
|---|---|
| bool | True if the Entity TransactionId could be converted and contains a valid value. |
TryParseShardRealmNum(string?, out EntityId?)
Attempts to parse a string as in the [shard.realm.num] format to convert into a Hedera Entity TransactionId.
Declaration
public static bool TryParseShardRealmNum(string? value, out EntityId? entityId)
Parameters
| Type | Name | Description |
|---|---|---|
| string | value | The string form ([shard.realm.num]) of an Entity ID. |
| EntityId | entityId | The resulting Entity TransactionId if convertible, otherwise null. |
Returns
| Type | Description |
|---|---|
| bool | True if the Entity TransactionId could be converted and contains a valid value. |