Coder Social home page Coder Social logo

horizontalsystems / atomic-swap-kit-ios Goto Github PK

View Code? Open in Web Editor NEW
18.0 4.0 9.0 531 KB

Atomic Swap iOS library for Bitcoin (BTC) and Bitcoin Cash (BCH) swaps in decentralized manner. Implemented on Swift.

License: MIT License

Objective-C 1.08% Swift 91.38% Ruby 7.55%
atomic-swap atomicswap atomicswaps dex bitcoin bitcoin-cash decentralized-exchange

atomic-swap-kit-ios's Introduction

Overview

This is a swift library that allows Atomic Swap, decentralized crypto currency exchange, between 2 parties. The implementation is based on Hash Time Locked Contracts.

Usage

Initialization

The primary class to use is SwapKit.

import BitcoinKit
import BitcoinCashKit
import AtomicSwapKit

let swapKit = SwapKit.instance()

swapKit.register(blockchainCreator: BitcoinSwapBlockchainCreator(kit: bitcoinAdapter.bitcoinKit), forCoin: "BTC")
swapKit.register(blockchainCreator: BitcoinSwapBlockchainCreator(kit: bitcoinCashAdapter.bitcoinCashKit), forCoin: "BCH")
swapKit.load()

The supported coins should be registered to SwapKit. The load method resumes atomic swaps previously in progress.

Exchanging crypto-curencies

There are 2 sides that take part in the process: Initiator and Responder. The process consists of the following steps:

Request for a swap

Initiator creates swap request:

let swapRequest = try swapKit.createSwapRequest(haveCoinCode: "BTC", wantCoinCode: "BCH", rate: 0.2, amount: 0.5)

Response to a swap

Responder creates response for this request:

let swapResponse = swapKit.createSwapResponse(from: swapRequest)

Creating response also starts the swap process in the Responder side.

Initiate swap

Initiator takes response and starts the swap

swapKit.initiateSwap(from: swapResponse)

Initiator and Responder Communication

The Swap Request and Swap Response are the simple data objects. They can be easily serialized into/parsed from strings and interchanged via standard apps, like messenger or email.

Prerequisites

  • Xcode 10.0+
  • Swift 5+
  • iOS 11+

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

CocoaPods 1.5.0+ is required to build BitcoinKit.

To integrate BitcoinKit into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '11.0'
use_frameworks!

target '<Your Target Name>' do
  pod 'AtomicSwapCore.swift'
  pod 'AtomicSwapBitcoinProvider'
end

Then, run the following command:

$ pod install

Example Project

All features of the library are used in example project. It can be referred as a starting point for usage of the library.

Dependencies

  • HSHDWalletKit - HD Wallet related features, mnemonic phrase geneartion.
  • HSCryptoKit - Crypto functions required for working with blockchain.

License

The AtomicSwapKit-iOS toolkit is open source and available under the terms of the MIT License.

atomic-swap-kit-ios's People

Contributors

esen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.