# Quick Start

Source: https://docs.formance.com/v3.2/modules/ledger/quick-start

Stack: v3.2

Get from zero to your first transactions. By the end you have funded an account, split a payment, and read the resulting balances, all using Numscript.

Estimated effort: 5 minutes

- fctl CLI installed

- A sandbox stack created

## Record your first transaction

Create a ledger

curl

```bash
curl -X POST $FORMANCE_API_URL/api/ledger/v2/main
```

fctl

```bash
fctl ledger create main
```

This creates a ledger named `main`. Every account and transaction in this guide lives here.

Fund a user account

Send $100 from `@world` (an infinite funding source) to a user account:

```numscript
send [USD/2 10000] (
  source = @world
  destination = @user:alice
)
```

curl

```bash
curl -X POST $FORMANCE_API_URL/api/ledger/v2/main/transactions \
  -H "Content-Type: application/json" \
  -d '{
    "script": {
      "plain": "send [USD/2 10000] (\n  source = @world\n  destination = @user:alice\n)"
    }
  }'
```

fctl

```bash
fctl ledger transactions num - --confirm --ledger main <<< 'send [USD/2 10000] ( source = @world destination = @user:alice )'
```

`USD/2` means US dollars with two decimal places, so `10000` represents $100.00. Ledger creates an account on first use.

Split a payment

Alice buys something for $30. The merchant gets 90%, the platform takes 10% as a fee:

```numscript
send [USD/2 3000] (
  source = @user:alice
  destination = {
    90% to @merchant:bob
    remaining to @platform:fees
  }
)
```

curl

```bash
curl -X POST $FORMANCE_API_URL/api/ledger/v2/main/transactions \
  -H "Content-Type: application/json" \
  -d '{
    "script": {
      "plain": "send [USD/2 3000] (\n  source = @user:alice\n  destination = {\n    90% to @merchant:bob\n    remaining to @platform:fees\n  }\n)"
    }
  }'
```

fctl

```bash
fctl ledger transactions num - --confirm --ledger main <<< 'send [USD/2 3000] ( source = @user:alice destination = { 90% to @merchant:bob remaining to @platform:fees } )'
```

The ledger enforces that Alice has sufficient funds. If she does not, Ledger rejects the whole transaction: no partial execution, no overdraft.

Check balances

curl

```bash
curl -X GET $FORMANCE_API_URL/api/ledger/v2/main/accounts
```

fctl

```bash
fctl ledger accounts list --ledger=main
```

Ledger returns these balances:

| Account         | Balance (USD/2) | Meaning             |
| --------------- | --------------: | ------------------- |
| `user:alice`    |            7000 | $70.00 remaining    |
| `merchant:bob`  |            2700 | $27.00 (90% of $30) |
| `platform:fees` |             300 | $3.00 (10% of $30)  |

Every cent is accounted for. The sum of all non-world balances equals the total funded.

## What just happened

- **Double-entry**: every `send` creates balanced movements — what leaves one account enters another
- **`@world`**: a special infinite source/sink for money entering and exiting the ledger
- **`USD/2`**: [Universal Monetary Notation](https://docs.formance.com/modules/numscript/monetary-notation) — the asset type and precision, no floating-point
- **Splits**: Numscript natively handles percentage splits with `remaining` catching rounding
- **Scarcity**: the ledger rejects transactions when the source account has insufficient funds
