Show / Hide Table of Contents

Struct Currency

Represents a currency type. Every single value of Currency defines a distinct currency type. To draw a parallel with real world monetary, each Currency value represents such currencies as USD (US Dollar) or EUR (Euro), not values like $100 or €100.

Implements
IEquatable<Currency>
ISerializable
Namespace: Libplanet.Assets
Assembly: Libplanet.dll
Syntax
public struct Currency : IEquatable<Currency>, ISerializable
Examples

Here is how US Dollar can be represented using Currency:

var USMint = new PrivateKey();
var USD = new Currency(ticker: "USD", decimalPlace: 2, minter: USMint.ToAddress());
var twentyThreeBucks = 23 * USD;
// Or alternatively: USD * 23;
// Or explicitly: new FungibleAssetValue(USD, 23, 0)

Constructors

| Improve this Doc View Source

Currency(String, Byte, Nullable<IImmutableSet<Address>>)

Defines a Currency type.

Declaration
public Currency(string ticker, byte decimalPlaces, IImmutableSet<Address>? minters)
Parameters
Type Name Description
String ticker

The ticker symbol, e.g., "USD".

Byte decimalPlaces

The number of digits to treat as minor units (i.e., exponent).

Nullable<IImmutableSet<Address>> minters

The Addresses who can mint the currency. See also Minters field which corresponds to this.

| Improve this Doc View Source

Currency(String, Byte, Nullable<Address>)

Defines a Currency type.

Declaration
public Currency(string ticker, byte decimalPlaces, Address? minter)
Parameters
Type Name Description
String ticker

The ticker symbol, e.g., "USD".

Byte decimalPlaces

The number of digits to treat as minor units (i.e., exponent).

Nullable<Address> minter

The address who can mint the currency. To specify multiple minters, use the constructor instead. See also Minters field which corresponds to this.

Fields

| Improve this Doc View Source

DecimalPlaces

The number of digits to treat as minor units (i.e., exponent).

Declaration
public readonly byte DecimalPlaces
Field Value
Type Description
Byte
| Improve this Doc View Source

Hash

The deterministic hash derived from other fields.

Declaration
public readonly HashDigest<SHA1> Hash
Field Value
Type Description
HashDigest<SHA1>
| Improve this Doc View Source

Minters

The Addresses who can mint the currency. If this is null anyone can mint the currency.

Declaration
public readonly IImmutableSet<Address>? Minters
Field Value
Type Description
Nullable<IImmutableSet<Address>>
Remarks

Unlike null, an empty set means no one can mint the currency.

See Also
MintAsset(Address, FungibleAssetValue)
| Improve this Doc View Source

Ticker

The ticker symbol, e.g., "USD".

Declaration
public readonly string Ticker
Field Value
Type Description
String

Methods

| Improve this Doc View Source

AllowsToMint(Address)

Returns true if and only if the given address is allowed to mint or burn assets of this currency.

Declaration
public bool AllowsToMint(Address address)
Parameters
Type Name Description
Address address

The account address to test.

Returns
Type Description
Boolean

true if and only if the given address is allowed to mint or burn assets of this currency.

| Improve this Doc View Source

Equals(Currency)

Declaration
public bool Equals(Currency other)
Parameters
Type Name Description
Currency other
Returns
Type Description
Boolean
| Improve this Doc View Source

Equals(Nullable<Object>)

Declaration
public override bool Equals(object? obj)
Parameters
Type Name Description
Nullable<Object> obj
Returns
Type Description
Boolean
| Improve this Doc View Source

GetHashCode()

Declaration
public override int GetHashCode()
Returns
Type Description
Int32
| Improve this Doc View Source

ToString()

Declaration
public override string ToString()
Returns
Type Description
String

Operators

| Improve this Doc View Source

Multiply(BigInteger, Currency)

Gets a fungible asset value with the given quantity of the specified currency.

Declaration
public static FungibleAssetValue operator *(BigInteger quantity, Currency currency)
Parameters
Type Name Description
BigInteger quantity

The major unit of the fungible asset value, i.e., digits before the decimal separator.

Currency currency

The currency to get a value.

Returns
Type Description
FungibleAssetValue

A fungible asset value with the given quantity of the specified currency.

Remarks

This cannot specify MinorUnit but only MajorUnit. For more precision, directly use FungibleAssetValue's constructors instead.

| Improve this Doc View Source

Multiply(Currency, BigInteger)

Gets a fungible asset value with the given quantity of the specified currency.

Declaration
public static FungibleAssetValue operator *(Currency currency, BigInteger quantity)
Parameters
Type Name Description
Currency currency

The currency to get a value.

BigInteger quantity

The major unit of the fungible asset value, i.e., digits before the decimal separator.

Returns
Type Description
FungibleAssetValue

A fungible asset value with the given quantity of the specified currency.

Remarks

This cannot specify MinorUnit but only MajorUnit. For more precision, directly use FungibleAssetValue's constructors instead.

Implements

IEquatable<>
ISerializable

See Also

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