Dapps - Glow-Lang/glow GitHub Wiki

Some Simple DApps Written in Glow

Buying a Signature: Check our tutorial for this simplest of all DApps: a buyer paying a seller for the signature on a document. With this DApp, you can complete the sale of some real-world assets, goods or services: a title transfer, sales contract or service agreement is signed by the seller in exchanged for payment of some tokens or other assets as escrowed in advance by the buyer. The document signed could also be a transaction on another blockchain, in which case the DApp implements the latter half of an on-chain atomic swap between blockchains.

Asset Swap In this example, a function swap is defined that exchanges two baskets of assets between two participants. It can be called with an expression like:

swap(alice, {ETH: 10}, bob, {DAI: 2084})

The execution model is that the first participant, Alice, will deposit her basket into the escrow for the current interaction. Then the second participant will deposit his basket. Finally they will each withdraw the other basket. When compiling, Glow will automatically divide this interaction into two transactions: The first transaction is the deposit by participant A. The transaction must end there, because the next action is done by the other participant. The second is the deposit by participant B followed by both withdrawals. The withdrawals are done by the consensus and therefore do not depend on a change of participant. To protect the first participant, in case the second one fails to deposit his basket, a timeout will automatically be added, that allows them to withdraw the basket they have deposited into the interaction. These automatically added timeouts ensure that the interaction is either completed or aborted, but not stuck forever waiting.

So far, Glow only directly supports swaps between assets on a same blockchain, and wrappers have to be used to trade assets on other blockchains.