Version: 0.14.1

comit-sdk - v0.14.1


COMIT is an open protocol facilitating cross-blockchain applications. For example, with COMIT you can exchange Bitcoin for Ether or any ERC20 token directly with another person.

This repository contains the Javascript software development kit (SDK) that wraps the communication with the comit-network daemon.

If you wish to do an atomic swap on your machine or to integrate COMIT into an application (e.g. a DEX) please take a look at the Getting Started section of the COMIT documentation. If you have any questions, feel free to reach out to the team in our Gitter chat!

License Gitter chat

COMIT Javascript SDK

The COMIT Javascript SDK enables the integration of the comit-network daemon into Javascript applications. You'll find the latest comit-sdk version on npmjs.

Below you find a short introduction into the SDK. For more detailed information please refer to the API-documentation in our documentation.

Getting started

The fastest way to get started with the SDK is to take a look at examples using the SDK.

Create a project using create-comit-app and take a look at the generated examples folder!

SDK Overview

The SDK enables you to create Javascript applications on top of COMIT. This can for example be a trustless decentralized exchange (DEX) or a multi-currency wallet.

The SDK offers functionality to negotiate a trade and to execute the trade after the negotiation is finished.

Trade Negotiation vs. Execution

The SDK integrates a simple negotiation protocol that serves as a starting point for makers and takers to create and take orders.

It is recommended to take a look at the TakerNegotiator and MakerNegotiator classes to get started.

The negotiation is currently only integrated into the SDK and does not concern the comit-network daemon (cnd). cnd is only used for executing the trade, i.e. preparing transactions necessary for executing the atomic swap and monitoring the respective ledgers of the swap.

For the execution you can use the SDK for communicating with cnd. Take a look at the ComitClient class to get started. The ComitClient enables you to:

  1. Initiate a swap with another party.
  2. Receive the fund action from cnd when available.
  3. Send the fund transaction to a wallet.
  4. Receive the redeem transaction from cnd when available.
  5. Send the redeem transaction to a wallet.

(For a refund scenario you would of course be able to receive and send the refund transaction as well.)

Wallets

The SDK includes two Javascript wallets:

These wallets are used to actually send the transactions necessary for the atomic swap to the respective ledger. COMIT is designed in a non-custodial way, thus cnd never holds your private key at any time. The wallets integrated in the SDK show how the transaction information received from cnd can be sent to the respective ledger. Note that you can, of course, use different wallets than the above default wallets in your application.