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.
This section of the tutorial shows how to initialise the actors of the trade, the maker and the taker, with the pre-funded accounts of the dev-environment.
In this section we use the Actor interface of the comit-sdk to initialise the maker and taker actors.
We will use the Bitcoin and Ethereum accounts created through start-env for initialising the actors.
Through the actor we have access to the wallets and the ComitClient which is used as a wrapper for the communication with cnd.
In this section we focus on the maker side and work on maker.ts
The dependencies to be added are not listed in the code examples. You can check the bottom or this section if you have trouble with imports.
Let's focus on the maker for the beginning.
start-env has provided us with two Bitcoin and two Ethereum accounts indexed with 0 and 1.
Let's use the Bitcoin and Ethereum account indexed with 0 for the maker.
From the index.js file we already know how to load the environment using the dotenv package. Let's initialise the maker's environment using the same code:
Because COMIT is a non custodial protocol, the maker needs a Bitcoin and an Ethreum wallet to send transactions into the respective network.
In this tutorial we use the Bitcoin and Ethereum wallet provided by the comit-sdk.
In this section we focus on the taker side and work on taker.ts
For the taker we have a similar setup as for the maker.
Similar to the maker we have to initialise a Bitcoin and Ethereum wallet with the accounts from the environment.
As for the maker we can then create the actor using the comit-sdk's createActor function.
Note that we will use the Bitcoin and Ethereum account as well as the cnd instance with index 1 for the taker.
In the end our taker.ts file should look like this: