We have developed Link, a Discord bot that connects with the Chainbase Network. It's an open-source project that anyone can use.
Chainbase Data Platform is an all-in-one data infrastructure for Web3 that allows you to index, transform, and utilize large-scale on-chain data. It provides a suite of tools and services to help you build, manage, and scale your Web3 applications. By leveraging enriched on-chain data and streaming computing technologies across one data infrastructure, Chainbase Data Platform automates the indexing and querying of blockchain data, enabling developers to accomplish complex data tasks with ease.
For more details, refer to the Chainbase API Documentation.
Link bot allows you to interact with blockchain data using a set of powerful commands:
- /sql: Execute the SQL query to show up to 4 columns and 20 rows.
- /sql_excel: Execute the SQL query and get the result in an Excel file.
- /get_block_by_number: Fetch block details by block number and chain ID.
- /get_transaction: Get the details of a transaction given the transaction hash.
- /get_native_token_balance: Get the native token balance for a specified address.
- /get_token_metadata: Get the metadata of a specified token.
- /get_token_price: Get the price of a specified token.
- /get_nft_metadata: Get the metadata associated with the specified NFT.
- /get_domain_metadata: Resolve an ENS domain to its associated address.
- /help: Provides information about available commands.
Clone this repository to your local machine:
git clone https://github.com/HarbhagwanDhaliwal/Link.git
cd Link
You will need API key and Discord Token to run this bot:
-
Chainbase API Key: Used to fetch data from Chainbase.
-
Discord Token: Required to interact with Discord.
Set up the following environment variables in your system:
export DISCORD_BOT_TOKEN=your_discord_bot_token
export CHAINBASE_SQL_BASE_URL=https://api.chainbase.com/api/v1
export CHAINBASE_WEB3_BASE_URL=https://api.chainbase.online/v1
export CHAINBASE_API_KEY=your_chainbase_api_key
export FLOCK_AUTH_TOKEN=your_flock_model_api_key
You can obtain the Chainbase API key from the Chainbase console. For the Discord bot token, create a Discord application and generate the token from there.
Install the required Python dependencies using the requirements.txt
file:
pip install -r requirements.txt
After setting up the environment variables and installing dependencies, run the bot using:
python3 main.py
To ensure that your Python script (main.py
) runs continuously as a system service, follow the steps below:
Create a new service file for your project by running the following command:
sudo nano /etc/systemd/system/my_discord_bot.service
Add the following content to the file:
[Unit]
Description=Link Discord Bot Service
After=network.target
[Service]
Type=simple
User=root
WorkingDirectory=/root/Link
ExecStart=/usr/bin/python3 /root/Link/main.py
Environment="DISCORD_BOT_TOKEN=your_discord_bot_token"
Environment="CHAINBASE_SQL_BASE_URL=https://api.chainbase.com/api/v1"
Environment="CHAINBASE_WEB3_BASE_URL=https://api.chainbase.online/v1"
Environment="CHAINBASE_API_KEY=your_chainbase_api_key"
Restart=on-failure
[Install]
WantedBy=multi-user.target
Replace root
with your Ubuntu username.
Replace /root/Link
with the actual path to your project directory.
sudo systemctl daemon-reload
sudo systemctl start my_discord_bot.service
sudo systemctl enable my_discord_bot.service
sudo systemctl status my_discord_bot.service
This project was developed by Harbhagwan Dhaliwal (also known as Manpreet). Feel free to reach out or contribute to the project via GitHub.
GitHub Repository: Link