Skip to content

Latest commit

 

History

History
68 lines (45 loc) · 1.87 KB

File metadata and controls

68 lines (45 loc) · 1.87 KB

Swap

Live Demo (alpha.swap.online)

Video: https://www.youtube.com/watch?v=87PYKr1nCCI

Install

git clone https://github.com/noxonsu/swap.git
cd ./swap
npm install

For windows

npm install --global windows-build-tools

Development

npm run dev

Then open http://localhost:3000/

(also read https://stackoverflow.com/questions/9346211/how-to-kill-a-process-on-a-port-on-ubuntu)

Production

npm run build

This command automatically deploy prod version to noxonswap.surge.sh

How it works

BTC -> ETH

Alice wants to sell BTC and buy ETH, Bob owerthise wants to sell ETH and buy BTC.

  • 1. Alice creates order 1 BTC -> 10 ETH
  • 2. Bob pushes a 'Buy' button in the orders list and is redirected to /eth-to-btc/:id page.
  • 3. Alice is notified about Bob and is redirected to /btc-to-eth/:id page.
  • 4. Alice is asked to create a 'Secret Key'.
  • 5. The system automatically generates the 'Secret Hash', shows it to Alice and sends to Bob.
  • 6. The system automatically calls the ETH Swap contract method to create a swap.
  • 7. The system asks Bob to sign the transaction (Bob fund the ETH Swap contract here).
  • 8. The system automatically creates a BTC Swap script.
  • 9. Alice is notified that Bob fund the ETH Swap contract. The system asks Alice to fund the script (Alice fund the script here).
  • 10. Bob is notified that Alice fund the script.
  • 11. The system automatically sends the ETH Swap contract address to Alice and the script to Bob.
  • 12. Alice signs a call to the ETH Swap contract to withdraw ETH.
  • 13. Bob is notified that Alice did withdraw. Bob signs a call to the ETH Swap contract to receive the secret.
  • 14. Bob signs the BTC script method to withdraw 1 BTC.

Contribute

PRs accepted.

License

MIT ©