# Ledger to Ledger

Source: https://docs.formance.com/modules/flows/examples/ledger-to-ledger

Stack: v3.2

In the Formance Ledger world, ledgers are logically separated from one another.

Sometimes you need to transfer value from one ledger to another.

Fortunately for us, Flows provides a way to do this that takes care of the underlying details for us.

## Workflow definition

```yaml
---
stages:
# let's first provision a user account on our first ledger
- send:
    source:
      account:
        id: "world"
        ledger: "flows-demo-001"
    destination:
      account:
        id: "users:42"
        ledger: "flows-demo-001"
    amount:
      asset: "USD/2"
      amount: 100
# now let's transfer that value to our second ledger
- send:
    source:
      account:
        id: "users:42"
        ledger: "flows-demo-001"
    destination:
      account:
        id: "users:42"
        # note that we're sending to a different ledger
        ledger: "flows-demo-002"
    amount:
      asset: "USD/2"
      amount: 100
```

## Running the workflow

Let's save the above workflow to a file called `ledger-to-ledger.yaml` and create it:

curl

```bash
curl -X POST $FORMANCE_API_URL/api/orchestration/workflows \
  -H "Content-Type: application/json" \
  -d @'ledger-to-ledger.yaml'
```

fctl

```bash
fctl orchestration workflows create ledger-to-ledger.yaml
```

Now run the workflow:

curl

```bash
curl -X POST "$FORMANCE_API_URL/api/orchestration/workflows/<workflow-id>/instances"
```

fctl

```bash
fctl orchestration workflows run <workflow-id>
```

We can now check the status of the workflow instance:

curl

```bash
curl -X GET "$FORMANCE_API_URL/api/orchestration/instances/<workflow-instance-id>"
```

fctl

```bash
fctl orchestration instances show <workflow-instance-id>
```
