* Payments involving vouchers and a user's prepaid balance * Complex funds destination scenario where the customer gets cash back * Configurable user credit balance spending transactions
The main idea is to take the pain out of describing of a system dealing with money movements should behave in traditional languages such as JS/TS/Go/Ruby etc, landing an expressive way to model these movements of value.
It is voluntarily broad in applicability—our customers use it today for use-cases ranging from marketplaces funds orchestration to home-grown loan management systems.
Once those transactions are modeled, they are to be picked up and committed to a system-of-record, ledgering system or executed on a set of payments and banking APIs.
It was initially a DSL we bundled into our Core Ledger product at Formance (YCS21) but we're giving it more autonomy now and started to make it standalone, with the idea that anyone could eventually bolt Numscript on top of their ledgering system. We're also exploring to make it natively compatible with other backends.
As part of this un-bundling, we've just shipping a playground which lets you fiddle with it without installing anything at https://playground.numscript.org/ (it works best on desktop).
Happy to chime in on any questions!
- How would this handle Canadian guidelines for dealing with cents in cash, where you round to the nearest 5c [1]?
EDIT: I think if you send 12 cents,Amounts ending in 1 cent and 2 cents are rounded down to the nearest 10 cents; Amounts ending in 3 cents and 4 cents are rounded up to the nearest 5 cents; Amounts ending in 6 cents and 7 cents are rounded down to the nearest 5 cents; Amounts ending in 8 cents and 9 cents are rounded up to the nearest 10 cents; Amounts ending in 0 cent and 5 cents remain unchanged.
It should result in sending 10 cents.send [CADCASH/2 12] ( source = @user1 destination = @user2 )
Can this happen?"postings": [{"source": "user1", "destination": "user2", "amount": 10, "asset": "CADCASH/2"}][1] https://www.canada.ca/en/revenue-agency/programs/about-canad...
- To this noob, this seems like a problem that was pretty convincingly solved by double entry accounting ledgers, but from your post it sounds like this isn’t a replacement-of but rather an addition-to that model. What’s a situation where an imperative approach would be preferable to the traditional declarative approach? My depth of knowledge pretty much starts and ends with the below document, so apologies if this is obvious to experts!
https://beancount.github.io/docs/the_double_entry_counting_m...
E: the problem being “tracking transactions”. Yes?
- This is a pretty neat paper about a Haskell DSL for specifying financial contracts and calculating their values:
https://www.microsoft.com/en-us/research/publication/composi...
It is quite powerful and you might want to look at it for possible features to use.
- Super interesting and thanks for sharing. If I understood the license page on the repository correctly, the DSL is MIT-licensed since it's not within the enterprise directory, right?
- This seems cool but what's the intention with the USD/2 notation? Is that for fractional sub-cent precision in rounding situations?
- The CLI is only displaying a "check" command but I did figure out that there is a "run" command as well.
go install github.com/formancehq/numscript@latest
numscript -hgo: downloading github.com/formancehq/numscript v0.0.8 go: downloading github.com/antlr4-go/antlr/v4 v4.13.1 go: downloading github.com/sourcegraph/jsonrpc2 v0.2.0 go: downloading golang.org/x/exp v0.0.0-20240707233637-46b078467d37Numscript cli Usage: numscript [command] Available Commands: check Check a numscript file help Help about any command Flags: -h, --help help for numscript -v, --version version for numscript Use "numscript [command] --help" for more information about a command. - Nice! I tried to achieve a similar design with my plain text accounting tool Transity: https://github.com/ad-si/Transity
But this seems to have more programming language like features if I understand correctly. What else is different?
- How do you model a bank making a loan, where the bank creates the money out of nothing and the accounting appears backwards?
The equivalent of DR @my_bank:loans_made 10000, CR @my_bank:1234 10000
- Large sends seem to crash the playground with a JSON parse error. eg change the first example 'Simple send' to send `10000000000000000000` (`send [USD/2 10000000000000000000]`) and there's a crash
- Ah, what better input format than JSON, a poorly defined, ambiguous format that freely mixes integers and floating points and lacks supports for bigints and bigdecimals.
- Can this or Formance interact with credit card systems, checking accounts, and layer 2 crypto wallets? If not, how is the money even going to come in or out?
- Are there converters to/from OFX for Numscript?
- This is mindblowing. It's like the missing piece of blockchain that was needed for dev adoption. I can see it also being used for modern bank/payments apps including those in games and other simulated economies.
Now let's see a "ContentScript" for posting content to ledgers :D
send [Image "tacos.jpg", Text "taco 2sday!"] ( source = @bschmidt1 destination = @us-west-relay )