This documentation section shows an overview of how to setup a COMIT-app for development. The tools around the COMIT protocol are listed and the interaction between them is shown.
A swap is executed between two parties. We call them a maker and a taker. While the former one creates orders and makes them available, the latter one can take these orders and initiate the swap execution.
Each party runs its own cnd. Typically those two instances would run separately on different machines. For the development environment they are typically started on the same machine. The two cnd nodes communicate via the COMIT communication protocols for exchanging swap parameters prior to executing the swap. Cnd offers a REST API for executing the cryptographic protocols.
For your local dev setup you will need the following components:
- Two cnd nodes; one for each party of the trade.
- The respective blockchain nodes for the swap. If you are swapping bitcoin for ether you need a Bitcoin and Ethereum node.
- Wallets, corresponding to the ledgers, to send transactions. If you are swapping bitcoin for ether you need a Bitcoin and Ethereum wallet.
You can use comit-scripts to start up a development environment based on docker containers.
The COMIT-app holds all the components together and offers an interface for swap negotiation and execution to the user. A COMIT-app typically includes some mechanism to find trading partners and manage orders because cnd does not support negotiation protocols yet.
This slide shows an overview of the components and their interaction.
create-comit-app is a project to help COMIT App developers setup an environment.
create-comit-app allows you to create a template COMIT App which includes working examples.
To create your template app in the
my-app directory, just do:
Let's have a look at what we have here:
.is where you can start writing your app, see write your app tuto
./package.jsoncontains some useful dependencies for your app
./examplescontains projects that are made to inspire developers such as yourself to build their app
./demoscontains projects which are catered for workshops demonstration. They do not have a conventional structure but have verbose output.
comit-scripts package helps you run a development environment to build a COMIT App.
When creating an application with create-comit-app (
yarn create comit-app my-app) it is part of the setup.
Let's install it from the template folder to play with it.
package.json of create-comit-app template includes the
start-env command of
start-env the development environemnt is started:
The second command
force-clean-env can be used if the environment unexpectedly crashed and some containers were not removed.
Usually you will not need this command, as Shutdown will properly clean up the containers.
Creating Docker network (create-comit-app)...✓
Creates a docker network to allow several docker containers to communicate with each others. The network is named
Starting Ethereum node...✓
- Starts a parity node in a docker container,
- Deploys an ERC20 token contract
- Creates two accounts,
- Funds each account with 1000 Ethers and 100 ERC20 tokens.
Starting Bitcoin node...✓
- Starts a bitcoind node in a docker container,
- Creates two HD wallet,
- Funds each wallet with 10 Bitcoin,
- Mines a new block every second.
Starting two cnds...✓
Starts 2 cnd (COMIT Network Daemon) in docker containers.
Let's take a break and check out what containers are now running:
Indeed we have bitcoind, parity and 2 cnds running.
Writing configuration in env file...✓
Writes useful information to
Let's have a look at this
env file in more details:
We have here the private keys of the funded accounts on Ethereum and Bitcoin and the endpoint to the various services. This can be used to be imported in my-app so that you can test it with funded accounts.
You may have noticed that you are getting 2 Bitcoin wallet, 2 Ethereum accounts and 2 cnd instances out of
This is simply due to the fact that one cannot do an atomic swap by themselves!
Atomic swap are inherently peer-to-peer.
One can only sell Bitcoin for Ether if someone else buys Bitcoin For Ether.
As you need two parties to do a swap,
start-env gives you an environment for both parties.
To stop the environment, just hit
CTRL+C and wait few seconds:
This section of the documentation is still under construction. Stay tuned for more content!