> For the complete documentation index, see [llms.txt](https://docs.xyb.co/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.xyb.co/xyb-platform-1/xyb-ledger/getting-started/quick-start-guide-building-a-simple-ledger-product.md).

# Create a Ledger Product via CLI Tool - Tutorial

Let's start by building a simple Ledger product using our command line tool, Luca. This should help you to understand the basic logic and workflow of Ledger.

This guide will walk you through setting up a **basic financial ledger** using the **Luca Command Line Tool**. The goal is to establish a **structured ledger** to manage payroll payments, ensuring that funds flow **correctly** from a **Revenue Account** to a **Salary Account**, while also maintaining accurate balance updates.

<figure><img src="https://2842134550-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FakJn6TxWIBAbZwLlYoVP%2Fuploads%2F7P86Gi1NkdbVL1jpNCk3%2Fimage.png?alt=media&amp;token=1be40d79-82cd-4d0f-bc2d-f5264318e8e0" alt=""><figcaption></figcaption></figure>

### **After completing this guide, you will be able to:**

* Set up a **Chart of Accounts** for the main **Financial Ledger**.
* Create an **Employee Funds Group** to manage **salary accounts and wallets**.
* Set up **wallets** under these accounts for **revenue collection** and **salary disbursement**.
* Initiate a **fund transfer** from the **Funds Wallet** to the **Salary Wallet**.
* **Verify transactions and balances** in the ledger after movement.

***

### **🛠️ Pre-requisites**

Before starting, ensure:

* You have the **Luca Command Line tool installed and initialized** with verified credentials. *(Refer to the* [*setup guide*](/xyb-platform-1/xyb-ledger/integrate-with-xyb-ledger/ledger-setup-and-configuration/install-and-setup-the-ledger-cli-tool.md) *if needed.)*
* You have a **basic understanding** of **accounts, wallets, and financial transactions**.

### a) Setting up the Chart Structure

The **Chart of Accounts** defines the organization’s financial structure. It tracks income and transactions by categorizing accounts for different purposes.

#### **Step 1: Create a Chart of Accounts for the Financial Ledger**

```bash
./luca write-chart FIN_CHART
```

> This **creates a Chart of Accounts** named `FIN_CHART`, which will **serve as the foundation** for all financial transactions.

***

#### **Step 2: Create a Revenue Account under the Financial Ledger**

```bash
./luca write-chart-account FIN_CHART REV_ACC
```

> This **creates a Revenue Account (`REV_ACC`)** under `FIN_CHART`, which will store **business income** before allocation to expenses (e.g., salaries).

***

#### **Step 3: Create a Funds Wallet under the Revenue Account**

```bash
./luca write-chart-wallet FIN_CHART REV_ACC FUNDS_WALLET EUR REVENUE --decimal-places=2
```

> The **Funds Wallet (`FUNDS_WALLET`)** is created under `REV_ACC`.
>
> * **Currency:** EUR
> * **Type:** REVENUE (indicates income)
> * **Decimal Places:** 2 (ensures accurate fund tracking)\
>   This **wallet holds company revenue** before it is allocated to **employee payments**.

***

#### **Step 4: Open the Revenue Account**

```bash
./luca transition /chart/FIN_CHART/REV_ACC OPEN
```

> This **activates the Revenue Account** (`REV_ACC`) so it can start processing transactions.

***

### b) Setting up the Group Structure

We now **set up a Group Account** for employees **based in Europe**. This group will **manage payroll transactions**, including salary disbursements.

#### **Step 5: Create an Employee Group Account (Europe)**

```bash
./luca write-group EMP_EU
```

> This **creates an Employee Group (`EMP_EU`)**, which will manage **payroll and operational costs** for European employees.

***

#### **Step 6: Create an Employee Payroll Account**

```bash
./luca write-group-account EMP_EU EMP_A_ACCOUNT
```

> This **creates an Employee Payroll Account (`EMP_A_ACCOUNT`)** under the `EMP_EU` group.\
> This account is responsible for **salary disbursements**.

***

#### **Step 7: Create a Salary Wallet under the Payroll Account**

```bash
./luca write-group-wallet EMP_EU EMP_A_ACCOUNT SALARY_WALLET_A EUR EXPENSE --decimal-places=2
```

> The **Salary Wallet (`SALARY_WALLET_A`)** is created under `EMP_A_ACCOUNT`.
>
> * **Currency:** EUR
> * **Type:** EXPENSE (as salaries are an outgoing cost)
> * **Decimal Places:** 2\
>   This **wallet is where employee salaries will be credited** before being paid out.

***

#### **Step 8: Open the Employee Payroll Account**

```bash
./luca transition /group/EMP_EU/EMP_A_ACCOUNT OPEN
```

> This **activates the Employee Payroll Account**, allowing funds to be received and distributed.

***

### c) Record transactions and review balances

With the structure set up, we will record the fund transfer from the Funds Wallet (Revenue Account) to the Salary Wallet (Payroll Account) and verify the balances. To do this, you need to create and execute an instruction that updates the wallet balances.&#x20;

{% hint style="info" %}
In a real-world scenario, this action would be triggered by a fund movement, with the Ledger monitoring the event and recording it accordingly. For this example, we will assume that the transfer has already occurred.
{% endhint %}

#### **Step 9: Create the Instruction for fund transfer recording from Revenue to Payroll**

To record this transfer, we will create an **instruction** that specifies the movement of funds and finalizes the transaction. **Define the fund movement activity** by specifying the source and destination wallets:

```sh
./luca add-activity - /chart/FIN_CHART/REV_ACC/FUNDS_WALLET/EUR/ \
/group/EMP_EU/EMP_A_ACCOUNT/SALARY_WALLET_A 1000 --finalize
```

* **/chart/FIN\_CHART/REV\_ACC/FUNDS\_WALLET/EUR/** → Source wallet (Revenue Account).
* **/group/EMP\_EU/EMP\_A\_ACCOUNT/SALARY\_WALLET\_A** → Destination wallet (Payroll Account).
* **1000** → Amount being transferred.
* **--finalize** → Ensures the transaction is fully committed.

**Step 10: Execute the instruction to send it to the ledger for processing:**

```sh
./luca write-instruction
```

This command finalizes the movement and records the transaction for audit purposes.

***

#### **Step 11: Verify Transactions & Update Wallet Balances**

**Check Employee Payroll Account Balance**

To confirm that the payroll account balance is updated after the fund transfer, run:

```sh
./luca read-group-account EMP_EU EMP_A_ACCOUNT
```

This retrieves the latest balance of **EMP\_A\_ACCOUNT**, ensuring that the ledger correctly reflects the fund movement.

**Check Transaction Postings**

To verify that the salary funds have been recorded as committed, run:

```sh
./luca read-postings /group/EMP_EU/EMP_A_ACCOUNT/SALARY_WALLET_A/EUR --status=COMMITTED
```

This confirms that the ledger has recognized and finalized the postings, aligning with the external payment execution.

By performing these checks, we ensure that the **ledger accurately reflects** the completed fund transfer and maintains a reliable record for reconciliation and auditing.

***


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.xyb.co/xyb-platform-1/xyb-ledger/getting-started/quick-start-guide-building-a-simple-ledger-product.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
