Show / Hide Table of Contents

Struct Address

An identifier of 20 bytes (or 40 letters in hexadecimal, commonly with a prefix 0x) that refers to a unique account.

It is derived from the corresponding PublicKey of an account, but as a derivation loses information, it is always unidirectional.

The address derivation from a public key is as follows:

  1. Calculates the Keccak-256, which is a previous form of SHA-3 before NIST standardized it and does not follow FIPS-202, of the corresponding PublicKey.
  2. Takes only the last 20 bytes of the calculated Keccak-256 hash.
  3. When the address needs to be shown to end users, displays these 20 bytes in hexadecimal, with a prefix 0x.

Since the scheme of the address derivation and the PrivateKey/PublicKey is the same to Ethereum, Ethereum addresses can be used by Libplanet-backed games/apps too.

Implements
System.Runtime.Serialization.ISerializable
IEquatable<Address>
IComparable<Address>
IComparable
Bencodex.IBencodable
Inherited Members
Object.Equals(Object, Object)
System.Object.GetType()
Object.ReferenceEquals(Object, Object)
Namespace: Libplanet.Crypto
Assembly: Libplanet.Crypto.dll
Syntax
[Serializable]
[TypeConverter(typeof(AddressTypeConverter))]
[JsonConverter(typeof(AddressJsonConverter))]
public readonly struct Address : ISerializable, IEquatable<Address>, IComparable<Address>, IComparable, IBencodable
Remarks

Every Address value is immutable.

Constructors

| Improve this Doc View Source

Address(IValue)

Creates an Address instance from given bencoded.

Declaration
public Address(IValue bencoded)
Parameters
Type Name Description
Bencodex.Types.IValue bencoded

A Bencodex Bencodex.Types.Binary of 20 System.Bytes which represents an Address.

Remarks

Every Address value is immutable.

Exceptions
Type Condition
ArgumentException

Thrown when given bencoded is not of type Bencodex.Types.Binary.

See Also
Address(in ImmutableArray<Byte>)
| Improve this Doc View Source

Address(PublicKey)

Derives the corresponding Address from a PublicKey.

Note that there is an equivalent extension method , which enables a code like publicKey.Address instead of new Address(publicKey), for convenience.

Declaration
public Address(PublicKey publicKey)
Parameters
Type Name Description
PublicKey publicKey

A PublicKey to derive the corresponding Address from.

Remarks

Every Address value is immutable.

See Also
PublicKey
| Improve this Doc View Source

Address(Byte[])

Creates an Address instance from the given System.Byte array (i.e., address).

Declaration
public Address(byte[] address)
Parameters
Type Name Description
System.Byte[] address

An array of 20 System.Bytes which represents an Address.

Remarks

A valid System.Byte array which represents an Address can be gotten using ToByteArray() method.

Exceptions
Type Condition
ArgumentException

Thrown when the given address array did not lengthen 20 bytes.

See Also
ToByteArray()
| Improve this Doc View Source

Address(in ImmutableArray<Byte>)

Creates an Address instance from the given immutable System.Byte array (i.e., address).

Declaration
public Address(in ImmutableArray<byte> address)
Parameters
Type Name Description
System.Collections.Immutable.ImmutableArray<System.Byte> address

An immutable array of 20 System.Bytes which represents an Address.

Remarks

A valid System.Byte array which represents an Address can be gotten using ToByteArray() method.

Exceptions
Type Condition
ArgumentException

Thrown when the given address array did not lengthen 20 bytes.

See Also
ByteArray
| Improve this Doc View Source

Address(String)

Derives the corresponding Address from a hexadecimal address string.

Declaration
public Address(string hex)
Parameters
Type Name Description
String hex

A 40 characters or included 0x prefix hexadecimal address string to derive the corresponding Address from. The string should be all lower-case or mixed-case which follows EIP 55.

Remarks

Every Address value is immutable.

Exceptions
Type Condition
ArgumentException

Thrown when given hex is neither 40 chars long nor 42 chars long with 0x prefix.

