This project is a governance bot designed to interact with Cosmos blockchain and Slack, providing users the facility to vote on blockchain proposals directly from Slack. It is especially beneficial for teams and individuals who want to streamline their voting process within a familiar environment.
The Cosmos Governance Slack Bot allows specified Slack users to fetch and vote on proposals from different Cosmos SDK versions. It integrates the CosmJS library for blockchain interactions and axios for HTTP requests, creating a seamless bridge between Cosmos blockchain and Slack.
- Clone the Repository
git clone https://github.com/yourusername/projectname.git
- Install Dependencies
cd projectname yarn install # or npm install
- Setup Environment Variables
Copy
.env.example
to.env
and fill in the actual values.cp .env.example .env nano .env # use any text editor to edit the file
- Setup PostgreSQL Database
Setup a PostgreSQL database and update the
.env
file with the database credentials.
If you have Docker installed, you can use it to run the application in a container. This will handle the database setup and manage the application dependencies for you.
- Build Docker Image
docker build -t cosmos-bot .
- Run Docker Container
docker run -d --name cosmos-bot -p 3000:3000 cosmos-bot
You can use pm2
to run the application in the background as a daemon.
- Install PM2
npm install pm2 -g
- Start Application with PM2
pm2 start npm --name "cosmos-bot" -- start
-
SLACK_BOT_TOKEN
: This token is used to authenticate the bot with Slack. It usually starts withxoxb-
. -
SLACK_APP_TOKEN
: This token is used to authenticate the app installation user within Slack. It usually starts withxapp-
. -
SLACK_SIGNING_SECRET
: This secret is used to verify that HTTP requests sent to your app's endpoints are from Slack. -
SLACK_CHANNEL_ID
: This is the ID of the Slack channel where the bot is intended to post messages. -
SLACK_ALLOWED_VOTE_USERS
: This is a comma-separated list of user IDs allowed to vote. -
PROPOSAL_SCAN_FREQUENCY
: Determines how often the bot should scan for new proposals. It's written in cron format. -
OPENAI_API_KEY
: This key is used to authenticate with the OpenAI service. It usually starts withsk-
. -
VOTING_WALLET_MNEMONIC
: This mnemonic is used for generating voting wallet keys. Replace the placeholder with the actual mnemonic. -
POSTGRES_USER
: The username for the PostgreSQL database. -
POSTGRES_PASSWORD
: The password for the PostgreSQL database. -
POSTGRES_DB
: The name of the PostgreSQL database.
Refer to Slack’s official documentation to generate the necessary Slack tokens and to obtain the signing secret. Remember to never share or expose these tokens, as they can be used to gain access to your Slack workspace.
This section will guide you through setting up Authz for the voting wallet.
Authz enables one account, the granter, to grant another account, the grantee, permissions to execute messages on its behalf.
Granter gives permission to the grantee by creating an authorization using MsgGrant.
gaiad tx authz grant [grantee_address] generic --from [granter_key_name] --msg-type /cosmos.gov.v1beta1.MsgVote
Revoke Permission: Granter can revoke the authorization granted using MsgRevoke.
gaiad tx authz revoke [granter_addr] /cosmos.gov.v1beta1.MsgVote --from [granter_key_name]
To contribute to this project, please create a fork of the repository, make your changes and submit a pull request. Ensure that your code adheres to the existing style and all tests are passing.
For any additional information or queries, feel free to contact us.