This project is a decentralized autonomous organization (DAO) voting platform built using FastAPI, Web3.py, and LangChain. It allows users to create proposals, vote on them, and interact with the DAO through a conversational AI assistant.
- Create Proposals: Submit new proposals for the DAO.
- Vote on Proposals: Cast votes on existing proposals.
- View Proposals: Retrieve all proposals and their details.
- Check Balance: View user balances in Ether.
- Voting History: Check the voting history for a specific address.
- Proposal Analysis: Analyze proposals for clarity and potential impact using an AI assistant.
- AI Assistant: Chat with an AI assistant for DAO-related queries.
/dao-voting-agent
│
├── main.py # Main application entry point, initializes FastAPI app and includes endpoints for interacting with the DAO
/dao-voting-agent/src
├── models.py # Pydantic models for request and response schemas
├── utils.py # utility codes
└── agent.py # Logic for analyzing proposals and chatting with users
- FastAPI: A modern web framework for building APIs with Python 3.6+ based on standard Python type hints.
- Web3.py: A Python library for interacting with the Ethereum blockchain.
- LangChain: A framework for developing applications powered by language models.
git clone https://github.com/okoliechykwuka/dao-voting-agent.git
cd dao-voting-agent-
Python 3.9+
-
Node.js and npm (optional, for testing contracts)
-
A custom blockchain endpoint
-
OpenAI API Key
Make sure you have Python 3.10+ installed, then create a virtual environment and install the required packages:
python -m venv venv
source venv/bin/activate # On Windows use `venv\Scripts\activate`
pip install -r requirements.txtUpdate the CONTRACT_ABI in endpoints.py with your smart contract's ABI. Ensure the following are correctly set to connect to your Ethereum network:
WEB3_PROVIDERCONTRACT_ADDRESSCHAIN_ID
Start the FastAPI application using Uvicorn:
uvicorn main:app --reloadOpen your browser and navigate to:
- Swagger UI: http://127.0.0.1:8000/docs
Request:
POST /proposals
Body:
{
"title": "Proposal Title",
"description": "Proposal Description",
"private_key": "your_private_key"
}Request:
POST /vote
Body:
{
"proposal_id": 1,
"private_key": "your_private_key"
}Request:
GET /proposals
Request:
GET /proposals/{proposal_id}
Request:
GET /balance/{address}
Request:
GET /vote_history/{address}
Request:
POST /chat
Body:
{
"message": "What is the current status of proposals?",
"user_address": "0xYourEthereumAddress"
}Request:
POST /analyze_proposal
Body:
{
"title": "Proposal Title",
"description": "Proposal Description"
}