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(*, currency: str = <object object>, issuer: str = <object object>, value: str | int | float = <object object>)
Bases:
IssuedCurrencySpecifies 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]]) Self
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]) Self
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
dictionaryis a dictionary representation of this class.Note: This only checks the exact model, and does not count model inheritance. This method returns
Falseif the dictionary represents a subclass of this class.- Parameters:
dictionary – The dictionary to check. Note: The input dictionary can be of non-dict type. For instance, a str representation of JSON.
- Returns:
True if dictionary is a
dictrepresentation 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.
- class xrpl.models.amounts.MPTAmount(*, mpt_issuance_id: str = <object object>, value: str = <object object>)
Bases:
BaseModelSpecifies an MPT amount.
- classmethod from_dict(value: Dict[str, str | int | List[Any] | Dict[str, Any]]) Self
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]) Self
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
dictionaryis a dictionary representation of this class.Note: This only checks the exact model, and does not count model inheritance. This method returns
Falseif the dictionary represents a subclass of this class.- Parameters:
dictionary – The dictionary to check. Note: The input dictionary can be of non-dict type. For instance, a str representation of JSON.
- Returns:
True if dictionary is a
dictrepresentation of an instance of this class; False if not.
- is_valid() bool
Returns whether this BaseModel is valid.
- Returns:
Whether this BaseModel is valid.
- mpt_issuance_id: str
This field is required.
- to_currency() MPTCurrency
Build an MPTCurrency from this MPTAmount.
- Returns:
The MPTCurrency for this MPTAmount.
- to_dict() Dict[str, str]
Returns the dictionary representation of an MPTAmount.
- Returns:
The dictionary representation of an MPTAmount.
- validate() None
Raises if this object is invalid.
- Raises:
XRPLModelException – if this object is invalid.
- value: str
This field is required.
- xrpl.models.amounts.get_amount_value(amount: IssuedCurrencyAmount | MPTAmount | 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 | MPTAmount | str) TypeGuard[IssuedCurrencyAmount]
Returns whether amount is an issued currency value, as opposed to an XRP or MPT value.
- Parameters:
amount – The Amount object whose type is being checked.
- Returns:
Whether the amount is an issued currency value.
- xrpl.models.amounts.is_mpt(amount: IssuedCurrencyAmount | MPTAmount | str) TypeGuard[MPTAmount]
Returns whether amount is an MPT value, as opposed to an XRP or an issued currency 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 | MPTAmount | str) TypeGuard[str]
Returns whether amount is an XRP value, as opposed to an issued currency or MPT value.
- Parameters:
amount – The Amount object whose type is being checked.
- Returns:
Whether the amount is an XRP value.
- xrpl.models.amounts.Amount
alias of
IssuedCurrencyAmount|MPTAmount|str