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

> Migrate away from the deprecated Gold DSL and learn how legacy .gold files structured Midaz transactions before the current API.

<Warning>
  **This feature is deprecated and will be removed in the next release.** Update your workflows as soon as possible to prevent errors or downtime.

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

<Tip>
  **This page is intended for developers** migrating away from the legacy DSL. If you're looking 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 in a readable and intuitive way. Designed for business teams, **gold** simplifies transaction modeling by allowing operations to be processed through `.gold` files. These files make financial movements more accessible and aligned with accounting logic.

### Why use Gold?

* Provides a clear, structured format for asset transfers.
* Defines sources, destinations, and amounts explicitly.
* Supports advanced transaction logic, such as distributing balances based on percentages or remaining amounts.
* Enhances automation and consistency in financial workflows.

## Structure of a `.gold` file

***

A `.gold` file represents a transaction using a hierarchical structure. Here’s 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

***

Below is the hierarchical structure of a `.gold` file, illustrating 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, where all related elements are defined.

### send

Specifies the asset and amount to be transferred, including the source accounts from which the funds will be debited. Multiple `from` accounts can be grouped using `source`.

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

### distribute

Defines the destination accounts where the funds will be credited. Multiple `to` accounts can be included within `distribute`.

## Value notations in transactions

***

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

* **`:amount`** – Standard notation specifying 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 using version 1.
* **(Transaction route ID)** – Categorizes the transaction.
* **(metadata ...)** – Stores additional transaction data.
* **(send BRL fee|2)** – Specifies the total amount sent.
* **(source ...)** – Details the source accounts from which the amount is debited.
* **(distribute ...)** – Allocates the funds to the appropriate accounts.
* **(distribute :remaining ...)** – Ensures any remaining balance is handled.

This format ensures a **structured, transparent, and efficient** way to manage transactions in Midaz.
