Class AccountAddress
- Namespace
- Concordium.Sdk.Types
- Assembly
- Concordium.Sdk.dll
Represents an account address.
The address of an account is a 32-byte value which uniquely identifies the account.
public sealed record AccountAddress : IEquatable<AccountAddress>, IAddress, IAccountIdentifier
- Inheritance
-
AccountAddress
- Implements
- Inherited Members
Fields
BytesLength
The serialized length of the account address.
public const uint BytesLength = 32
Field Value
Methods
AsSpan()
Returns a read only span of underlying byte array.
public ReadOnlySpan<byte> AsSpan()
Returns
CreateAliasAddress(byte, byte, byte)
Gets a alias of this account address with the given input bytes.
The first 29 bytes of an address identifies a unique account with the remaining 3 bytes representing aliases of that account
public AccountAddress CreateAliasAddress(byte byte1, byte byte2, byte byte3)
Parameters
Returns
- AccountAddress
Alias of the account address with the given bytes.
Equals(AccountAddress?)
Determines whether one AccountAddress is equal to a second AccountAddress.
public bool Equals(AccountAddress? other)
Parameters
other
AccountAddress
Returns
Remarks
This does not consider two distinct aliases to the same account as equal.
From(byte[])
Creates an instance from a length-32 byte array representing the address (without the version byte prepended).
public static AccountAddress From(byte[] addressAsBytes)
Parameters
addressAsBytes
byte[]The address as a length-32 byte array, i.e. without the version byte prepended.
Returns
Exceptions
- ArgumentException
The input is not a length-32 byte array.
From(string)
Initializes a new instance of the AccountAddress class.
public static AccountAddress From(string addressAsBase58String)
Parameters
addressAsBase58String
stringThe address represented as a length-50 base58 encoded string.
Returns
Exceptions
- ArgumentException
The input is not a length-50 base58 encoded string.
GetBaseAddress()
Returns base address which is the first 29 bytes of an address.
public AccountAddress GetBaseAddress()
Returns
GetHashCode()
Get hash code for the AccountAddress.
public override int GetHashCode()
Returns
GetNthAlias(uint)
Gets the n
th alias of this account address.
The first 29 bytes of an address identifies a unique account with the
remaining 3 bytes representing aliases of that account. An alias can thus
be thought of as an unsigned integer whose value is between 0
and
2^24-1
. We refer to the address where the last three bytes corresponds
to the value n
in big endian format as the n
th alias of the account.
public AccountAddress GetNthAlias(uint n)
Parameters
n
uintAn unsigned integer representing the
n
th alias.
Returns
- AccountAddress
A new account address which is the
n
th alias of the account.
Exceptions
- ArgumentOutOfRangeException
n
is larger than2^24-1
.
IsAliasOf(AccountAddress)
Check whether the account address is an alias of another.
Two addresses are aliases if they identify the same account. This is defined to be when the addresses agree on the first 29 bytes.
public bool IsAliasOf(AccountAddress other)
Parameters
other
AccountAddressthe account address as base58 encoded string.
Returns
IsValid(string?)
Checks if passed string is a base58 encoded address.
public static bool IsValid(string? addressAsBase58String)
Parameters
addressAsBase58String
stringThe account address as base58 encoded string.
Returns
- bool
true
if the input could be decoded as a base58 encoded address andfalse
otherwise.
ToAccountIdentifierInput()
Converts the account address to a corresponding AccountIdentifierInput
This can be used as the input for class methods of RawClient.
public AccountIdentifierInput ToAccountIdentifierInput()
Returns
ToBytes()
Copies the address to a byte array which has the version byte preprended.
public byte[] ToBytes()
Returns
- byte[]
ToProto()
Converts the account address to its corresponding protocol buffer message instance.
This can be used as the input for class methods of RawClient.
public AccountAddress ToProto()
Returns
ToString()
Get the address represented as a base58 encoded string.
public override string ToString()
Returns
TryDeserial(ReadOnlySpan<byte>, out (AccountAddress? AccountAddress, string? Error))
Create an account address from a byte array.
public static bool TryDeserial(ReadOnlySpan<byte> bytes, out (AccountAddress? AccountAddress, string? Error) output)
Parameters
bytes
ReadOnlySpan<byte>The serialized account address.
output
(AccountAddress AccountAddress, string Error)Where to write the result of the operation.
Returns
TryParse(string, out AccountAddress?)
Try parse account address from a base 58 encoded string.
public static bool TryParse(string base58EncodedAddress, out AccountAddress? address)
Parameters
base58EncodedAddress
stringBase 58 encoded string of address
address
AccountAddressIf parsed returns Account Address.
Returns
- bool
True if Account Address could be parsed.