ArgumentException

Thrown when given hex is mixed-case and the checksum is invalid.

ArgumentException

Thrown when given hex does not consist of ASCII characters.

See Also
PublicKey

Fields

| Improve this Doc View Source

Size

The System.Bytes size that each Address takes.

It is 20 System.Bytes.

Declaration
public const int Size = 20
Field Value
Type Description
Int32
Remarks

Every Address value is immutable.

See Also
PublicKey

Properties

| Improve this Doc View Source

Bencoded

An identifier of 20 bytes (or 40 letters in hexadecimal, commonly with a prefix 0x) that refers to a unique account.

It is derived from the corresponding PublicKey of an account, but as a derivation loses information, it is always unidirectional.

The address derivation from a public key is as follows:

  1. Calculates the Keccak-256, which is a previous form of SHA-3 before NIST standardized it and does not follow FIPS-202, of the corresponding PublicKey.
  2. Takes only the last 20 bytes of the calculated Keccak-256 hash.
  3. When the address needs to be shown to end users, displays these 20 bytes in hexadecimal, with a prefix 0x.

Since the scheme of the address derivation and the PrivateKey/PublicKey is the same to Ethereum, Ethereum addresses can be used by Libplanet-backed games/apps too.

Declaration
public readonly IValue Bencoded { get; }
Property Value
Type Description
Bencodex.Types.IValue
Remarks

Every Address value is immutable.

See Also
PublicKey
| Improve this Doc View Source

ByteArray

An immutable array of 20 System.Bytes that represent this Address.

Declaration
public readonly ImmutableArray<byte> ByteArray { get; }
Property Value
Type Description
System.Collections.Immutable.ImmutableArray<System.Byte>
Remarks

This is immutable. For a mutable array, call ToByteArray() method.

See Also
ToByteArray()

Methods

| Improve this Doc View Source

CompareTo(Address)

An identifier of 20 bytes (or 40 letters in hexadecimal, commonly with a prefix 0x) that refers to a unique account.

It is derived from the corresponding PublicKey of an account, but as a derivation loses information, it is always unidirectional.

The address derivation from a public key is as follows:

  1. Calculates the Keccak-256, which is a previous form of SHA-3 before NIST standardized it and does not follow FIPS-202, of the corresponding PublicKey.
  2. Takes only the last 20 bytes of the calculated Keccak-256 hash.
  3. When the address needs to be shown to end users, displays these 20 bytes in hexadecimal, with a prefix 0x.

Since the scheme of the address derivation and the PrivateKey/PublicKey is the same to Ethereum, Ethereum addresses can be used by Libplanet-backed games/apps too.

Declaration
public readonly int CompareTo(Address other)
Parameters
Type Name Description
Address other
Returns
Type Description
Int32
Remarks

Every Address value is immutable.

See Also
PublicKey
| Improve this Doc View Source

CompareTo(Object)

An identifier of 20 bytes (or 40 letters in hexadecimal, commonly with a prefix 0x) that refers to a unique account.

It is derived from the corresponding PublicKey of an account, but as a derivation loses information, it is always unidirectional.

The address derivation from a public key is as follows:

  1. Calculates the Keccak-256, which is a previous form of SHA-3 before NIST standardized it and does not follow FIPS-202, of the corresponding PublicKey.
  2. Takes only the last 20 bytes of the calculated Keccak-256 hash.
  3. When the address needs to be shown to end users, displays these 20 bytes in hexadecimal, with a prefix 0x.

Since the scheme of the address derivation and the PrivateKey/PublicKey is the same to Ethereum, Ethereum addresses can be used by Libplanet-backed games/apps too.

Declaration
public readonly int CompareTo(object obj)
Parameters
Type Name Description
Object obj
Returns
Type Description
Int32
Remarks

Every Address value is immutable.

See Also
PublicKey
| Improve this Doc View Source

Equals(Address)

An identifier of 20 bytes (or 40 letters in hexadecimal, commonly with a prefix 0x) that refers to a unique account.

