description |
---|
This page explains balanced transactions and how they can be formed. |
Balanced transactions are characterized by a zero transaction delta. They can be executed if they are valid and comply with the resource machine rules. One way of obtaining balanced transactions is through composition of matching, unbalanced transactions, a.k.a. as intents. However, a single party can often directly produce a balanced transaction without requiring any counterparty.
In the following, we show examples of transactions that can be sent by a single party, here Alice.
{% hint style="info" %} Legend
- Symbols, e.g., 🍏 , indicate resource objects of specific kind that can contain arbitrary data and logic.
- Numbers Preceeding numbers, e.g., 4🍏 indicate the quantity of resources.
- Names following a resource, e.g., 4🍏 Alice , indicate who is authorized to consume.
- Blue coloring indicates ephemeral resources. {% endhint %}
Often, transactions and actions within aim to change one or multiple properties of existing resource objects. Most of the time, a single, authorized party (i.e., the owner) can unilaterally execute the transaction. Actions can include, for example,
- Transferring a resource, which changes the owner
- Splitting and merging resources, which changes the quantity
{% tabs %} {% tab title="Transfer" %} Alice owns an apple resource 🍏 and wants to transfer it to Bob.
Alice consumes her 3🍏 Alice resource and creates a 3🍏 Bob resource for Bob.
Consume | Create |
---|---|
3🍏 Alice | 3🍏 Bob |
After execution, Alice has transferred 3🍏 to Bob but the total quantity hasn't changed. {% endtab %}
{% tab title="Split" %} Alice owns an 3🍏 resource and wants to split it into a 2🍏 and a 1🍏 resource.
Alice consumes her 3🍏 Alice resource and creates a 2🍏 Alice and a 1🍏 Alice resource for herself.
Consume | Create |
---|---|
3🍏 Alice | 2🍏 Alice |
1🍏 Alice |
After execution, Alice has two resource objects instead of one, but the total quantity hasn't changed. {% endtab %}
{% tab title="Merge" %} Alice owns a 2🍏 and a 1🍏 resource and wants to merge them into one 3🍏 resource.
Alice consumes her 2🍏 Alice and 1🍏 Alice resources and creates a 3🍏 Alice resource for herself.
Consume | Create |
---|---|
2🍏 Alice | 3🍏 Alice |
1🍏 Alice |
After execution, Alice has one resource instead of two, but the total quantity hasn't changed. {% endtab %} {% endtabs %}
Changing resource properties requires resource to exist in the first place. However, immediately after the genesis of a resource controller (e.g., the launch of a new blockchain or the deployment of a protocol adapter) the associated commitment tree is empty. The question is how resources can be initially created but also finally consumed.
We call the process of initially creating a resource out of nothing initialization, and the process of finally consuming a resource finalization.
The former and latter result in inflation and deflation of the supply (i.e., the total quantity) of the associated resource kind, respectively. Both require utilizing ephemeral resources to balance the transaction.
{% hint style="info" %} Constraining the Supply
Resource logics can include constraints and mechanisms fixing the supply (i.e., the total quantity of all resources) of a given resource kind after initialization or allowing only a specific originator identity to inflate or deflate the supply. {% endhint %}
{% tabs %} {% tab title="Initialization" %} Alice wants to initiallly create an apple resource (without consuming an existing one) and inflate the total 🍏 supply by 3. To balance the transaction she uses an ephemeral resource.
Alice consumes an ephemeral 3🍏 Alice resource and creates a non-ephemeral 3🍏 Alice resource.
Consume | Create |
---|---|
3🍏 Alice | 3🍏 Alice |
After execution, Alice has created a new 3🍏 resource for herself and inflated the total supply by 3. {% endtab %}
{% tab title="Finalization" %} Alice wants to finally consume a 3🍏 resource (without creating a new one) to deflate the total 🍏 supply by 3. To balance the transaction she uses an ephemeral resource.
Alice consumes a non-ephemeral 3🍏 Alice resource and creates an ephemeral 3🍏 Alice resource.
Consume | Create |
---|---|
3🍏 Alice | 3🍏 Alice |
After execution, Alice has finally consumed her 3🍏 resource and deflated the supply by 3. {% endtab %} {% endtabs %}