# Introduction

Source: https://docs.formance.com/v4.0/examples/introduction

Stack: v4.0

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

Every Ledger 3.0 transaction carries two times: `timestamp`, the business-effective time you can set on the request (it defaults to the current time), and `insertedAt`, when the Ledger accepted the write. The field is described under [Control the transaction record](https://docs.formance.com/v4.0/modules/ledger/transactions/create-with-postings#control-the-transaction-record). The 2.x backdating guidance does not carry over, because it describes the PostgreSQL `moves` table that 3.0 replaces; how 3.0 validates a backdated write is not documented yet.

## 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.

```numscript
vars {
  monetary $payment
}

send $payment (
  source = @bank:nostro
  destination = @user:main
)
```

The same script runs against any currency — call it with `$payment = "USD/2 100"`, `"EUR/2 50"`, `"BTC/8 1000000"`, or any asset you've defined. A `monetary` is the asset code and amount together (e.g. `USD/2 100`), sent bare with `send $payment (…)`. To pass them separately use `asset $a` and `number $n` declarations, then write `send [$a $n] (…)`.

### Rich Metadata

Attach business context to accounts and transactions directly within your Numscripts for powerful querying, reporting, and integration.

```numscript Card Authorization with Metadata
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](https://docs.formance.com/v4.0/modules/numscript/reference/metadata) 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.
