Figure 1 A conceptual overview of Algorand Atomic Transfers for developers.
Atomic Transfers are irreducible batch transactions that allow groups of transactions to be submitted at one time. See Figure 1 above for a conceptual overview. If any of the transactions fail, then all the transactions will fail. That is, an Atomic Transfer guarantees the simultaneous execution of multiple transfers of all kinds of assets. Detailed documentation about this feature is available on Algorand’s developer website here. If you are a database developer this is analogous to database transaction (it all works or none of it works).
In this post we will draw out some of the most important concepts for developers who plan to work with Atomic Transfers. We will list some of the many examples of real-world assets that users can represent with this feature on the Algorand blockchain. Then we will share an example scenario paired with an interactive task to get you started with this new feature on TestNet.
Steps to create Atomic Transfers
- Create unsigned transactions and save them to a file
- Combine these transactions in to one file
- Sign the grouped transactions with all the appropriate keys and submit them
Note that goal and the SDKs include wrappers for these steps.
Figure 2 Diagram shows the steps to create an Atomic Transfer.
The example code at the above link is separated into snippets categorized by these core functions…
Create the Transactions — This is like creating any kind of transaction in Algorand.
Group the Transactions — This involves computing a groupID and assigning that id to each transaction.
Sign the grouped transactions — Sign the grouped transactions with their respective private keys.
Send the transactions to the network — Combine the transactions and send it to the net.
Atomic Transfers Use Cases
Atomic Transfers enables applications such as:
- Circular Trades — e.g. Alice pays Bob if and only if Bob pays Clare if and only if Clare pays Alice.
- Group Payments — e.g. Either everyone pays or no one does.
- Decentralized exchanges — e.g. Atomic multi-party transfers enable trades without trusted intermediaries .
- Internal units of accounting — e.g. Several companies can settle their accounts with each other with a single transaction.
- Payments — e.g. Payments can be made to multiple recipients.