It is derived from the corresponding PublicKey of an account, but as a derivation loses information, it is always unidirectional.

The address derivation from a public key is as follows:

  1. Calculates the Keccak-256, which is a previous form of SHA-3 before NIST standardized it and does not follow FIPS-202, of the corresponding PublicKey.
  2. Takes only the last 20 bytes of the calculated Keccak-256 hash.
  3. When the address needs to be shown to end users, displays these 20 bytes in hexadecimal, with a prefix 0x.

Since the scheme of the address derivation and the PrivateKey/PublicKey is the same to Ethereum, Ethereum addresses can be used by Libplanet-backed games/apps too.

Declaration
public readonly bool Equals(Address other)
Parameters
Type Name Description
Address other
Returns
Type Description
System.Boolean
Remarks

Every Address value is immutable.

See Also
PublicKey
| Improve this Doc View Source

Equals(Object)

An identifier of 20 bytes (or 40 letters in hexadecimal, commonly with a prefix 0x) that refers to a unique account.

It is derived from the corresponding PublicKey of an account, but as a derivation loses information, it is always unidirectional.

The address derivation from a public key is as follows:

  1. Calculates the Keccak-256, which is a previous form of SHA-3 before NIST standardized it and does not follow FIPS-202, of the corresponding PublicKey.
  2. Takes only the last 20 bytes of the calculated Keccak-256 hash.
  3. When the address needs to be shown to end users, displays these 20 bytes in hexadecimal, with a prefix 0x.

Since the scheme of the address derivation and the PrivateKey/PublicKey is the same to Ethereum, Ethereum addresses can be used by Libplanet-backed games/apps too.

Declaration
public override readonly bool Equals(object obj)
Parameters
Type Name Description
Object obj
Returns
Type Description
System.Boolean
Overrides
System.ValueType.Equals(System.Object)
Remarks

Every Address value is immutable.

See Also
PublicKey
| Improve this Doc View Source

GetHashCode()

An identifier of 20 bytes (or 40 letters in hexadecimal, commonly with a prefix 0x) that refers to a unique account.

It is derived from the corresponding PublicKey of an account, but as a derivation loses information, it is always unidirectional.

The address derivation from a public key is as follows:

  1. Calculates the Keccak-256, which is a previous form of SHA-3 before NIST standardized it and does not follow FIPS-202, of the corresponding PublicKey.
  2. Takes only the last 20 bytes of the calculated Keccak-256 hash.
  3. When the address needs to be shown to end users, displays these 20 bytes in hexadecimal, with a prefix 0x.

Since the scheme of the address derivation and the PrivateKey/PublicKey is the same to Ethereum, Ethereum addresses can be used by Libplanet-backed games/apps too.

Declaration
public override readonly int GetHashCode()
Returns
Type Description
Int32
Overrides
ValueType.GetHashCode()
Remarks

Every Address value is immutable.

See Also
PublicKey
| Improve this Doc View Source

GetObjectData(SerializationInfo, StreamingContext)

An identifier of 20 bytes (or 40 letters in hexadecimal, commonly with a prefix 0x) that refers to a unique account.

It is derived from the corresponding PublicKey of an account, but as a derivation loses information, it is always unidirectional.

The address derivation from a public key is as follows:

  1. Calculates the Keccak-256, which is a previous form of SHA-3 before NIST standardized it and does not follow FIPS-202, of the corresponding PublicKey.
  2. Takes only the last 20 bytes of the calculated Keccak-256 hash.
  3. When the address needs to be shown to end users, displays these 20 bytes in hexadecimal, with a prefix 0x.

Since the scheme of the address derivation and the PrivateKey/PublicKey is the same to Ethereum, Ethereum addresses can be used by Libplanet-backed games/apps too.

Declaration
public readonly void GetObjectData(SerializationInfo info, StreamingContext context)
Parameters
Type Name Description
SerializationInfo info
StreamingContext context
Remarks

Every Address value is immutable.

