notrustverify / tipALPH

A tipping bot for the Alephium blockchain. Developed by No Trust Verify
https://t.me/tipALPHBot
GNU General Public License v3.0
2 stars 2 forks source link
alephium bot telegram-bot tipping

TipAlph

This repository hosts the code of @TipAlphBot, a bot that allows you to send and receive Alephium with Telegram!
This project was developed as part of the Alephium Hackathon.

This project uses Node lts/hydrogen (v18.19.0) and NPM (v10.2.3).

Dependencies

To be added soon.

How to deploy

The only supported way to deploy the code actually is using Docker, as the code uses Docker secrets.
To deploy the bot:

  1. create a bot by chatting with Bot Father and get your bot token
  2. get Alephium related elements:
    1. get a fresh mnemonic for the wallet hosting everybody's address. Make sure to not create and new address on this wallet.
    2. get an address for collecting the operator's fees (if you want some)
  3. clone this repository git clone https://github.com/notrustverify/tipALPH
  4. copy the .env.example into .env file: cp .env.example .env
  5. change the variable in the .env file according to your setup (fullnode address, …) and insert the bot token and the address for fees in the .env file
  6. copy your freshly created mnemonic in a file named bot_mnemonic.txt in the secrets folder
  7. create a new TipAlph docker image with npm run package
  8. run docker compose --profile tipalph up -d to run the fresh docker image.

On the logs (with docker compose --profile tipalph logs -f), you should see a successful connection to the database as well as a ready and synced NodeProvider.
The telegram bot should now be available.

How to develop

To work on the bot, we suggest to use the devnet. It allows for faster testing and better testing conditions (easier generation of tokens).
Follow the same procedure as for deployment, but specify a fullnode on the testnet and "NETWORK=testnet" in the .env file. The provided fees collection address and mnemonic for the wallets should also be on the testnet. We would advise you to use a different database as well, if you previously deployed on a database.

There is multiple way of running the code application:

These are defined in the package.json file.

How to test

Before running the test suite, you need to have a fullnode on the devnet accessible to http://127.0.0.1:22973.
The easiest way to do it is to start a docker container before running the test suite. This can be simply archived by running: docker compose --profile test up -d and waiting some seconds.

Tests can be run using npm run test.

To add coverage, edit the jest.config.cjs file and set collectCoverage to true;

Alephium side

We wrote some code to test the alephium client that our bot uses, to ensure that we correctly use it.

Telegram side

It seems to be really complicated to test Telegram bots (integration tests, by sending Telegram messages). If you know how to do it, please reach out to us or do a PR!

Building the docker container

We provide a Dockerfile to build the container. The easiest way to build a new image is by running the npm run package commands, which takes care of settings the appropriate tags for you.

To create a docker container from the freshly built image, we recommend using the provided docker-compose.yml file with the required configuration. Once you provided the required dependencies, simply do a docker compose --profile tipalph up to spin a new container.

License

The code in this repository (without the dependencies it relies on), is released under the GNU GENERAL PUBLIC LICENSE v3 or later license.