Class EvmAddress
Represents a 20-byte EVM Address for the Hedera Virtual Machine.
Inherited Members
Namespace: Hiero
Assembly: Hiero.dll
Syntax
[JsonConverter(typeof(EvmAddressConverter))]
public sealed record EvmAddress : IEquatable<EvmAddress>, ISpanFormattable, IFormattable, IUtf8SpanFormattable
Remarks
An address may be a long-zero encoding of a shard.realm.num
id, or an EIP-1014 (CREATE2) / public-key-derived address with no
simple relation to a native id. ToString() renders the
address as a 0x-prefixed, EIP-55 mixed-case checksum string.
Constructors
| Edit this page View SourceEvmAddress(Endorsement)
Constructor from ECDSASecp256K1 Endorsement, converts the public key into the appropriate 20-byte public key hash.
Declaration
public EvmAddress(Endorsement endorsement)
Parameters
| Type | Name | Description |
|---|---|---|
| Endorsement | endorsement | An ECDSASecp256K1 public key. The EvmAddress will automatically convert the public key into the matching 20-byte eth hash. |
EvmAddress(ReadOnlyMemory<byte>)
Public Constructor, a
EvmAddress
is immutable after construction.
Declaration
public EvmAddress(ReadOnlyMemory<byte> bytes)
Parameters
| Type | Name | Description |
|---|---|---|
| ReadOnlyMemory<byte> | bytes | The bytes representing the address, if originates from a long-zero address (shard.realm.num) form the encoding follows:
|
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | when any of the inputs are out of range, such as the bytes not having a length of 20. |
EvmAddress(ReadOnlySpan<byte>)
Public Constructor, a
EvmAddress
is immutable after construction.
Declaration
public EvmAddress(ReadOnlySpan<byte> bytes)
Parameters
| Type | Name | Description |
|---|---|---|
| ReadOnlySpan<byte> | bytes | The bytes representing the address, if originates from a long-zero address (shard.realm.num) form the encoding follows:
|
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | when any of the inputs are out of range, such as the bytes not having a length of 20. |
Properties
| Edit this page View SourceBytes
The 20-byte EVM Address of the contract.
Every contract has an EVM Address determined by its
shard.realm.num
id.
This Address is as follows:
The first 4 bytes are the big-endian representation of the shard.
The next 8 bytes are the big-endian representation of the realm.
The final 8 bytes are the big-endian representation of the number.
In the above format, the shard and realm should match the encoded values.
Contracts created via CREATE2 have an <b>additional, primary address</b> that is
derived from the<a href="https://eips.ethereum.org/EIPS/eip-1014"> EIP-1014</a>
specification, and does not have a simple relation to a<tt> shard.realm.num</tt> id.
(therefore shard and realm values do not match the encoded bytes)
Declaration
public ReadOnlySpan<byte> Bytes { get; }
Property Value
| Type | Description |
|---|---|
| ReadOnlySpan<byte> |
None
A special designation of an alias that can't be created. It represents the absence of a valid alias. 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.
Declaration
public static EvmAddress None { get; }
Property Value
| Type | Description |
|---|---|
| EvmAddress |
Methods
| Edit this page View SourceEquals(EvmAddress?)
Equality implementation
Declaration
public bool Equals(EvmAddress? other)
Parameters
| Type | Name | Description |
|---|---|---|
| EvmAddress | other |
object to compare. |
Returns
| Type | Description |
|---|---|
| bool | True if the EVM address bytes are identical. |
GetHashCode()
Equality implementation.
Declaration
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| int |
|
Overrides
| Edit this page View SourceToString()
Outputs an EIP-55 Checksum Encoding of EvmAddress
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| string | String representation of this EVM Address |
Overrides
| Edit this page View SourceToString(string?, IFormatProvider?)
Outputs an EIP-55 Checksum Encoding of EvmAddress
Declaration
public string ToString(string? format, IFormatProvider? formatProvider)
Parameters
| Type | Name | Description |
|---|---|---|
| string | format | |
| IFormatProvider | formatProvider |
Returns
| Type | Description |
|---|---|
| string | String representation of this EVM Address |
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 |
TryParse(ReadOnlySpan<char>, out EvmAddress?)
Tries to parse a string value into an EVM Address.
Declaration
public static bool TryParse(ReadOnlySpan<char> value, out EvmAddress? evmAddress)
Parameters
| Type | Name | Description |
|---|---|---|
| ReadOnlySpan<char> | value | The string representation of the EVM address, may start with '0x' |
| EvmAddress | evmAddress | Contains the EVM Address if parsing is successful |
Returns
| Type | Description |
|---|---|
| bool | True if parsing was successful, false if not. |
TryParse(string?, out EvmAddress?)
Tries to parse a string value into an EVM Address.
Declaration
public static bool TryParse(string? value, out EvmAddress? evmAddress)
Parameters
| Type | Name | Description |
|---|---|---|
| string | value | The string representation of the EVM address, may start with '0x' |
| EvmAddress | evmAddress | Contains the EVM Address if parsing is successful |
Returns
| Type | Description |
|---|---|
| bool | True if parsing was successful, false if not. |
Operators
| Edit this page View Sourceimplicit operator EntityId(EvmAddress)
Implicitly wraps an EVM Address within an
EntityId
construct.
Declaration
public static implicit operator EntityId(EvmAddress evmAddress)
Parameters
| Type | Name | Description |
|---|---|---|
| EvmAddress | evmAddress |
. |
Returns
| Type | Description |
|---|---|
| EntityId |
implicit operator EvmAddress(ReadOnlyMemory<byte>)
Implicit operator for converting a readonly memory array into an EVM Address.
Declaration
public static implicit operator EvmAddress(ReadOnlyMemory<byte> bytes)
Parameters
| Type | Name | Description |
|---|---|---|
| ReadOnlyMemory<byte> | bytes | The bytes representing the EVM Address. |
Returns
| Type | Description |
|---|---|
| EvmAddress |
implicit operator EvmAddress(ReadOnlySpan<byte>)
Implicit operator for converting a readonly span of bytes into an EVM Address.
Declaration
public static implicit operator EvmAddress(ReadOnlySpan<byte> bytes)
Parameters
| Type | Name | Description |
|---|---|---|
| ReadOnlySpan<byte> | bytes | The bytes representing the EVM Address. |
Returns
| Type | Description |
|---|---|
| EvmAddress |