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:
DSL hierarchy
Below is the hierarchical structure of a.gold
file, illustrating key relationships:
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. Multiplefrom
accounts can be grouped using source
.
Format: send {asset_code} {value}|{scale}
distribute
Defines the destination accounts where the funds will be credited. Multipleto
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 totalsend
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:
Breakdown:
- (transaction v1) – Defines a new transaction using version 1.
- (chart-of-accounts-group-name PIX_OUT) – 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.