Skip to main content

Off-Chain Execution Bots

Run an Ergo node

The bots require access to an Ergo node, so if you do not have one yet install as instructed here: Ergo GitHub.

caution

Public node usage makes your chances of winning transaction executions very low! So deploy your own node!

In addition to the node, the bots rely on tools like Kafka and Redis to function. To simplify the process of building and running the bots, a docker-based solution has been developed. Apart from the node, the only prerequisites are the installation of the following:

Build off-chain bots

First, you need to download the code from this repo. The easiest way to keep it updated in the future is by using git:

cd <the folder you want to keep the off-chain bots code in>
git clone https://github.com/spectrum-finance/ergo-dex-backend.git

All instructions for the containers are specified in the docker-compose.yml file. To run the bots, only configuration settings stored in a file called config.env are needed. An example of this file can be found in config-example.env. To get started, make a copy of the example file, rename it as config.env, and edit the file to reflect your specific values:

Linux and macOS:

cd ergo-dex-backend
cp ./config-example.env ./config.env

Windows:

cd ergo-dex-backend
copy ./config-example.env ./config.env

There are two values that require modification in the config.env file. The first value is the mnemonic, which will be used by the bot to create a wallet for receiving fees and paying miner fees (in SPF fee cases). The Generate seed phrase for bots section can help you generate the appropriate address for this purpose. The second value that needs to be updated is the URI of your node. It's worth noting that localhost/127.0.0.1 may not be accessible from within a docker container, so it's best to use the local LAN IP if the node is running on the same host.

Run off-chain bots

After creating the config.env file, ensure that you have sufficient funds on the anticipated address. You can refer to the section titled Generate seed phrase for bots to locate the appropriate address. Finally, the only remaining step is to launch the containers:

Linux and macOS:

sudo -E docker-compose up -d

Windows:

docker-compose up -d

Check off-chain bots

You can examine their logs to confirm that the bots are running correctly. To view a consolidated log for all bots, use the following command:

Linux and macOS:

cd ergo-dex-backend
sudo docker-compose logs -f

Windows:

cd ergo-dex-backend
docker-compose logs -f

Update off-chain bots

caution

After running the git pull command from the instructions below, make sure to check for potential changes in config-example.env to apply to your own config.env

Linux and macOS:

git pull
sudo -E docker-compose pull
sudo -E docker-compose up -d

Windows:

git pull
docker-compose pull
docker-compose up -d

Generate seed phrase for bots

info
  1. The term seed phrase is the same as a mnemonic key or mnemonic phrase.
  2. It's impossible to generate a seed phrase from your address.
  3. Without a seed phrase, you cannot use the address to receive crypto funds.
  4. You can only use the address generated by bots using the seed phrase you provided through EIP3.
  5. Remember to save the seed phrase for each of your wallets.
  6. It's advisable to create a new wallet specifically for bots instead of using your regular one.
  7. Bots can only access funds from the first address generated from the provided seed phrase using eip3 standard.
  8. It's essential to have all your funds in one address box (ERGs for miner fees), or bots' behavior may be unpredictable.

I don't have seed phrase

danger

IT IS RECOMMENDED TO STORE YOUR SEED PHRASE SECURELY, SUCH AS BY WRITING IT DOWN AND AVOIDING ANY FORM OF DIGITAL STORAGE. IF YOU HAPPEN TO LOSE IT, THERE IS NO OTHER WAY TO RESTORE IT.

  1. Generate a new unique seed phrase via wallet ( e.g. nautilus - just create a new wallet and save seed phrase) or run HowTo.scala, check line Seed phrase is: and save seed phrase (24 words) from stdout.
  2. Deposit funds to exactly the address you see in Address is: line in stdout.
  3. Put your seed phrase into the config.env file and run bots.

I have seed phrase

danger

DON'T USE YOUR REGULAR HOT WALLET, ALWAYS GENERATE NEW ONE TO RUN OFF-CHAIN BOTS

  1. It is important to make sure that you have sufficient funds on the same address that the bot will use. The bot will always utilize the first address from your wallet, which is generated using EIP3. To verify this, you can open the HowTo.scala file, enter your seed phrase into the val seedPhrase variable, and run the script.
  2. Check the address printed in the output. If the address matches the one that holds the required funds, then you can use this seed phrase for the bots. Otherwise, you should transfer your funds to the required address as displayed in the script's output.
  3. After putting your seed phrase into the config file, you can run the bots.