XRPL Currency Models
The XRP Ledger has three kinds of money: XRP, issued currencies, and MPTs. All types have high precision, although their formats are different.
- class xrpl.models.currencies.IssuedCurrency(*, currency: str = <object object>, issuer: str = <object object>)
Bases:
BaseModelSpecifies an amount in an issued currency, but without a value field. This format is used for some book order requests.
See https://xrpl.org/currency-formats.html#specifying-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_dict() Dict[str, Any]
Returns the dictionary representation of a BaseModel.
If not overridden, returns the object dict with all non-None values.
- Returns:
The dictionary representation of a BaseModel.
- validate() None
Raises if this object is invalid.
- Raises:
XRPLModelException – if this object is invalid.
- class xrpl.models.currencies.MPTCurrency(*, mpt_issuance_id: str = <object object>)
Bases:
BaseModelSpecifies an amount in an MPT, but without a value field. This format is used for some book order requests.
See https://xrpl.org/currency-formats.html#specifying-currency-amounts
- 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_amount(value: str | int) MPTAmount
Converts an MPTCurrency to an MPTAmount.
- Parameters:
value – The amount of MPTs in the MPTAmount.
- Returns:
An MPTAmount that represents the MPT and the provided value.
- to_dict() Dict[str, Any]
Returns the dictionary representation of a BaseModel.
If not overridden, returns the object dict with all non-None values.
- Returns:
The dictionary representation of a BaseModel.
- validate() None
Raises if this object is invalid.
- Raises:
XRPLModelException – if this object is invalid.
- class xrpl.models.currencies.XRP
Bases:
BaseModelSpecifies XRP as a currency, without a value. Normally, you will not use this model as it does not specify an amount of XRP. In cases where you need to specify an amount of XRP, you will use a string. However, for some book order requests where currencies are specified without amounts, you may need to specify the use of XRP, without a value. In these cases, you will use this object.
See https://xrpl.org/currency-formats.html#specifying-currency-amounts
- currency: str = 'XRP'
- classmethod from_dict(value: Dict[str, Any]) Self
Construct a new XRP from a dictionary of parameters.
- Parameters:
value – The value to construct the XRP from.
- Returns:
A new XRP 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.
- to_amount(value: str | int | float) str
Converts value to XRP.
- Parameters:
value – The amount of XRP.
- Returns:
A string representation of XRP amount.
- to_dict() Dict[str, Any]
Returns the dictionary representation of an XRP currency object.
- Returns:
The dictionary representation of an XRP currency object.
- validate() None
Raises if this object is invalid.
- Raises:
XRPLModelException – if this object is invalid.
- xrpl.models.currencies.Currency
alias of
IssuedCurrency|MPTCurrency|XRP