Class EvmHash
Represents a 32-byte EVM hash, such as a keccak256 transaction hash or block hash returned by the Mirror Node REST API.
Implements
Inherited Members
Namespace: Hiero
Assembly: Hiero.dll
Syntax
[JsonConverter(typeof(EvmHashConverter))]
public sealed record EvmHash : IEquatable<EvmHash>
Remarks
This is a value-type wrapper that distinguishes an EVM-style
32-byte hash from arbitrary ReadOnlyMemory<byte> payloads
at the type level. Use it for transaction hashes, block hashes,
and log topic values where the wire representation is a
32-byte keccak output. Hedera-native hashes (e.g., SHA-384
record-file hashes) are not 32 bytes and should not be represented
with this type.
Constructors
| Edit this page View SourceEvmHash(ReadOnlyMemory<byte>)
Public Constructor, an EvmHash is immutable after
construction.
Declaration
public EvmHash(ReadOnlyMemory<byte> bytes)
Parameters
| Type | Name | Description |
|---|---|---|
| ReadOnlyMemory<byte> | bytes | The 32 bytes of the hash. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | When the length of |
EvmHash(ReadOnlySpan<byte>)
Public Constructor, an EvmHash is immutable after
construction.
Declaration
public EvmHash(ReadOnlySpan<byte> bytes)
Parameters
| Type | Name | Description |
|---|---|---|
| ReadOnlySpan<byte> | bytes | The 32 bytes of the hash. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | When the length of |
Properties
| Edit this page View SourceBytes
The 32 bytes of the hash.
Declaration
public ReadOnlySpan<byte> Bytes { get; }
Property Value
| Type | Description |
|---|---|
| ReadOnlySpan<byte> |
None
The zero hash (32 bytes of 0x00). Used as a sentinel for "no hash"; distinguishable from a valid hash because a real keccak256 output of all zeros is cryptographically improbable.
Declaration
public static EvmHash None { get; }
Property Value
| Type | Description |
|---|---|
| EvmHash |
Methods
| Edit this page View SourceEquals(EvmHash?)
Equality implementation.
Declaration
public bool Equals(EvmHash? other)
Parameters
| Type | Name | Description |
|---|---|---|
| EvmHash | other | The other |
Returns
| Type | Description |
|---|---|
| bool | True if the hash bytes are identical. |
GetHashCode()
Equality implementation.
Declaration
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| int | A unique hash of the contents of this |
Overrides
| Edit this page View SourceToString()
Outputs the hash as a 0x-prefixed 64-character
lowercase hex string.
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| string |
Overrides
| Edit this page View SourceTryParse(ReadOnlySpan<char>, out EvmHash?)
Tries to parse a string value into an EvmHash.
Declaration
public static bool TryParse(ReadOnlySpan<char> value, out EvmHash? hash)
Parameters
| Type | Name | Description |
|---|---|---|
| ReadOnlySpan<char> | value | The string representation of the hash. May optionally start
with |
| EvmHash | hash | Contains the |
Returns
| Type | Description |
|---|---|
| bool | True if parsing was successful, false if not. |
TryParse(string?, out EvmHash?)
Tries to parse a string value into an EvmHash.
Declaration
public static bool TryParse(string? value, out EvmHash? hash)
Parameters
| Type | Name | Description |
|---|---|---|
| string | value | The string representation of the hash. May optionally start
with |
| EvmHash | hash | Contains the |
Returns
| Type | Description |
|---|---|
| bool | True if parsing was successful, false if not. |
Operators
| Edit this page View Sourceimplicit operator EvmHash(ReadOnlyMemory<byte>)
Implicit operator for converting a read-only memory of bytes
into an EvmHash.
Declaration
public static implicit operator EvmHash(ReadOnlyMemory<byte> bytes)
Parameters
| Type | Name | Description |
|---|---|---|
| ReadOnlyMemory<byte> | bytes | The 32 bytes of the hash. |
Returns
| Type | Description |
|---|---|
| EvmHash |
implicit operator EvmHash(ReadOnlySpan<byte>)
Implicit operator for converting a read-only span of bytes
into an EvmHash.
Declaration
public static implicit operator EvmHash(ReadOnlySpan<byte> bytes)
Parameters
| Type | Name | Description |
|---|---|---|
| ReadOnlySpan<byte> | bytes | The 32 bytes of the hash. |
Returns
| Type | Description |
|---|---|
| EvmHash |