Metaverse Trustless Atomic Swap

Sven Mutzl
Metaverse
Published in
3 min readJan 29, 2019

Metaverse is a Blockchain that enables everyone to create a digital identity (Metaverse Avatar) and register own assets on the Blockchain. These assets can either be so-called Smart Assets (MST) that have a quantity or Identifiable Tokens (MIT) that is always an indivisible entity. The main currency on Metaverse is ETP (Entropy).

Problem Definition

To enable two or even multiple parties to exchange assets there is a need for a protocol that guarantees the following requirements:

  • let users exchange asset α for asset β
  • not require a third party
  • asset safety in case of a cancellation or connection failures
  • asset security against malicious trading partners

Notation: A shall be Alice’s and B Bob’s wallet. M is a multi signature wallet of Alice and Bob which requires both signatures. α and β are the assets (and quantities) that Alice and Bob want to exchange. A transaction AMα transfers the asset α from wallet A to wallet M.

The Protocol

  1. Alice and Bob generate a multi signature wallet M

2. Alice creates a transaction AMα in which she transfers the asset α from her wallet A to the multisig wallet M. Bob creates the transaction BMβ.

3. Alice and Bob exchange the hashes of their transactions. To make it easier we can assume that the assets that are sent to the multisig wallet are in output index 0 of the transactions. Otherwise they would also have to communicate the index numbers.

4. One party (lets use Alice in this example) generates reversal transactions MAα and MBβ. Alice can create the transactions because she knows the hash of Bobs transaction BMβ and therefore she can add the output index 0 as the input of the reversal transaction MBβ. Also she can create the target transaction MAβMBα that takes the same inputs as MBα and MBβ combined.

5. Alice signs the reversal transactions MAα and MBβ and sends them to Bob.

6. Bob verifies that the transactions have the expected properties. Then he signs them and sends them back to Alice.

7. Alice verifies that the signature of the reversal transaction MAα is valid. Then she signs MAβMBα and sends it to Bob.

6. Bob signs MAβMBα and sends it back to Alice.

8. Alice can now broadcast her transaction AMα knowing that she could broadcast the completely signed reversal transaction MBα. Same is true for Bob so he can broadcast BMβ.

9. Both or one party can broadcast the target transaction MAβMBα that will use the outputs from AMα and BMβ and send the exchanged assets to the counter party.

10. Both wait for confirmations of the target transaction. In case of problems any party can broadcast their reversal transaction to refund their assets. Because Metaverse is based on UTXO (unspent transaction outputs) only the target or the reversal transactions can be included on the main chain.

Special cases

Transaction Fee

To make it easier I ignored the transaction fees. Ideally both transactions AMα and BMβ should attach enough ETP to their first output to pay for the fee of the reversal transactions.

MIT

Currently MITs can only be transferred to Avatars. To be able to process an MIT with the multisig address the sender will first have to transfer an Avatar to that address. The Avatar can be sent back to the sender in the target as well as the reversal transactions so the Avatar always gets transferred back and can be reused for later transfers. In fact it should be a dedicated Avatar for this purpose because otherwise it could cause problems if a third party tries to send a transaction to the Avatar during the time it is assigned to the multisig address. It can be some very high HD index so that it will not be visible in most wallet applications.

Future Work

I assumed that Alice and Bob already know the assets, exchange rate and quantity of their trade. This should either be subject of a decentralized matching algorithm or an OTC market. Alice and Bob also must establish a secure communication channel to exchange messages off-chain.

The protocol itself can get integrated into any Metaverse supporting wallet and will not require manual interaction. All steps can be automated.

--

--