Sambot

This is an installation and setup guide for Sambot on macOS - a self hosted Telegram bot for fast swaps on ETH via Uniswap routing smart contracts.

This guide requires some level of entry technical knowledge, however, if the guide is followed closely, the installation may be replicated.

Minimum Requirements:

- macOS or Linux based 64 bit operating system

- 4 GB RAM minimum

- Intel Core i5 or equivalent quad core processor

Installation pre-requisites

Before we setup Sambot, we have to install the necessary pre-requisites which the bot needs in order to successfully start. You may skip some of these steps, if you already have the pre-requisites installed.

PostgreSQL

This is a SQL database, which Sambot uses to store user information & related trades data. As Sambot is self-hosted, you will own all of the stored data and its contents are never synchronized outside of your self-hosting container.

1. There are several ways to install PostgreSQL 16, however we recommend using the installer from the EDB website: https://www.enterprisedb.com/downloads/postgres-postgresql-downloads. Choose your operating system and proceed with the PostgreSQL installation.

2. (Optional) This is an optional step, however this tutorial will refer to it often. If you are an advanced user, you may skip this step. To interact with PostgreSQL, we can use pgAdmin which is a PostgreSQL management tool. This will allows us to create new databases, manage tables as well as view any of the stored data using a Graphical User Interface. The tool should be included if you used the EDB installation package, however if it is not available for some reason then you may install pgAdmin using the official link: https://www.pgadmin.org/

Now that we have the database and pgAdmin, we can start creating a local database. Note: if you are planning to self-host on a server then we recommend hosting your PostgreSQL in a separate server container.

1. Initiate PostgreSQL after installation in a previous step by searching for Postgres.app on macOS and running it

2. Initiate pgAdmin and proceed with the initial setup instructions

3. In pgAdmin, on the left panel, you should have a list of servers.

1. Right click on servers and register a new server.

2. Under the General tab, you may name the new server however you want.

3. Under the Connection tab, you will fill out the following information:

1. host: localhost

2. port: 5432

3. maintenance database: postgres

4. username: postgres

5. You may leave other fields blank as this is a self-hosting tutorial on your local machine. However, we do recommend setting up a password as well for any server based setup.

6. Click on Save

4. Unpack the new server you created on the left panel and create a new database under "Databases"

1. Right click on Databases and click on "Create"

2. Under the General tab, fill in "sambot_local" as the database name

3. Click on Save

5. Now you should have a new local server, which contains a new database called "sambot_local" on port 5432 if you have followed the instructions above.

Redis

Redis is another database used by Sambot to improve performance and the concurrency of operations that the bot can perform. This makes it not only ideal for personal single user usage, but also for whitelabeling and hosting the bot under your own platform.

1. To install Redis on macOS, you should ideally follow this official guide: https://redis.io/docs/latest/operate/oss_and_stack/install/install-redis/install-redis-on-mac-os/

2. All settings will be left on the default values for the sake of this tutorial. Again, if you are hosting on a server setup as an advanced user, you should ideally take measures to set up Redis using proper security measures that the Redis configuration offers.

3. Ensure that Redis runs after successfully installing it

Telegram

To operate the bot, we will need to setup the bot instance on Telegram and register it with the Telegram API. To do this, follow these steps:

1. Visit @BotFather on Telegram. This is an official Telegram bot management tool.

2. Using the menu button (Create a new bot) or text command (/newbot), create a new bot

3. Follow the BotFather setup guide and provide the bot name

4. Choose a username for your bot

5. BotFather will return an HTTP API token. This is very important and will be needed in the next step.

6. You may customize your bot's brand and add a description or a profile picture to make it your own.

Sambot Setup

Now that we have all the pre-requisites installed, we can dive into the bot setup itself.

1. Visit sambot.samurai.financial and scroll to the bottom of the website to initiate a download for your chosen platform. If you cannot see any download buttons, you will want to either switch to the same wallet that purchased the on-chain license or you haven't purchased your licensed yet.

2. You will have to sign a message (this does not cost any FTM tokens and is completely free) using the same wallet that purchased the license. This cryptographically signed message is verified to ensure that the wallet truly owns an on-chain license before issuing a download.

3. Once you have the downloaded zip file on your chosen platform, unzip it into a folder.

4. Open the folder, and you will see 2 files.

1. sambot-macos or sambot-linux (depending on your platform)

2. env.example

5. Using a Text Editor, open the env.example. You should see the following text:

```

NODE_ENV=production

PORT=3000

DATABASE_URL=postgres://postgres@localhost:5432/sambot_local

REDIS_HOST=localhost

REDIS_PORT=6379

TG_TOKEN=

ENCRYPTION_KEY=please-dont-forget-to-change-me-to-something-else

RPC_URL=https://eth.llamarpc.com

MEV_RPC_URL=https://rpc.mevblocker.io/

UNI_ROUTER=0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45

CHAIN_ID=1

SSL=FALSE

BE_URL=

```

6. Paste the Telegram HTTP API token that you received from BotFather right next to the equals sign on the TG_TOKEN line. (`e.g. TG_TOKEN=7044123890:AAh...`)

7. Change the ENCRYPTION_KEY to any arbitrary value (`e.g. ENCRYPTION_KEY=black-coffee-22`).

8. Ensure that you use values which are your own and do not reveal any API tokens or values in your configuration settings.

9. (Optional) if you are an advanced user, you may utilise Telegram Bot Webhooks by filling out the BE_URL value with the value of your domain (`e.g. BE_URL=https://amazingbotcompany.com`)

10. (Optional) if you have your own RPC nodes (such as the ones obtained from purchasing HONOUR NODES) you may use them in the configuration under the RPC_URL key. Otherwise if you prefer any other MEV blocking RPC URLs, you may replace the MEV_RPC_URL. Doing so could significantly improve the bot's performance for both values.

11. Save the env.example file using your text editor

12. Rename the `env.example` file to `.env`. On macOS, any files which begin with a dot are automatically hidden. To unhide these files, press **Command + Shift + Dot**.

13. Double click on sambot-macos or sambot-linux and a terminal window should appear.

14. If all values are green, then you have managed to successfully setup Sambot and may begin using it via the Telegram interface on your bot's handle.

In case of needed troubleshooting, you may reach out via Discord for further technical help.

Last updated