The project won the Consensys Sponsorship Prize on the ETHSanFrancisco hackathon. Created by HU Yao-Chieh, Tina Lee, and Kevin Gau.
Branch: bitcoinjs-lib-…
Clone or download
Latest commit 0827d6f Oct 9, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci Revert "ci: ignore gh-pages" Jul 26, 2018
.github
examples color and UI update Oct 7, 2018
src Remove unnecessary console.log Oct 7, 2018
test Add Bitcoin RPC provider (#65) Oct 4, 2018
webpack Add Bitcoin RPC provider (#65) Oct 4, 2018
.babelrc remove dist and docs folder. use per-target babel config Jul 26, 2018
.esdoc.json Errors, documentation for errors and updated examples (#30) Aug 6, 2018
.gitignore Removed yarn.lock Jul 26, 2018
CODE_OF_CONDUCT.md Prepare the project! (#47) Sep 5, 2018
CONTRIBUTION.md Prepare the project! (#47) Sep 5, 2018
LICENSE.md
README.md
liquality-logo.png Prepare the project! (#47) Sep 5, 2018
package-lock.json copy over Oct 7, 2018
package.json Bitcoin Swap Provider using locally using bitcoinjs-lib Oct 7, 2018

README.md

BTC - ETH Cross Chain Atomic Swap

The project won the Consensys Sponsorship Prize on the ETHSanFrancisco hackathon.

Created by HU Yao-Chieh, Lee Ting Ting, and Kevin Gau.

We built the CrossChain Swap environments for Bitcoin and Ethereum respectively. We implemented the mvp of the idea as a demo to visualize the BTC/ETH swapping process. Description on project deatils is available on Devpost with the Demo Video on Youtube

End-to-end Test Case

  1. Open Ethereum private node: ganache-cli
  2. Open Bitcoin private node (after downloading bitcoin core): bitcoind -txindex -regtest -reindex -rpcpassword=local321 -rpcuser=bitcoin -rpcport=18332
  3. Host the html site on port 9000: serve-https /Users/tingtinglee/hack/WEB-v2-BTC/examples/swap/swap-e2e-local.html -p 9000
  4. In the browser, GOTO https://localhost:9000/examples/swap/_swap-e2e-local.html
  5. Fill in Bitcoin params: 100000 (or any)
  6. Click on Generate Secret

A Initiates SWAP on Bitcoin

  1. Copy over Secret Hash to Bitcoin Initiate Swap
  2. Click on Initiate Swap

B Initiates SWAP on Ethereum

  1. Fill in Secret Hash at Ethereum Initiate Swap
  2. Click on Initiate Swap

A Claims SWAP on Ethereum

  1. Fill in Secret from A
  2. Fill in Initiate Transaction Hash from B's Initiation on Ethereum

B Claims SWAP on Bitcoin

  1. Fill in Secret from A
  2. Fill in Initiate Transaction Hash from A's Initiation on Bitcoin

Addresses

  • A's BTC address: muWrnsfYwzv24sAuC1t45JssWttHUtA162
  • A's ETH address: 0x5a3df33ebab91eb80712493c8ad30855b882c669
  • B's BTC address: muT9jzX9Jws7X9xE6JZkXcNrzNAfQRDaj9
  • B's ETH address: 0x1cdf3aac5329aa9d1dee420468a72bad24055885

Bitcoin tips

Host Bitcoin private net

bitcoind -txindex -regtest -reindex -rpcpassword=local321 -rpcuser=bitcoin -rpcport=18332

Interact with the Bitcoin private net via console

bitcoin-cli -rpcpassword=local321 -rpcuser=bitcoin -rpcport=18332 <function_name> <function_param>

Generate a Bitcoin address

bitcoin-cli -rpcpassword=local321 -rpcuser=bitcoin -rpcport=18332 getrawchangeaddress "legacy"

get help

bitcoin-cli -rpcpassword=local321 -rpcuser=bitcoin -rpcport=18332 help

import private key

bitcoin-cli -rpcpassword=local321 -rpcuser=bitcoin -rpcport=18332 importprivkey cVuHNLamShn9pJEVQLy76fdzLPZxgfhenVdK7wo1vBweue4x2dHv
bitcoin-cli -rpcpassword=local321 -rpcuser=bitcoin -rpcport=18332 importprivkey cTYiTKhEujcjM4xqgzRHbpCc9Mbtpvqd8VpsRUB6aXygBgg5JsYp

generate 100 blocks

bitcoin-cli -rpcpassword=local321 -rpcuser=bitcoin -rpcport=18332 generate 101

fund an address

bitcoin-cli -rpcpassword=local321 -rpcuser=bitcoin -rpcport=18332 sendtoaddress muT9jzX9Jws7X9xE6JZkXcNrzNAfQRDaj9 10

Examine on console

Check bitcoin balance

bitcoin.getBalance(["muT9jzX9Jws7X9xE6JZkXcNrzNAfQRDaj9"]).then(console.log)

Chain Abstraction Layer

ChainAbstractionLayer Standard Code Style MIT License ChainAbstractionLayer

⚠️ This project is under heavy development. Expect bugs & breaking changes.

Query different blockchains with a single and simple interface.

Installation

npm install @liquality/chainabstractionlayer

Error: Cannot find module 'babel-runtime/core-js/get-iterator'

Issues to track: LedgerHQ/ledgerjs/issues/211, LedgerHQ/ledgerjs/issues/218

npm install babel-runtime

Usage

import { Client, providers } from '@liquality/chainabstractionlayer'

const { BitcoinRPCProvider } = providers.bitcoin

const bitcoin = new Client()
bitcoin.addProvider(new BitcoinRPCProvider('http://localhost:8080', 'bitcoin', 'local321'))

bitcoin
  .generateBlock(1) // returns Promise
  .then(console.log) // Array<BlockHash>

Community

Liquality Gitter

Try ChainAbstractionLayer in Browser

Chain Wallet Provider
Ethereum Ledger Source & Demo
MetaMask Source & Demo
Bitcoin Ledger Source & Demo

Documentation

The documentation is being generated by esdoc. Github Page hosted documentation is available at liquality.github.io/chainabstractionlayer

If you want to build documentation locally;

npm run build:docs

License

MIT