> ## Documentation Index
> Fetch the complete documentation index at: https://docs.lerian.studio/llms.txt
> Use this file to discover all available pages before exploring further.

# Transactions DSL

> Reference for the deprecated Gold DSL and legacy .gold transaction files — for teams migrating existing scripts to the current Midaz transactions API.

<Warning>
  **Midaz deprecated this feature and will remove it in the next release.** Update your workflows now to prevent errors or downtime.

  To create transactions with the current approach, see [Transactions](/en/reference/midaz/create-a-transaction-using-dsl).
</Warning>

<Tip>
  **This page is for developers** who move away from the legacy DSL. For a business-level overview of how transactions work in Midaz, see [About Midaz](/en/midaz/about-midaz).
</Tip>

Midaz uses a **Domain-Specific Language (DSL)** called **gold** to structure financial transactions. You write each transaction as a `.gold` file. The syntax maps financial movements to accounting logic in a readable form.

### Why use Gold?

* Provides a structured format for asset transfers.
* Defines sources, destinations, and amounts explicitly.
* Supports advanced transaction logic, such as balance distribution by percentage or by remaining amount.
* Improves automation and consistency in financial workflows.

## Structure of a `.gold` file

***

A `.gold` file represents a transaction as a hierarchical structure. Here is an example:

<CodeGroup>
  ```go Go expandable theme={null}
  (transaction v1
  	(transaction route ID)
    (description "description for the transaction not for the operation")
    (metadata
      (key value)
      (anotherKey anotherValue)
    )
    (send USD 10000
      (source
       (from @originAccount :amount USD 10000
  				(transaction route ID)
          (description "shown on the statement")
          (metadata
            (key value)
            (anotherKey anotherValue)
          )
        )
      )
      (distribute
       (to @destinationAccount :amount USD 10000
  				(transaction route ID)
          (description "operation description")
          (metadata
            (key value)
          )
        )
      )
    )
  )
  ```
</CodeGroup>

## DSL hierarchy

***

This tree shows the hierarchical structure of a `.gold` file and its key relationships:

```bash theme={null}
└─ transaction
   ├─ route
   ├─ description
   ├─ code
   ├─ pending
   ├─ metadata
   │   └─ key value (n)
   ├─ send
   │   ├─ source
   │   │  └─ from
   │   │     ├─ description
   │   │     ├─ route
   │   │     └─ metadata
   │   │        └─ key value (n)
   │   └─ distribute
   │      └─ to
   │         ├─ description
   │         ├─ route
   │         └─ metadata
   └─           └─ key value (n)
```

## Understanding DSL keywords

***

### transaction

Opens a new transaction block. This block holds all related elements.

### send

Specifies the asset and amount to transfer. It lists the source accounts to debit. Group multiple `from` accounts under `source`.

**Format**: `send {asset_code} {value}`

### distribute

Defines the destination accounts to credit. Add multiple `to` accounts within `distribute`.

## Value notations in transactions

***

The **gold** DSL supports different ways to express values within a transaction:

* **`:amount`** – Standard notation for the asset, amount, and scale.
* **`:share`** – Specifies a percentage of the total `send` amount.
* **`:remaining`** – Allocates the remaining balance after all other distributions.

## Example: Pix Out transaction flow

***

This example demonstrates a Pix Out transaction in `.gold` format:

<CodeGroup>
  ```go Go expandable theme={null}
  (transaction v1
  	(transaction route ID)
    (metadata
      (anyKey anyValue)
      (anotherKey anotherValue)
    )
    (code PIX_OUT)
    (description "description for the transaction not for the operation")
    (send BRL $amount+$fee|2
      (source
       (from $sourceAccount :amount BRL $amount
  				(transaction route ID)
          (description "Pix shipping")
        )
       (from $sourceAccount :amount BRL $fee
  				(transaction route ID)
          (description "Pix shipping rate")
        )
      )
      (distribute
       (to @fees/PIX_OUT :amount BRL $fee
  				(transaction route ID)
        )
        (distribute :remaining
          (to @external/BRL :remaining
            (description "internalTransactionId 99839218")
          )
        )
      )
    )
  )
  ```
</CodeGroup>

### Breakdown:

* **(transaction v1)** – Defines a new transaction with version 1.
* **(Transaction route ID)** – Categorizes the transaction.
* **(metadata ...)** – Stores additional transaction data.
* **(send BRL fee|2)** – Specifies the total amount to send.
* **(source ...)** – Details the source accounts to debit.
* **(distribute ...)** – Allocates the funds to the appropriate accounts.
* **(distribute :remaining ...)** – Handles any remaining balance.

This format keeps transactions structured and transparent in Midaz.
