Files
bch-dex/README.md
T

4.3 KiB

bch-dex

js-standard-style semantic-release Join the chat at https://gitter.im/Permissionless-Software-Foundation/psf-dex-dev

This is a prototype web service that monitors the P2WDB for trading signals, to trade BCH and SLP tokens. It's inspired by the SWaP Protocol.

This repository contains the back end code. The user interface is contained in the bch-dex-ui repository.

Warning: This repository is under active development. Things will be constantly changing and breaking.

Installation

Running the DEX requires composition of these different software packages:

  • bch-dex - This repository is the back end software that tracks trade data on the network, generates Offers and Counter Offers, and finalizes trades by accepting Counter Offers.
  • bch-dex-ui is a Gatsby web app and user interface (UI) for bch-dex.
  • P2WDB is a censorship-resistant database used to communicate trade data between peers running bch-dex.
  • IPFS is a censorship-resistant network for communicating data over the internet.
  • MongoDB is a database used by both P2WDB and bch-dex to store and manage local data.

The above software is orchestrated using Docker and Docker Compose. The target operating system is Ubuntu 20+, and the target hardware is amd64 (normal desktop PCs) and the arm64 (Raspberry Pi 4). Trying to operate this software on other operating systems or hardware is possible, but not supported.

Instructions for setting up Docker and Docker Compose can be found in this Gist. Walk-through videos can also be found on the PSF Videos page.

Building the Docker containers and getting the app working involve these steps:

  • Follow the direction in this Gist to install Node.js, Docker, and Docker Compose.
  • Install dependencies by running npm install
  • Create a wallet by executing the create-wallet.js script with node create-wallet.js
  • Move the wallet.json file to the x86 Docker folder or the RPi Docker folder depending on your hardware target.
  • Change directory to the docker or rpi-docker folder depending on your hardware target.
  • Build the Docker containers with docker-compose build --no-cache.
  • Start the Docker containers with docker-compose up -d
  • Wait for the containers to run for about a minute, then bring them down with docker-compose down. That will create the needed folders in the production/data.
  • Copy the swarm.key into the production/data/go-ipfs/data/. This will allow the IPFS node to connect to the PSF private network.
  • Bring the containers back up with docker-compose up -d.
  • Wait for the P2WDB to sync and populate bch-dex with trade data. You can monitor it with docker logs --tail 20 -f p2wdb.
  • Open a web browser and navigate the http://localhost:4500. You'll be able to see new Offers as they come in and are detected by bch-dex.
  • To take the other side of the trade, click the Take button in the UI.
  • You can add the 12-word mnemonic from the wallet.json file to the the web wallet, which will mirror your wallet in the UI.

License

MIT