Overview

While the default expectation is to record transactions between ledger balances of the same asset class, i.e., currency, Blnk also allows you to be able to record transactions between ledger balances of different asset classes using the rate parameter in your transaction request payload.

Note, the Double Entry principle only requires that there’s a corresponding credit entry for every debit entry and vice versa. However, it is up to you if you want to apply exchange rates between balances using rate or not.

How to apply “rate”

Consider a transaction record sending NGN 500.23 from a Naira balance (bal_ngn) to a Dollar balance (bal_usd).

The first thing is to determine the exchange rate value against the source, i.e., by how much should you multiply the amount to convert from the source’s currency to the destination’s currency.

In this case, 1 NGN = 0.00081 USD. This means the value for our rate is “0.00081”.

If the source is bal_usd and the destination is bal_ngn, the exchange rate will be 1 USD = 1,200 NGN. This means the amount (in USD) will be multiplied by 1,200 to compute the equivalent NGN amount.

Here’s a sample request payload with rate applied:

request
{
  "reference": ref_1234567890
  "amount": 500.23,
  "currency": "NGN",
  "precision": 100,
  "rate": 0.00081,
  "source": "bal_ngn",
  "destination": "bal_usd"
}

What happens next?

  1. Blnk applies the rate to the amount: 500.23 * 0.00081 = 0.41
  2. Blnk applies the precision to the converted amount: 0.41 * 100 = 41
  3. Blnk records the amount as 41 in bal_usd, and computes its respective balances.
  4. Blnk records the amount as 50023 in bal_ngn (after applying precision) and computes its respective balances.

To learn more about precision, read Understanding precision.

Things to Note

  1. Only send money between balances whose different asset classes have the same precision value, i.e., NGN to USD work fine because the precision value for their lowest unit possible is 100. However, NGN to BTC is not advisable.

  2. It is encouraged to always specify your precision value in your transaction payload to ensure consistency in how your balance is computed.

See also

Need help?

Are you stuck? Do you have a question that isn’t answered in this doc? Have you run into a problem you can’t solve? Want to file a bug report?

Join our Discord server and share your questions/thoughts with other developers building financial applications like you.

Was this page helpful?