See Also
PublicKey
| Improve this Doc View Source

ToByteArray()

Gets a mutable array of 20 System.Bytes that represent this Address.

Declaration
[Pure]
public readonly byte[] ToByteArray()
Returns
Type Description
System.Byte[]

A new mutable array which represents this Address. Since it is created every time the method is called, any mutation on that does not affect internal states of this Address.

Remarks

Every Address value is immutable.

See Also
ByteArray
Address(Byte[])
| Improve this Doc View Source

ToHex()

Gets a mixed-case hexadecimal string of 40 letters that represent this Address. The returned hexadecimal string follows EIP 55.

Declaration
[Pure]
public readonly string ToHex()
Returns
Type Description
String

A hexadecimal string of 40 letters that represent this Address. Note that it does not start with a prefix.

Remarks

As the returned string has no prefix, for 0x-prefixed hexadecimal, call ToString() method instead.

Examples

A returned string looks like 87Ae4774E20963fd6caC967CF47aDCF880C3e89B.

See Also
ToString()
| Improve this Doc View Source

ToString()

Gets a 0x-prefixed mixed-case hexadecimal string of 42 letters that represent this Address. The returned hexadecimal string follows EIP 55.

Declaration
[Pure]
public override readonly string ToString()
Returns
Type Description
String

A 0x-hexadecimal string of 42 letters that represent this Address.

Overrides
System.ValueType.ToString()
Remarks

As the returned string is 0x-prefixed, for hexadecimal without prefix, call ToHex() method instead.

Examples

A returned string looks like 0x87Ae4774E20963fd6caC967CF47aDCF880C3e89B.

See Also
ToHex()

Operators

| Improve this Doc View Source

Equality(Address, Address)

An identifier of 20 bytes (or 40 letters in hexadecimal, commonly with a prefix 0x) that refers to a unique account.

It is derived from the corresponding PublicKey of an account, but as a derivation loses information, it is always unidirectional.

The address derivation from a public key is as follows:

  1. Calculates the Keccak-256, which is a previous form of SHA-3 before NIST standardized it and does not follow FIPS-202, of the corresponding PublicKey.
  2. Takes only the last 20 bytes of the calculated Keccak-256 hash.
  3. When the address needs to be shown to end users, displays these 20 bytes in hexadecimal, with a prefix 0x.

Since the scheme of the address derivation and the PrivateKey/PublicKey is the same to Ethereum, Ethereum addresses can be used by Libplanet-backed games/apps too.

Declaration
public static bool operator ==(Address left, Address right)
Parameters
Type Name Description
Address left
Address right
Returns
Type Description
System.Boolean
Remarks

Every Address value is immutable.

See Also
PublicKey
| Improve this Doc View Source

Inequality(Address, Address)

An identifier of 20 bytes (or 40 letters in hexadecimal, commonly with a prefix 0x) that refers to a unique account.

It is derived from the corresponding PublicKey of an account, but as a derivation loses information, it is always unidirectional.

The address derivation from a public key is as follows:

  1. Calculates the Keccak-256, which is a previous form of SHA-3 before NIST standardized it and does not follow FIPS-202, of the corresponding PublicKey.
  2. Takes only the last 20 bytes of the calculated Keccak-256 hash.
  3. When the address needs to be shown to end users, displays these 20 bytes in hexadecimal, with a prefix 0x.

Since the scheme of the address derivation and the PrivateKey/PublicKey is the same to Ethereum, Ethereum addresses can be used by Libplanet-backed games/apps too.

Declaration
public static bool operator !=(Address left, Address right)
Parameters
Type Name Description
Address left
Address right
Returns
Type Description
System.Boolean
Remarks

Every Address value is immutable.

See Also
PublicKey

Implements

System.Runtime.Serialization.ISerializable
System.IEquatable<T>
System.IComparable<T>
System.IComparable
Bencodex.IBencodable

See Also

PublicKey
  • Improve this Doc
  • View Source
In This Article
Back to top Copyright © 2018–2023 Planetarium