• Overview
  • Design
  • API Reference
  • Changelog
  • Contribute
Show / Hide Table of Contents
  • Libplanet
    • Address
    • AddressExtension
    • ByteUtil
    • Hashcash
    • Hashcash.Stamp
    • HashDigest<T>
    • HashDigestExtension
    • Nonce
  • Libplanet.Action
    • AccountStateGetter
    • ActionEvaluation
    • ActionTypeAttribute
    • IAccountStateDelta
    • IAction
    • IActionContext
    • IRandom
    • MissingActionTypeException
    • PolymorphicAction<T>
    • RandomExtension
    • UnexpectedlyTerminatedActionException
  • Libplanet.Blockchain
    • BlockChain<T>
    • BlockChain<T>.TipChangedEventArgs
    • IncompleteBlockStatesException
    • MineBlockEventArgs<T>
  • Libplanet.Blockchain.Policies
    • BlockPolicy<T>
    • IBlockPolicy<T>
  • Libplanet.Blocks
    • Block<T>
    • InvalidBlockDifficultyException
    • InvalidBlockException
    • InvalidBlockHashException
    • InvalidBlockIndexException
    • InvalidBlockNonceException
    • InvalidBlockPreviousHashException
    • InvalidBlockTimestampException
    • InvalidGenesisBlockException
  • Libplanet.Crypto
    • CryptoConfig
    • DefaultCryptoBackend
    • ICryptoBackend
    • InvalidCiphertextException
    • PrivateKey
    • PublicKey
    • SymmetricKey
  • Libplanet.KeyStore
    • IncorrectPassphraseException
    • InvalidKeyJsonException
    • KeyJsonException
    • MismatchedAddressException
    • ProtectedPrivateKey
    • UnsupportedKeyJsonException
  • Libplanet.KeyStore.Ciphers
    • Aes128Ctr
    • ICipher
  • Libplanet.KeyStore.Kdfs
    • IKdf
    • Pbkdf2<T>
    • Scrypt
  • Libplanet.Net
    • ActionExecutionState
    • BlockDownloadState
    • BoundPeer
    • DifferentAppProtocolVersionException
    • DifferentProtocolVersionEventArgs
    • IceServer
    • IceServerException
    • InvalidMessageException
    • NoSwarmContextException
    • Peer
    • PeerNotFoundException
    • PeerState
    • PreloadBlockDownloadFailEventArgs
    • PreloadState
    • StateDownloadState
    • Swarm<T>
    • SwarmException
  • Libplanet.Net.Protocols
    • PeerDiscoveryException
  • Libplanet.Serialization
    • SerializationInfoExtension
  • Libplanet.Store
    • BaseIndex<TKey, TVal>
    • BaseStore
    • BlockSet<T>
    • ChainIdNotFoundException
    • DefaultStore
    • IStore
    • StoreExtension
    • TransactionSet<T>
  • Libplanet.Tx
    • InvalidTxException
    • InvalidTxIdException
    • InvalidTxNonceException
    • InvalidTxPublicKeyException
    • InvalidTxSignatureException
    • InvalidTxUpdatedAddressesException
    • Transaction<T>
    • TxId

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
ISerializable
IComparable<Address>
IComparable
Namespace: Libplanet
Assembly: Libplanet.dll
Syntax
public struct Address : ISerializable, IComparable<Address>, IComparable
Remarks

Every Address value is immutable.

Constructors

| Improve this Doc View Source

Address(ImmutableArray<Byte>)

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

Declaration
public Address(ImmutableArray<byte> address)
Parameters
Type Name Description
ImmutableArray<Byte> address

An immutable array of 20 s which represents an Address.

Remarks

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

See Also
ByteArray
| Improve this Doc View Source

Address(PublicKey)

Derives the corresponding Address from a PublicKey.

Note that there is an equivalent extension method ToAddress(PublicKey), which enables a code like publicKey.ToAddress() 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.

See Also
ToAddress(PublicKey)
| Improve this Doc View Source

Address(SerializationInfo, StreamingContext)

Declaration
public Address(SerializationInfo info, StreamingContext context)
Parameters
Type Name Description
SerializationInfo info
StreamingContext context
| Improve this Doc View Source

Address(Byte[])

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

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

An array of 20 s which represents an Address. This must not be null.

Remarks

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

See Also
ToByteArray()
| 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 hexadecimal address string to derive the corresponding Address from. The string should be all lower-case or mixed-case which follows EIP 55.

Fields

| Improve this Doc View Source

Size

The s size that each Address takes.

It is 20 s.

Declaration
public const int Size = null
Field Value
Type Description
Int32

Properties

| Improve this Doc View Source

ByteArray

An immutable array of 20 s that represent this Address.

Declaration
public ImmutableArray<byte> ByteArray { get; }
Property Value
Type Description
ImmutableArray<Byte>
Remarks

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

See Also
ToByteArray()

Methods

| Improve this Doc View Source

GetObjectData(SerializationInfo, StreamingContext)

Declaration
public void GetObjectData(SerializationInfo info, StreamingContext context)
Parameters
Type Name Description
SerializationInfo info
StreamingContext context
| Improve this Doc View Source

ToByteArray()

Gets a mutable array of 20 s that represent this Address.

Declaration
public byte[] ToByteArray()
Returns
Type Description
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.

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
public 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
public override string ToString()
Returns
Type Description
String

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

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

Implements

ISerializable
IComparable<>
IComparable

See Also

PublicKey
  • Improve this Doc
  • View Source
Back to top Copyright © 2019–2020 Planetarium