Technical Documentation

Atomic Swap Wallet is a protocol allowing cross-chain swap of cryptocurrencies without the need for an intermediary party. Implementation is done with JS & the use of IPFS.

 

Features

  • DECENTRALIZED WALLET: Completely Decentralized Cryptocurrency Wallet. No intermediary parties involved. Your coins, Your keys.
  • BROWSER-BASED: No more software downloads or installs. Use the browser or the chrome extension to power your wallet.
  • ATOMIC SWAPS: Connecting multiple blockchains & enabling users to exchange coins directly with other connected peers.
  • IPFS POWERED: Orders are recorded and activated directly on the IPFS. Orders are activated & deactivated as you turn your browser on/off.
  • IMPORT/EXPORT: Import or Export your wallets as you wish. Enjoy complete control over your funds. No restrictions, no fees.
  • OPEN SOURCE: 100% open sourced project for improved transparency & further developments by Blockchain & Crypto geeks.

 

Terms You Need to Know

  • Hash function: a function conforming to the following conditions:
    If x is known, then f(x) is relatively easy to calculate.
    If y=f(x) is known, there is no simple (efficient) way to calculate x.
    Example of the function , where mod is the remainder after division by N.
  • Order: a message which indicates that the user wishes to trade ‘X’ for ‘Y’. In this case, the swap (exchange) only begins when other users ‘subscribe’ to the orders and their conditions are met. More info: https://medium.com/@EthAdvisor/atomic-swaps-etomic-swaps-explained-in-plain-english-4c3936c7adb8
  • Swap: an exchange procedure whereby X is traded for Y and vice versa in a simultaneous and irreversible way.
  • Smart contract: specifically conditioned address on the blockchain with funds locked only until the specific condition has been met.
  • Bitcoin script: smart contracts for bitcoin and likewise networks.
  • IPFS pub sub: a decentralized network for message and data transmission.

 

Forkflow

The swap (exchange) process resembles a dialogue between people. Below, M refers to the Market Maker, T refers to the Market Taker, and M refers to Messages which are marked as **. 

  1. ** Maker to All: I want to exchange 1 BITCOIN for 10 ETH (place order) (signed with a private key with a condition that a penalty of $100 is to be paid upon refusal)
  2. ** Taker to Maker: Let’s exchange
  3. The Maker fills the bitcoin script with the condition that only T may unlock it upon sending the x value conforming to the condition y=f(x) to the script; the script contains the y value.
  4. ** Maker to Taker: I have frozen bitcoins at the address {ContractBTCaddress}, sending the Y value now
  5. The Taker creates and fills a similar contract in the Ethereum network stating the same Y value
  6. ** Taker to Maker: Here is the contract in the Ethereum network {ContractETHaddress}
  7. The Maker takes ETH out of {ContractETHaddress} by transferring the X value there
  8. The Taker takes bitcoins from {ContractBTCaddress} by transferring the X value there

The Maker is unable to take money out of {ContractBTCaddress} until the timeout expires, and vice versa.

The parties check whether the smart contract is created and filled properly by the other party before taking any actions.

 

Components

Wallet

Upon first logging in to the wallet, cryptocurrency addresses and its corresponding private keys are generated for the user. The user can then proceed to import/export private keys, deposit, withdraw, view transaction history, and place swap orders.

 

Orderbook

The orderbook (for swaps) mimics a mini-blockchain whereby all parties will actively keep a copy of the orderbook.

  • order messages and data operates via events through IPFS whereby each user will be able to send his/her actions directly to other users

 

Transport: IPFS

Data are stored in a distributed network based on IPFS pub sub, and in this case the only point of failure is the signal server; furthermore, several such servers may be added.

  • Possible Alternatives: webRTC, metsh, Whisper, libp2p
  • Current: IPFS pub sub room
  • Disclaimer: It is probable that a redundant transport system will be required as IPFS remains unfinished

 

Liquidity: bots

The protocol allows exchanging cryptocurrency directly from other addresses; users do not have to keep a reserve on the stock exchange. The user may keep reserves wherever he/she requires these reserves, for example, on other stock exchanges, and run them through the system only during the swap. Thus, we will not take liquidity from competitors and become an additional invisible layer.

 

Rating and pledge

*to be expanded*

It is not possible to implement all parts of the protocol technically, many aspects still depends on the user; therefore, a rating or other additional data to filter users are required.

Rating example: Each exchange increases statistics for the volume and quantity of transactions, with the drawback that it keeps Ethereum-related transactions, but this means 95% of all tokens.

Pledge example: The market maker puts a pledge into the smart contract which is reduced if he/she agrees for transactions and later cancels them.

Rating data may be stored off-chain; each user keeps the exchange history with signatures from the other party, which allows uploading it into the blockchain at any time to obtain rating points.

 

Token (example)

  1. A token is a pledge for the green status;
  2. The user transfers the token into the smart contract, and his/her address becomes green in the system which can be seen by all protocol participants;
  3. If one party aborts the transaction, part of his/her tokens will be transferred to another user;
  4. Therefore, the system encourages correct behaviour, when the expected value is positive; it is not an investment income;
  5. If desired, the participant may withdraw excess tokens;
  6. The token holders may, upon a general vote, establish a fee for all transactions with tokens and a purpose of use (stating the address);
  7. We cannot affect the protocol operation in any way but may choose what information should be displayed on the website.

 

Questions? Email us at [email protected].