Skip to content
/ bot2 Public

An alternative bot implementation for Nois using Deno instead of Node.js

Notifications You must be signed in to change notification settings

noislabs/bot2

Repository files navigation

Bot 2 (an alternative bot implementation for Nois)

bot2 is doing the same thing that nois-bot is doing as well: fetching random beacons from the drand network and submitting them to the Nois blockchain. See the bot docs to learn more about how the bot fits in the bigger picture.

bot2 written in TypeScript and uses Deno as a runtime. This gives us type-safety and and a more integrated deployment experience.

nois-bot bot2
Language JavaScript TypeScript
Runtime Node.js Deno
CosmWasm client CosmJS 0.29 CosmJS 0.29
Drand client drand-client@0.2.0 drand-client@1.0.0-pre.6
Deployment Docker; source code executed by node source code executed by deno

How to start

  1. Copy config.example.json to config.json and adjust it to your needs
  2. Run deno run --allow-read --allow-net main.ts

Installation

On a Ubuntu server do:

sudo apt update && sudo apt upgrade -y && sudo reboot

# Node is restarting ...

sudo apt install -y git htop joe jq unzip

# Install deno
curl -fsSL https://deno.land/x/install/install.sh | sh
echo 'export DENO_INSTALL="$HOME/.deno"' >> ~/.profile
echo 'export PATH="$DENO_INSTALL/bin:$PATH"' >> ~/.profile
logout

# Login again
deno --version

git clone https://github.com/noislabs/bot2.git \
  && cd bot2

That's it. Move on with "How to start".

Upgrading

  1. In the bot2 checkout run git pull.
  2. Check if your config.json has all the fields from config.example.json and adapt if necessary.

Run with PM2

Run bot in the background using PM2.

Install Deno as written above, then install NodeJS and PM2:

wget -O nodejs.deb https://deb.nodesource.com/node_16.x/pool/main/n/nodejs/nodejs_16.17.1-deb-1nodesource1_amd64.deb \
  && sudo dpkg -i nodejs.deb \
  && npm install pm2 -g \
  && cd $HOME/bot2

Run bot:

pm2 start main.ts --interpreter="deno" --interpreter-args="run --allow-read --allow-net"

Useful commands:

#show logs
pm2 logs --lines 100

#restart
pm2 restart main

#restart and show logs
pm2 restart main && pm2 logs --lines 100

#stop bot
pm2 stop main

Run in Docker

Make sure you have

  • config.json file in your current directory
  • Docker installed and running

Update to latest version:

docker pull --platform linux/amd64 noislabs/nois-bot:nextgen

Start:

docker run \
  -v "$PWD/config.json":/app/config.json \
  noislabs/nois-bot:nextgen

About

An alternative bot implementation for Nois using Deno instead of Node.js

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published