Balanced Transactions
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.
Resource Property Changes
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
Examples
Alice owns an 3🍏 resource and wants to split it into a 2🍏 and a 1🍏 resource.
Alice's balanced transaction
Alice consumes her 3🍏 Alice resource and creates a 2🍏 Alice and a 1🍏 Alice resource for herself.
3🍏 Alice
2🍏 Alice
1🍏 Alice
After execution, Alice has two resource objects instead of one, but the total quantity hasn't changed.
Alice owns a 2🍏 and a 1🍏 resource and wants to merge them into one 3🍏 resource.
Alice's balanced transaction
Alice consumes her 2🍏 Alice and 1🍏 Alice resources and creates a 3🍏 Alice resource for herself.
2🍏 Alice
3🍏 Alice
1🍏 Alice
After execution, Alice has one resource instead of two, but the total quantity hasn't changed.
Resource Supply Changes
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.
Examples
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's balanced transaction
Alice consumes an ephemeral 3🍏 Alice resource and creates a non-ephemeral 3🍏 Alice resource.
3🍏 Alice
3🍏 Alice
After execution, Alice has created a new 3🍏 resource for herself and inflated the total supply by 3.
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's balanced transaction
Alice consumes a non-ephemeral 3🍏 Alice resource and creates an ephemeral 3🍏 Alice resource.
3🍏 Alice
3🍏 Alice
After execution, Alice has finally consumed her 3🍏 resource and deflated the supply by 3.
Last updated