Atomic swaps
In general, the scheme of atomic swaps in two independent blockchains looks as follows:
Transactions in Nimera Blockchain
BeginSwap
- Begin exchange operation (signed by the sender)sender
- sendertarget
- recipienttimestamp
- expiration timealg
- hashing algorithmhash
- hash?DATA (amount, color, etc)
- data about the frozen funds
CommitSwap
- complete the exchange operation (does not require a signature)hash
- hash of the secret as exchange operation identifiersecret
- secret phrasesender
- exchange initiatortarget
- recipient
RollbackSwap
- Roll back an exchange operation (does not require a signature)hash
- hash of the secret as exchange operation identifiersender
- exchange initiator
CancelSwap
- Cancel the exchange operation (signed by the sender and recipient).hash
- hash of the secret as exchange operation identifiersender
- exchange initiatortarget
- recipient
How it works
Diagram of the asset flow within a single network:
BeginSwap
initiates the exchange operation by freezing the funds in the sender's account. To do this, coins are deducted from the account and information about the operation (secret, lifetime, deducted amount, etc.) is being recorded in the account in a special field with unfinished exchanges.
CommitSwap
unfreezes the funds and transfers them to the recipient. For this purpose, the secret, whose hash was specified earlier, is provided before the expiration of the exchange operation. In fact, the operation adds the transaction amount to the recipient's balance (it was deducted from the sender when the exchange was created), and then the information about the incomplete operation gets deleted from the sender's account.
CancelSwap
cancels operations by mutual consent. It can be performed at any time, including before the exchange expires. This is an optional operation.
Last updated