Struct CcdAmount
- Namespace
- Concordium.Sdk.Types
- Assembly
- Concordium.Sdk.dll
Represents a CCD amount.
Note that 1_000_000 µCCD is equal to 1 CCD.
public readonly record struct CcdAmount : IEquatable<CcdAmount>
- Implements
- Inherited Members
Fields
BytesLength
Byte length of CcdAmount integral numeric type.
public const uint BytesLength = 8
Field Value
MicroCcdPerCcd
Conversion factor, 1_000_000 µCCD = 1 CCD.
public const ulong MicroCcdPerCcd = 1000000
Field Value
Properties
Value
The amount in µCCD.
public ulong Value { get; init; }
Property Value
Zero
Zero amount.
public static CcdAmount Zero { get; }
Property Value
Methods
FromCcd(ulong)
Creates an instance from a CCD amount represented by an integer.
public static CcdAmount FromCcd(ulong ccd)
Parameters
ccd
ulongCCD amount represented by an integer.
Returns
Exceptions
- ArgumentException
The CCD amount in µCCD does not fit in ulong
FromMicroCcd(ulong)
Creates an instance from a µCCD amount represented as an integer.
public static CcdAmount FromMicroCcd(ulong microCcd)
Parameters
microCcd
ulongµCCD amount represented as an integer.
Returns
GetFormattedCcd()
Get a formatted string representing the amount in CCD.
public string GetFormattedCcd()
Returns
GetFormattedMicroCcd()
Get a formatted string representing the amount in µCCD.
public string GetFormattedMicroCcd()
Returns
Max(CcdAmount, CcdAmount)
Return the largest of two amounts.
public static CcdAmount Max(CcdAmount first, CcdAmount second)
Parameters
Returns
ToBytes()
Copies the CCD amount represented in big-endian format to byte array.
public byte[] ToBytes()
Returns
- byte[]
TryDeserial(ReadOnlySpan<byte>, out (CcdAmount? Amount, string? Error))
Create a CCD amount from a byte array.
public static bool TryDeserial(ReadOnlySpan<byte> bytes, out (CcdAmount? Amount, string? Error) output)
Parameters
bytes
ReadOnlySpan<byte>The serialized CCD amount.
output
(CcdAmount? Amount, string Error)Where to write the result of the operation.
Returns
Operators
operator +(CcdAmount, CcdAmount)
Add CCD amounts.
public static CcdAmount operator +(CcdAmount a, CcdAmount b)
Parameters
Returns
Exceptions
- ArgumentException
The result odoes not fit in ulong
operator >(CcdAmount, CcdAmount)
Determines whether one CcdAmount is greater than a second CcdAmount.
public static bool operator >(CcdAmount left, CcdAmount right)
Parameters
Returns
operator >=(CcdAmount, CcdAmount)
Determines whether one CcdAmount is greater or equal than a second CcdAmount.
public static bool operator >=(CcdAmount left, CcdAmount right)
Parameters
Returns
operator <(CcdAmount, CcdAmount)
Determines whether one CcdAmount is less than a second CcdAmount.
public static bool operator <(CcdAmount left, CcdAmount right)
Parameters
Returns
operator <=(CcdAmount, CcdAmount)
Determines whether one CcdAmount is less or equal than a second CcdAmount.
public static bool operator <=(CcdAmount left, CcdAmount right)
Parameters
Returns
operator -(CcdAmount, CcdAmount)
Subtract CCD amounts.
public static CcdAmount operator -(CcdAmount a, CcdAmount b)
Parameters
Returns
Exceptions
- ArgumentException
The result does not fit in ulong