XRPL Amount Models¶
An Amount is an object specifying a currency, a quantity of that currency, and the counterparty (issuer) on the trustline that holds the value. For XRP, there is no counterparty.
- class xrpl.models.amounts.IssuedCurrencyAmount(*args: List[Any], **kwargs: Dict[str, Any])¶
Bases:
IssuedCurrency
Specifies an amount in an issued currency.
See https://xrpl.org/currency-formats.html#issued-currency-amounts.
- currency: str¶
This field is required.
- classmethod from_dict(value: Dict[str, str | int | List[Any] | Dict[str, Any]]) BM ¶
Construct a new BaseModel from a dictionary of parameters.
- Parameters:
value – The value to construct the BaseModel from.
- Returns:
A new BaseModel object, constructed using the given parameters.
- Raises:
XRPLModelException – If the dictionary provided is invalid.
- classmethod from_xrpl(value: str | Dict[str, Any]) BM ¶
Creates a BaseModel object based on a JSON-like dictionary of keys in the JSON format used by the binary codec, or an actual JSON string representing the same data.
- Parameters:
value – The dictionary or JSON string to be instantiated.
- Returns:
A BaseModel object instantiated from the input.
- classmethod is_dict_of_model(dictionary: Any) bool ¶
Checks whether the provided
dictionary
is a dictionary representation of this class.Note: This only checks the exact model, and does not count model inheritance. This method returns
False
if the dictionary represents a subclass of this class.- Parameters:
dictionary – The dictionary to check.
- Returns:
True if dictionary is a
dict
representation of an instance of this class; False if not.
- is_valid() bool ¶
Returns whether this BaseModel is valid.
- Returns:
Whether this BaseModel is valid.
- issuer: str¶
This field is required.
- to_amount(value: str | int | float) IssuedCurrencyAmount ¶
Converts an IssuedCurrency to an IssuedCurrencyAmount.
- Parameters:
value – The amount of issued currency in the IssuedCurrencyAmount.
- Returns:
- An IssuedCurrencyAmount that represents the issued currency and the
provided value.
- to_currency() IssuedCurrency ¶
Build an IssuedCurrency from this IssuedCurrencyAmount.
- Returns:
The IssuedCurrency for this IssuedCurrencyAmount.
- to_dict() Dict[str, str] ¶
Returns the dictionary representation of an IssuedCurrencyAmount.
- Returns:
The dictionary representation of an IssuedCurrencyAmount.
- validate() None ¶
Raises if this object is invalid.
- Raises:
XRPLModelException – if this object is invalid.
- value: str | int | float¶
This field is required.
- xrpl.models.amounts.get_amount_value(amount: IssuedCurrencyAmount | str) float ¶
Returns the value of an amount irrespective of its currency.
- Parameters:
amount – The Amount object whose value we want.
- Returns:
The value of the amount irrespective of its currency.
- xrpl.models.amounts.is_issued_currency(amount: IssuedCurrencyAmount | str) bool ¶
Returns whether amount is an issued currency value, as opposed to an XRP value.
- Parameters:
amount – The Amount object whose type is being checked.
- Returns:
Whether the amount is an issued currency value.
- xrpl.models.amounts.is_xrp(amount: IssuedCurrencyAmount | str) bool ¶
Returns whether amount is an XRP value, as opposed to an issued currency.
- Parameters:
amount – The Amount object whose type is being checked.
- Returns:
Whether the amount is an XRP value.
- xrpl.models.amounts.Amount¶
alias of
Union
[IssuedCurrencyAmount
,str
]