Publishing an order
This page is part of the typescript tutorial for creating your first COMIT-app, that builds two simple command-line application using the COMIT protocol to execute a Bitcoin to Ethereum atomic swap locally on your machine.
info
In this section we focus on the maker side and work on maker.ts
In this section we create and publish an order that a taker can then fetch from the maker's order HTTP API.
Maker creates an Order
Let's create an Order
of 50 ether for 1 bitcoin, meaning that the maker is offering 50 ether and is asking for 1 bitcoin:
Maker publishes the Order
The MakerNegotiator
allows us to publish an Order
:
And finally we "tell" the world that we have an order available:
Your COMIt-app could publish this link on a forum or social media so takers can connect to you.
Waiting for a taker
When a taker takes the order created by the maker, it will trigger the swap execution right away. The maker thus has to wait for a taker to take the order to commence with the execution.
In this tutorial the maker is waiting for 10 minutes for a potential taker to taker his order.
The maker uses the ComitClient
to wait for incoming swaps.
Once the taker takes the order he will trigger a swap request in his cnd that will be detected by the maker's cnd.
Summary
At this stage your maker application should look similar to this:
When running yarn maker
it prints:
The maker app is now capable for waiting for a taker to initiate the swap for execution. The order is published and a taker can retrieve it, take it and by doing so start the swap execution.
However, the maker does not execute an incoming swap properly yet. Let's add that in the next section before we move on the taker side.