Money-native · real, tested code

Convert Currency in Larzscript

Convert an amount between currencies with a settable rate table - fully offline, no API call, no hidden currency-tagging assumptions.

fx.set_rate() records a rate (and its inverse automatically), fx.convert() scales a Money amount by it - the package is explicit that Larzscript's Money type isn't currency-tagged, so the caller is responsible for tracking which currency a value is actually in.

larzscript pkg install fx

Code

import "fx" as fx

fx.set_rate("USD", "NGN", 1550.0)
print(fx.convert($10.00, "USD", "NGN"))
print(round(fx.rate("NGN", "USD"), 6))
Output
$15500.00
0.000645