This guide helps you apply Formance Ledger patterns to real-world financial operations. The recipes that follow are illustrative — they show how Numscript can serve as an intent layer where business, finance, and engineering teams agree on financial logic in a clear, executable form. Your own regulatory, legal, and accounting obligations will shape the final implementation; treat these as a starting vocabulary, not a turnkey solution.
Intent-Based Finance#
At the heart of the Formance approach is the concept of Numscript as an intent layer. This means:
Separation of Concerns#
Define Actors and Accounts
Your business and finance teams identify all parties involved in your operations: customers, banks, payment processors, internal accounts, liability accounts, etc.
Each actor is represented by accounts in the ledger with clear naming conventions and metadata.
Map Events and Bookings
Together, teams enumerate all the financial events that can occur in your business: deposits, withdrawals, authorizations, settlements, refunds, chargebacks, minting, burning, etc.
Each event translates to specific accounting movements between accounts.
Write Numscripts
Once actors, accounts, and events are defined, Numscripts encode the business logic. These scripts become the single source of truth that both business and technical teams can read and validate.
Numscripts are intentionally readable. Your finance team should be able to review a script and confirm it matches their understanding of the business logic.
Execute with Variables
When events occur in your system, you simply "play" the appropriate Numscript with the correct variables. The ledger handles the rest: validating constraints, recording transactions, maintaining balances.
Benefits of This Approach#
- Business Clarity: Finance and operations teams can understand and validate the logic without deep technical knowledge.
- Rapid Iteration: Changes to business logic require updating Numscripts, not redeploying entire systems.
- Consistency: The same Numscript produces the same results, eliminating implementation drift across services.
Leveraging Bi-Temporality#
A critical feature of the Formance Ledger is bi-temporality, which means every transaction tracks two timestamps:
- Request Time: When the transaction was submitted to the ledger (machine clock time)
- Transaction Time: When the transaction is considered to have occurred (business effective time)
Why This Matters for Financial Operations#
In real-world financial operations, you frequently encounter timing mismatches:
- Settlement Delays: Payment authorizations happen in real-time, but bank settlements occur T+1 to T+3 days later. Your ledger should reflect the true effective dates of these movements, not just when you learned about them.
- Batch Processing: Bank statements arrive the next day. You need to record yesterday's transactions with their correct effective timestamps.
- Corrections and Adjustments: When errors are discovered or chargebacks occur, you may need to backdate transactions to reflect when they truly should have occurred.
- Multi-Timezone Operations: Events happening in different timezones need consistent temporal representation.
Implementing Bi-Temporality in Your Numscripts#
When executing Numscripts for real-world events, always provide the appropriate transaction timestamp, if reporting for point in time balances of accounts is important:
{
"script": {
"plain": "send [USD/2 100.00] (\n source = @bank:account\n destination = @user:123:main\n)",
"vars": {
"amount": "100.00",
"userId": "123"
}
},
"timestamp": "2024-10-20T14:30:00Z" // Business effective time, not current time
}If you don't specify a timestamp, the ledger uses the current machine time.
Backdating Considerations
When inserting backdated transactions (transaction time in the past), the ledger validates that the entire timeline remains consistent. This means a backdated transaction could be rejected if it would cause account balances to become invalid at any point in the future timeline.
Plan your account structures and constraints carefully to accommodate late-arriving information, or consider allowing overdraft.
Key Capabilities Demonstrated#
Throughout these recipes, you'll see how the Formance Ledger handles:
Multi-Asset Operations#
Accounts are multi-asset by default. The same account structure and Numscripts work across USD, EUR, GBP, stablecoins, or any other asset you define.
send [$ASSET] (
source = @bank:nostro
destination = @user:main
)The $ASSET variable makes the script reusable across all currencies.
Rich Metadata#
Attach business context to accounts and transactions directly within your Numscripts for powerful querying, reporting, and integration.
vars {
account $user
monetary $amount
string $auth_id
string $card_scheme
}
send $amount (
source = {
@user:main
@user:credit_line
}
destination = @hold:authorization
)
set_tx_meta("payment_method", "card")
set_tx_meta("card_scheme", $card_scheme)
set_tx_meta("authorization_id", $auth_id)Metadata can be any type: strings, numbers, monetary values, portions, or even account references. See the Numscript metadata reference for complete details.
Constraint Enforcement#
The ledger automatically enforces business rules:
- Prevent overdrafts on customer accounts
- Ensure sufficient reserves for liabilities
- Validate transaction amounts and parties
These are starting points, not finished solutions. Your business is unique, and your ledger implementation should reflect that uniqueness while maintaining the clarity and auditability that Formance enables.