Skip to content
GitHub

Amounts

Amounts represent monetary values and are fundamental to every Open Payments operation. Whether you’re creating an incoming payment, requesting a quote, or tracking payment progress, every amount consists of three key components: a numerical value, an assetCode, and an assetScale. Understanding these components is crucial for building Open Payments applications.

Before learning about amount components, you should understand the difference between debit and receive amounts.

  • Debit amount - The total amount that a sender will be charged, in their asset/currency, with the completion of an outgoing payment
  • Receive amount - The amount that will be paid into the recipient’s account in their asset/currency

The first component that makes up an amount is a numerical value.

To maximize precision and avoid rounding errors in financial calculations, Open Payments uses numerical data types without decimals to represent values. In the context of programming languages, this means that Open Payments uses unsigned 64-bit integers for monetary amounts instead of floating-point numbers.

An example of a value is the number 10000.

The second component of an amount is an assetCode.

Asset codes identify the type of currency or asset being used in a payment and should follow the ISO 4217 standard for currency representation.

An example of an ISO 4217 assetCode is USD, which represents the US Dollar.

The third component of an amount is an assetScale.

An asset scale tells you how many decimal places a currency uses. It’s like specifying whether you’re counting in dollars, cents, or smaller units.

Asset scales are numbers between 0 and 255 that indicate decimal precision.

In the case of USD with an assetScale of 2, the display amount of $100.00 is stored and represented as 10000 cents.

Thus, the conversion formula is:

value10assetScale=display amount\frac{\text{value}}{10^{\text{assetScale}}} = \text{display amount}

Using the preceding example, the formula looks like this:

10000102=10000100=$100.00\frac{10000}{10^2} = \frac{10000}{100} = \$100.00

CurrencyAsset CodeAsset ScaleInteger Amount (Value)Actual Value
US DollarUSD210000$100.00
EuroEUR22550€25.50
British PoundGBP23250£32.50
Japanese YenJPY01000¥1000
Mexican PesoMXN218500$185.00
Jordanian DinarJOD31000د.ا1.000
South African RandZAR21500R15.00

Using the three necessary components of value, assetCode, and assetScale, $100 USD would be represented in Open Payments using the following structure:

{
"value": "10000",
"assetCode": "USD",
"assetScale": 2
}

This consistent structure enables multi-currency payments, precise calculations, and seamless integration between different ASEs Account servicing entity .