Coder Social home page Coder Social logo

chatch / xcat Goto Github PK

View Code? Open in Web Editor NEW
36.0 8.0 9.0 256 KB

Cross chain atomic trades protocol and api for trades between Stellar and Ethereum

License: GNU General Public License v3.0

JavaScript 100.00%
cross-chain cryptocurrencies xcat stellar-network ethereum blockchain

xcat's Introduction

xcat

Protocol and api for doing cross chain atomic trades between Stellar and Ethereum.

Protocol

Stellar XLM <-> Ethereum ETH

Stellar Asset <-> Ethereum ERC20 Token

Progress

Native Token Swap (XLM <-> ETH)

  • Protocol API Scenario 1 (Stellar side initiated)
  • Protocol API Scenario 2 (Ethereum side initiated)
  • Built in communication channel (Telehash Links?)

The protocol for trades initiated from the Stellar side is working as demonstrated by this script which exercises both parties along the path of least resistance. More testing is required around refunds and edge cases.

Communication would ideally be done by the tool over some channel rather then having users manually send each other data (see last todo item above). These 2 pieces require manual sharing:

  • initial trade.json and trade.json.sig signature (intiater sends after running 'new', counterparty run 'verifysig' and 'import' commands)
  • refund tx envelope (party 2 sends to the initiater, initiater puts it in the trade.json file and runs 'status' to continue with the trade)

These pieces can be found by scanning the ledgers and so don't require communication:

  • Ethereum HTLC contract id
  • hash(x) preimage (after submission)
  • deposit and withdraw transactions on both sides

Asset to Token Swap (Asset <-> ERC20)

  • TODO!

Trade.json

Trades are defined by a trade.json file conforming to the JSON schema here.

Example:

{
  "timelock": 1505729032,
  "commitment":
    "22bf0b3d38d2bec7226eeafd6571cdd452d34a79fb4e72f98e246d372c6a9855",
  "stellar": {
    "token": "XLM",
    "amount": 2000.0,
    "depositor": "GADU5GS223ZOY7LRWDE5IQBGMCNI523FCF5CFP2KPMMU3TKLJ7IPHEJU",
    "withdrawer": "GD3BNTEXZF7IG4OSWDJMCZ4V6N4I6XGEWO5Y6P3FYAZ24ARF2DWV2P3L"
  },
  "ethereum": {
    "token": "ETH",
    "amount": 1.0,
    "depositor": "0x7ee7d41559284957f1cd6bd14a658bf985d87ad0",
    "withdrawer": "0xfc80237acff828e5a69ba27ec506c2296dab2f68"
  }
}

Develop

Start Stellar private network

docker run -it --rm --name horizon-integrationnet -p 8000:8000 zulucrypto/stellar-integration-test-network

Start Ethereum local network

PHRASE="end staff push admit delay abandon ability nurse renew alert stomach jazz"
docker run --rm -it -p 8545:8545 chatch/ethereumjs-testrpc:4.1.3 -m "$PHRASE" $@

NOTE: PHRASE is important as the integration tests expect specific accounts to exist.

Deploy HashedTimelock smart contract

git clone https://github.com/chatch/hashed-timelock-contract-ethereum
npm i -g truffle
truffle migrate

Run tests

npm run test

Run integration test

npm run test-protocol

xcat's People

Contributors

chatch avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

xcat's Issues

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.