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.
Namespace: Libplanet.Types.Assets
Assembly: Libplanet.Types.dll
Syntax
public readonly struct Currency
Remarks
There are two types of Currencies: capped and uncapped. Capped currencies have a hard limit on the maximum minted amount, and uncapped currencies do not have the said limit. To define a Currency you may call either of the following.
Examples
Here is how US Dollar can be represented using Currency:
var USMint = new PrivateKey();
var USD = Currency.Uncapped(ticker: "USD", decimalPlaces: 2, minter: USMint.Address);
var twentyThreeBucks = 23 * USD;
// Or alternatively: USD * 23;
// Or explicitly: new FungibleAssetValue(USD, 23, 0)
Constructors
| Improve this Doc View SourceCurrency(IValue)
Deserializes a Currency type from a Bencodex value.
Declaration
public Currency(IValue serialized)
Parameters
Type | Name | Description |
---|---|---|
IValue | serialized | The Bencodex value serialized by Serialize() method. |
Remarks
There are two types of Currencies: capped and uncapped. Capped currencies have a hard limit on the maximum minted amount, and uncapped currencies do not have the said limit. To define a Currency you may call either of the following.
See Also
| Improve this Doc View SourceCurrency(HashDigest<SHA1>, String, Byte, Nullable<IImmutableSet<Address>>, Boolean, Nullable<FungibleAssetValue>)
An internal constructor for JSON deserialization. Do not use this directly.
Declaration
public Currency(HashDigest<SHA1> hash, string ticker, byte decimalPlaces, IImmutableSet<Address>? minters, bool totalSupplyTrackable, FungibleAssetValue? maximumSupply)
Parameters
Type | Name | Description |
---|---|---|
HashDigest<SHA1> | hash | |
System.String | ticker | |
System.Byte | decimalPlaces | |
System.Nullable<IImmutableSet<Address>> | minters | |
System.Boolean | totalSupplyTrackable | |
System.Nullable<FungibleAssetValue> | maximumSupply |
Remarks
There are two types of Currencies: capped and uncapped. Capped currencies have a hard limit on the maximum minted amount, and uncapped currencies do not have the said limit. To define a Currency you may call either of the following.
See Also
Fields
| Improve this Doc View SourceDecimalPlaces
The number of digits to treat as minor units (i.e., exponent).
Declaration
public readonly byte DecimalPlaces
Field Value
Type | Description |
---|---|
System.Byte |
Remarks
There are two types of Currencies: capped and uncapped. Capped currencies have a hard limit on the maximum minted amount, and uncapped currencies do not have the said limit. To define a Currency you may call either of the following.
See Also
| Improve this Doc View SourceHash
The deterministic hash derived from other fields.
Declaration
public readonly HashDigest<SHA1> Hash
Field Value
Type | Description |
---|---|
HashDigest<SHA1> |
Remarks
There are two types of Currencies: capped and uncapped. Capped currencies have a hard limit on the maximum minted amount, and uncapped currencies do not have the said limit. To define a Currency you may call either of the following.
See Also
| Improve this Doc View SourceMinters
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 |
---|---|
System.Nullable<IImmutableSet<Address>> |
Remarks
Unlike null, an empty set means no one can mint the currency.
See Also
| Improve this Doc View SourceTicker
The ticker symbol, e.g., "USD"
.
Declaration
public readonly string Ticker
Field Value
Type | Description |
---|---|
System.String |
Remarks
There are two types of Currencies: capped and uncapped. Capped currencies have a hard limit on the maximum minted amount, and uncapped currencies do not have the said limit. To define a Currency you may call either of the following.
See Also
| Improve this Doc View SourceTotalSupplyTrackable
Whether the total supply of this instance of Currency is trackable.
Declaration
public readonly bool TotalSupplyTrackable
Field Value
Type | Description |
---|---|
System.Boolean |
Remarks
There are two types of Currencies: capped and uncapped. Capped currencies have a hard limit on the maximum minted amount, and uncapped currencies do not have the said limit. To define a Currency you may call either of the following.
See Also
Properties
| Improve this Doc View SourceMaximumSupply
The uppermost quantity of currency allowed to exist. null means unlimited supply.
Declaration
public readonly FungibleAssetValue? MaximumSupply { get; }
Property Value
Type | Description |
---|---|
System.Nullable<FungibleAssetValue> |
Remarks
There are two types of Currencies: capped and uncapped. Capped currencies have a hard limit on the maximum minted amount, and uncapped currencies do not have the said limit. To define a Currency you may call either of the following.
See Also
Methods
| Improve this Doc View SourceAllowsToMint(Address)
Returns true if and only if
the given address
is allowed
to mint or burn assets of this currency.
Declaration
public readonly bool AllowsToMint(Address address)
Parameters
Type | Name | Description |
---|---|---|
Address | address | The account address to test. |
Returns
Type | Description |
---|---|
System.Boolean | true if and only if
the given |
Remarks
There are two types of Currencies: capped and uncapped. Capped currencies have a hard limit on the maximum minted amount, and uncapped currencies do not have the said limit. To define a Currency you may call either of the following.
See Also
| Improve this Doc View SourceCapped(String, Byte, (BigInteger Major, BigInteger Minor), Address)
Define a Currency with a maximum supply limit.
Declaration
public static Currency Capped(string ticker, byte decimalPlaces, (BigInteger Major, BigInteger Minor) maximumSupply, Address minter)
Parameters
Type | Name | Description |
---|---|---|
System.String | ticker | The ticker symbol, e.g., |
System.Byte | decimalPlaces | The number of digits to treat as minor units (i.e., exponent). |
System.ValueTuple<BigInteger, BigInteger> | maximumSupply | The uppermost quantity of currency allowed to exist. For
example, the |
Address | minter | The address who can mint the currency. To specify multiple
minters, use the |
Returns
Type | Description |
---|---|
Currency | An instance of Currency with a maximum supply limit. |
Remarks
There are two types of Currencies: capped and uncapped. Capped currencies have a hard limit on the maximum minted amount, and uncapped currencies do not have the said limit. To define a Currency you may call either of the following.
See Also
| Improve this Doc View SourceCapped(String, Byte, (BigInteger Major, BigInteger Minor), Nullable<IImmutableSet<Address>>)
Define a Currency with a maximum supply limit.
Declaration
public static Currency Capped(string ticker, byte decimalPlaces, (BigInteger Major, BigInteger Minor) maximumSupply, IImmutableSet<Address>? minters)
Parameters
Type | Name | Description |
---|---|---|
System.String | ticker | The ticker symbol, e.g., |
System.Byte | decimalPlaces | The number of digits to treat as minor units (i.e., exponent). |
System.ValueTuple<BigInteger, BigInteger> | maximumSupply | The uppermost quantity of currency allowed to exist. For
example, the |
System.Nullable<IImmutableSet<Address>> | minters | The Addresses who can mint the currency. See also Minters field which corresponds to this. |
Returns
Type | Description |
---|---|
Currency | An instance of Currency with a maximum supply limit. |
Remarks
There are two types of Currencies: capped and uncapped. Capped currencies have a hard limit on the maximum minted amount, and uncapped currencies do not have the said limit. To define a Currency you may call either of the following.
See Also
| Improve this Doc View SourceEquals(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.
Declaration
public readonly bool Equals(Currency other)
Parameters
Type | Name | Description |
---|---|---|
Currency | other |
Returns
Type | Description |
---|---|
System.Boolean |
Remarks
There are two types of Currencies: capped and uncapped. Capped currencies have a hard limit on the maximum minted amount, and uncapped currencies do not have the said limit. To define a Currency you may call either of the following.
See Also
| Improve this Doc View SourceEquals(Nullable<Object>)
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.
Declaration
public override readonly bool Equals(object? obj)
Parameters
Type | Name | Description |
---|---|---|
System.Nullable<System.Object> | obj |
Returns
Type | Description |
---|---|
System.Boolean |
Remarks
There are two types of Currencies: capped and uncapped. Capped currencies have a hard limit on the maximum minted amount, and uncapped currencies do not have the said limit. To define a Currency you may call either of the following.
See Also
| Improve this Doc View SourceGetHashCode()
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.
Declaration
public override readonly int GetHashCode()
Returns
Type | Description |
---|---|
System.Int32 |
Remarks
There are two types of Currencies: capped and uncapped. Capped currencies have a hard limit on the maximum minted amount, and uncapped currencies do not have the said limit. To define a Currency you may call either of the following.
See Also
| Improve this Doc View SourceLegacy(String, Byte, Address)
OBSOLETE! DO NOT USE.
(unless you are upgrading your project from an old
version of Libplanet that did not support total supply tracking for
Currencies and had a legacy Currency defined.)
Define a legacy Currency without total supply tracking, which is
internally compatible with the legacy version.
Declaration
public static Currency Legacy(string ticker, byte decimalPlaces, Address minter)
Parameters
Type | Name | Description |
---|---|---|
System.String | ticker | The ticker symbol, e.g., |
System.Byte | decimalPlaces | The number of digits to treat as minor units (i.e., exponent). |
Address | minter | The address who can mint the currency. To specify multiple minters, use the Legacy(String, Byte, Nullable<IImmutableSet<Address>>) See also Minters field which corresponds to this. |
Returns
Type | Description |
---|---|
Currency | An instance of legacy Currency without total supply tracking. |
Remarks
There are two types of Currencies: capped and uncapped. Capped currencies have a hard limit on the maximum minted amount, and uncapped currencies do not have the said limit. To define a Currency you may call either of the following.
See Also
| Improve this Doc View SourceLegacy(String, Byte, Nullable<IImmutableSet<Address>>)
OBSOLETE! DO NOT USE.
(unless you are upgrading your project from an old
version of Libplanet that did not support total supply tracking for
Currencies and had a legacy Currency defined.)
Define a legacy Currency without total supply tracking, which is
internally compatible with the legacy version.
Declaration
public static Currency Legacy(string ticker, byte decimalPlaces, IImmutableSet<Address>? minters)
Parameters
Type | Name | Description |
---|---|---|
System.String | ticker | The ticker symbol, e.g., |
System.Byte | decimalPlaces | The number of digits to treat as minor units (i.e., exponent). |
System.Nullable<IImmutableSet<Address>> | minters | The Addresses who can mint the currency. See also Minters field which corresponds to this. |
Returns
Type | Description |
---|---|
Currency | An instance of legacy Currency without total supply tracking. |
Remarks
There are two types of Currencies: capped and uncapped. Capped currencies have a hard limit on the maximum minted amount, and uncapped currencies do not have the said limit. To define a Currency you may call either of the following.
See Also
| Improve this Doc View SourceSerialize()
Serializes the currency into a Bencodex value.
Declaration
public readonly IValue Serialize()
Returns
Type | Description |
---|---|
IValue | The serialized Bencodex value. |
Remarks
There are two types of Currencies: capped and uncapped. Capped currencies have a hard limit on the maximum minted amount, and uncapped currencies do not have the said limit. To define a Currency you may call either of the following.
See Also
| Improve this Doc View SourceToString()
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.
Declaration
public override readonly string ToString()
Returns
Type | Description |
---|---|
System.String |
Remarks
There are two types of Currencies: capped and uncapped. Capped currencies have a hard limit on the maximum minted amount, and uncapped currencies do not have the said limit. To define a Currency you may call either of the following.
See Also
| Improve this Doc View SourceUncapped(String, Byte, Address)
Define a Currency without a maximum supply limit.
Declaration
public static Currency Uncapped(string ticker, byte decimalPlaces, Address minter)
Parameters
Type | Name | Description |
---|---|---|
System.String | ticker | The ticker symbol, e.g., |
System.Byte | decimalPlaces | The number of digits to treat as minor units (i.e., exponent). |
Address | minter | The address who can mint the currency. To specify multiple minters, use the Uncapped(String, Byte, Nullable<IImmutableSet<Address>>) See also Minters field which corresponds to this. |
Returns
Type | Description |
---|---|
Currency | An instance of Currency without a maximum supply limit. |
Remarks
There are two types of Currencies: capped and uncapped. Capped currencies have a hard limit on the maximum minted amount, and uncapped currencies do not have the said limit. To define a Currency you may call either of the following.
See Also
| Improve this Doc View SourceUncapped(String, Byte, Nullable<IImmutableSet<Address>>)
Define a Currency without a maximum supply limit.
Declaration
public static Currency Uncapped(string ticker, byte decimalPlaces, IImmutableSet<Address>? minters)
Parameters
Type | Name | Description |
---|---|---|
System.String | ticker | The ticker symbol, e.g., |
System.Byte | decimalPlaces | The number of digits to treat as minor units (i.e., exponent). |
System.Nullable<IImmutableSet<Address>> | minters | The Addresses who can mint the currency. See also Minters field which corresponds to this. |
Returns
Type | Description |
---|---|
Currency | An instance of Currency without a maximum supply limit. |
Remarks
There are two types of Currencies: capped and uncapped. Capped currencies have a hard limit on the maximum minted amount, and uncapped currencies do not have the said limit. To define a Currency you may call either of the following.
See Also
Operators
| Improve this Doc View SourceMultiply(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 |
Remarks
This cannot specify MinorUnit but only MajorUnit. For more precision, directly use FungibleAssetValue's constructors instead.
See Also
| Improve this Doc View SourceMultiply(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 |
Remarks
This cannot specify MinorUnit but only MajorUnit. For more precision, directly use FungibleAssetValue's constructors instead.