Show / Hide Table of Contents

Class EvmAddress

Represents a 20-byte EVM Address for the Hedera Virtual Machine.

Inheritance
object
EvmAddress
Implements
IEquatable<EvmAddress>
ISpanFormattable
IFormattable
IUtf8SpanFormattable
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetType()
object.ReferenceEquals(object, object)
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 Source

EvmAddress(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.

| Edit this page View Source

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:

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.
Exceptions
Type Condition
ArgumentOutOfRangeException

when any of the inputs are out of range, such as the bytes not having a length of 20.

| Edit this page View Source

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:

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.
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 Source

Bytes

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>
| Edit this page View Source

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 Source

Equals(EvmAddress?)

Equality implementation

Declaration
public bool Equals(EvmAddress? other)
Parameters
Type Name Description
EvmAddress other
The other 
EvmAddress

object to compare.

Returns
Type Description
bool

True if the EVM address bytes are identical.

| Edit this page View Source

GetHashCode()

Equality implementation.

Declaration
public override int GetHashCode()
Returns
Type Description
int
A unique hash of the contents of this 
EvmAddress
object.  Only consistent within the current instance of 
the application process.
Overrides
object.GetHashCode()
| Edit this page View Source

ToString()

Outputs an EIP-55 Checksum Encoding of EvmAddress

Declaration
public override string ToString()
Returns
Type Description
string

String representation of this EVM Address

Overrides
object.ToString()
| Edit this page View Source

ToString(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

| Edit this page View Source

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 utf8Destination.

ReadOnlySpan<char> format

A span containing the characters that represent a standard or custom format string that defines the acceptable format for utf8Destination.

IFormatProvider provider

An optional object that supplies culture-specific formatting information for utf8Destination.

Returns
Type Description
bool

true if the formatting was successful; otherwise, false.

| Edit this page View Source

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 destination.

ReadOnlySpan<char> format

A span containing the characters that represent a standard or custom format string that defines the acceptable format for destination.

IFormatProvider provider

An optional object that supplies culture-specific formatting information for destination.

Returns
Type Description
bool

true if the formatting was successful; otherwise, false.

| Edit this page View Source

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.

| Edit this page View Source

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 Source

implicit 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
The EVM Address to wrap within an 
EntityId

.

Returns
Type Description
EntityId
| Edit this page View Source

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
| Edit this page View Source

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

Implements

IEquatable<T>
ISpanFormattable
IFormattable
IUtf8SpanFormattable
  • Edit this page
  • View Source
In this article
Back to top .NET Client Library for Hiero Network and Hedera Hashgraph