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).
To be added soon.
The only supported way to deploy the code actually is using Docker, as the code uses Docker secrets.
To deploy the bot:
- create a bot by chatting with Bot Father and get your bot token
- get Alephium related elements:
- get a fresh mnemonic for the wallet hosting everybody's address. Make sure to not create and new address on this wallet.
- get an address for collecting the operator's fees (if you want some)
- clone this repository
git clone https://github.com/notrustverify/tipALPH
- copy the
.env.example
into.env
file:cp .env.example .env
- 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 - copy your freshly created mnemonic in a file named
bot_mnemonic.txt
in thesecrets
folder - create a new TipAlph docker image with
npm run package
- 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.
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:
- using
npm run start
: will transpile the Typescript into Javacript and use node to execute it - using
npm run dev
: will directly execute the Typescript code usingtsx
- using
npm run watch
: asnpm run dev
but in watch mode (will reload the program if a file changed or ENTER is pressed) - as a docker container (see below)
These are defined in the package.json file.
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
;
We wrote some code to test the alephium client that our bot uses, to ensure that we correctly use it.
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!
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.
The code in this repository (without the dependencies it relies on), is released under the GNU GENERAL PUBLIC LICENSE v3 or later license.