Class EntityId
Identifies a Hedera Address, Token, File, Topic, or Contract, typically
in the native format of
shard.realm.num
, but can also hold a Key Alias or EVM Address if such an Entity Id type is required.
Inherited Members
Namespace: Hiero
Assembly: Hiero.dll
Syntax
[JsonConverter(typeof(EntityIdConverter))]
public sealed record EntityId : IEquatable<EntityId>, ISpanFormattable, IFormattable, IUtf8SpanFormattable
Constructors
| Edit this page View SourceEntityId(long, long, Endorsement)
Constructor creating a form of Entity Id 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 Id will encapsulate. |
EntityId(long, long, EvmAddress)
Constructor creating a form of Entity Id 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 Id 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 Id contains an EVM Address (EIP-1014) format.
Declaration
public bool IsEvmAddress { get; }
Property Value
| Type | Description |
|---|---|
| bool |
IsKeyAlias
Indicates if this Entity Id contains a Key Alias format.
Declaration
public bool IsKeyAlias { get; }
Property Value
| Type | Description |
|---|---|
| bool |
IsShardRealmNum
Indicates if this Entity Id contains a [shard.realm.num] native address.
Declaration
public bool IsShardRealmNum { get; }
Property Value
| Type | Description |
|---|---|
| bool |
None
A special designation of an Entity Id that can't be created. It represents the absence of a valid Entity Id. 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 Address format. If this ID already represents an underlying EVM Address, that instance value will be returned, otherwise the equivalent long-zero format of an EVM Address 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 Address compatible for use with smart contracts. |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | If this Entity Id 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 Id is equal to another Entity Id.
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, 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 Id
(
shard.realm.num
), Key Alias or EVM Address.
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 SourceToString(string?, IFormatProvider?)
Formats the value of the current instance using the specified format.
Declaration
public string ToString(string? format, IFormatProvider? formatProvider)
Parameters
| Type | Name | Description |
|---|---|---|
| string | format | The format to use. -or- A null reference ( |
| IFormatProvider | formatProvider | The provider to use to format the value. -or- A null reference ( |
Returns
| Type | Description |
|---|---|
| string | The value of the current instance in the specified format. |
TryFormat(Span<byte>, out int, ReadOnlySpan<char>, IFormatProvider?)
Tries to format the value of the current instance as UTF-8 into the provided span of bytes.
Declaration
public bool TryFormat(Span<byte> utf8Destination, out int bytesWritten, ReadOnlySpan<char> format, IFormatProvider? provider)
Parameters
| Type | Name | Description |
|---|---|---|
| Span<byte> | utf8Destination | The span in which to write this instance's value formatted as a span of bytes. |
| int | bytesWritten | When this method returns, contains the number of bytes that were written in |
| ReadOnlySpan<char> | format | A span containing the characters that represent a standard or custom format string that defines the acceptable format for |
| IFormatProvider | provider | An optional object that supplies culture-specific formatting information for |
Returns
| Type | Description |
|---|---|
| bool |
TryFormat(Span<char>, out int, ReadOnlySpan<char>, IFormatProvider?)
Tries to format the value of the current instance into the provided span of characters.
Declaration
public bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format, IFormatProvider? provider)
Parameters
| Type | Name | Description |
|---|---|---|
| Span<char> | destination | The span in which to write this instance's value formatted as a span of characters. |
| int | charsWritten | When this method returns, contains the number of characters that were written in |
| ReadOnlySpan<char> | format | A span containing the characters that represent a standard or custom format string that defines the acceptable format for |
| IFormatProvider | provider | An optional object that supplies culture-specific formatting information for |
Returns
| Type | Description |
|---|---|
| bool |
TryGetEvmAddress(out EvmAddress)
Attempts to retrieve the EVM Address wrapped by this Entity Id instance. Will return false if this Entity Id does not hold an EVM Address.
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 Id instance. Will return false if this Entity Id 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 Id.
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 Id if convertible, otherwise null. |
Returns
| Type | Description |
|---|---|
| bool | True if the Entity Id 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 Id.
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 Id if convertible, otherwise null. |
Returns
| Type | Description |
|---|---|
| bool | True if the Entity Id could be converted and contains a valid value. |