Free 30-min Web3 Consultation
Book Consultation
Smart Contract Security Audits
View Audit Services
Custom DeFi Protocol Development
Explore DeFi
Full-Stack Web3 dApp Development
View App Services
Free 30-min Web3 Consultation
Book Consultation
Smart Contract Security Audits
View Audit Services
Custom DeFi Protocol Development
Explore DeFi
Full-Stack Web3 dApp Development
View App Services
Free 30-min Web3 Consultation
Book Consultation
Smart Contract Security Audits
View Audit Services
Custom DeFi Protocol Development
Explore DeFi
Full-Stack Web3 dApp Development
View App Services
Free 30-min Web3 Consultation
Book Consultation
Smart Contract Security Audits
View Audit Services
Custom DeFi Protocol Development
Explore DeFi
Full-Stack Web3 dApp Development
View App Services
LABS
Guides

Setting Up Governance Proposal Sentiment Analysis

This guide provides a technical walkthrough for extracting proposal text, applying NLP models to gauge community sentiment, and correlating it with on-chain voting patterns to predict governance outcomes.
Chainscore © 2026
introduction
GOVERNANCE ANALYTICS

Introduction

A practical guide to building a system that analyzes sentiment and voter behavior for on-chain governance proposals.

On-chain governance is the mechanism by which decentralized protocols like Compound, Uniswap, and Aave evolve. Token holders submit, debate, and vote on proposals that can alter critical parameters, allocate treasury funds, or upgrade smart contract logic. However, raw voting data—simple For/Against/Abstain tallies—often fails to capture the nuanced community sentiment and the strategic behavior of large voters, known as whales. This guide provides a technical framework for moving beyond basic vote counts to perform meaningful sentiment analysis.

We will build a system that aggregates and analyzes governance data from multiple sources. The core data pipeline involves querying subgraphs (like The Graph) for on-chain voting events and fetching related discussion from forum platforms (such as Commonwealth or Discourse). By correlating a voter's on-chain actions with their off-chain commentary, we can classify sentiment more accurately than vote direction alone. For example, a voter might vote For a proposal while expressing strong reservations in the forum, indicating weak rather than strong support.

The technical stack for this tutorial is flexible but will primarily utilize Python for data processing and SQL for storage and querying. We'll use libraries like pandas for data manipulation and textblob or VADER for performing Natural Language Processing (NLP) on forum posts. The goal is to create a repeatable pipeline that ingests data, applies analysis, and outputs metrics like sentiment scores, voter cohesion, and whale influence tracking. All code examples will be functional and based on real protocol subgraph endpoints.

Understanding governance sentiment is critical for several reasons. It helps protocol developers gauge true community alignment beyond simple majority votes. Delegates and voters can use these insights to make more informed decisions. Furthermore, analyzing historical voting patterns can reveal if a protocol is trending toward voter apathy or increased centralization of voting power. This analysis forms a foundational tool for assessing the long-term health and decentralization of any DAO.

By the end of this guide, you will have a working script that, for a given proposal ID, can: 1) Fetch all votes and voter addresses from a subgraph, 2) Retrieve and analyze the corresponding forum discussion, 3) Calculate a composite sentiment score, and 4) Generate a simple report highlighting key voters and discussion themes. This builds a scalable base for more advanced analytics like predicting proposal outcomes or modeling voter networks.

prerequisites
SETUP GUIDE

Prerequisites

Before analyzing governance proposal sentiment, you need a foundational environment with the right tools and data sources. This guide covers the essential setup.

To build a governance sentiment analysis system, you need a development environment with Node.js (v18 or later) and a package manager like npm or yarn. You will also require a blockchain RPC provider to fetch on-chain proposal data. For major DAOs like Uniswap or Compound, you can use services like Alchemy, Infura, or a public RPC endpoint. Install core libraries: ethers.js or viem for blockchain interaction and axios or fetch for API calls to indexers like The Graph or Tally.

The second prerequisite is access to the governance data itself. You need the smart contract addresses for the DAO's governance module (e.g., GovernorBravo) and its associated token. For off-chain discussion data, you'll need API keys for platforms like Discord (for bot access), Commonwealth, or Snapshot (for fetching proposal descriptions and votes). Store these keys securely using environment variables in a .env file.

Finally, set up a basic project structure. Initialize a new project and create modules for data fetching, processing, and analysis. A typical structure includes: a src/fetchers/ directory for on-chain and API clients, a src/processors/ directory for cleaning and structuring text data (e.g., proposal descriptions, forum posts), and a src/analysis/ directory for your sentiment logic. This modular approach separates concerns and makes your codebase maintainable.

data-extraction
DATA COLLECTION

Step 1: Extracting Proposal and Discussion Data

The foundation of any governance sentiment analysis is a robust dataset. This step details how to programmatically collect raw proposal metadata and the associated community discussions from platforms like Snapshot and Discord.

Governance sentiment analysis begins with data extraction. You need to gather two primary data types: proposal metadata and discussion text. Proposal metadata includes the title, description, voting options, and results, typically sourced from on-chain governance modules (e.g., Compound Governor) or off-chain platforms like Snapshot. The discussion data consists of the community discourse from forums such as Discourse, Commonwealth, or messaging platforms like Discord and Telegram. This raw data forms the corpus for your analysis.

To extract data from Snapshot, you can use its GraphQL API. A common starting point is to query proposals for a specific space (DAO). The following Python example uses the gql and aiohttp libraries to fetch recent proposals. You'll need the space's ENS name (e.g., ens:uniswap.eth) and can filter by state or date. The API returns structured JSON containing the proposal's core information, voter list, and scores.

python
from gql import gql, Client
from gql.transport.aiohttp import AIOHTTPTransport

# Set up the Snapshot Hub transport
snapshot_transport = AIOHTTPTransport(url="https://hub.snapshot.org/graphql")
client = Client(transport=snapshot_transport, fetch_schema_from_transport=True)

# Define the query to get proposals for a space
query = gql("""
    query {
      proposals(
        first: 20,
        skip: 0,
        where: { space_in: ["ens:uniswap.eth"], state: "closed" }
      ) {
        id
        title
        body
        choices
        scores
        votes
      }
    }
""")

result = client.execute(query)

Collecting discussion data is more complex due to fragmented sources. For Discord, you must use its API and manage rate limits. A practical approach is to use a library like discord.py to access a specific channel's message history. Remember to respect API terms, implement pagination, and filter for relevant threads. For forum-based platforms, check for a public API or consider web scraping (with respect to robots.txt). Always store the extracted data with timestamps and author identifiers for temporal and network analysis.

Once collected, you must link discussion data to specific proposals. This often requires heuristic matching, such as searching for proposal titles or unique identifiers (like the Snapshot proposal ID 0x...) within the discussion text. Store the final dataset in a structured format—like a relational database with tables for proposals, discussion_posts, and votes—or in a data lake (e.g., Parquet files) for large-scale processing. This clean, linked dataset is ready for the next step: text preprocessing and feature extraction.

nlp-sentiment-analysis
IMPLEMENTATION

Step 2: Applying NLP Models for Sentiment Scoring

This guide details how to implement a sentiment analysis pipeline for on-chain governance proposals using pre-trained NLP models and Python.

To analyze proposal sentiment, you need to process raw text data from platforms like Discourse forums, Snapshot descriptions, or on-chain proposal metadata. The first step is text preprocessing, which involves cleaning the data by converting text to lowercase, removing URLs and special characters, and handling tokenization. Libraries like NLTK or spaCy are essential for this. For example, using spaCy's efficient pipeline allows you to lemmatize words and filter out common stop words, which reduces noise and improves model accuracy by focusing on meaningful content.

After preprocessing, you select and apply a pre-trained sentiment model. For general-purpose analysis, the VADER (Valence Aware Dictionary and sEntiment Reasoner) lexicon is highly effective for social media and short text, providing compound scores from -1 (negative) to +1 (positive). For more nuanced, context-aware sentiment, transformer-based models like DistilBERT or RoBERTa, fine-tuned on financial or political corpora, offer superior performance. You can load these using the transformers library from Hugging Face. A simple implementation might use pipeline('sentiment-analysis') for quick prototyping.

The core of the system is the scoring function that processes each proposal. This function should handle batch processing for efficiency, outputting structured results. Key outputs include a compound sentiment score, a classification label (e.g., Positive, Neutral, Negative), and often a confidence metric from the model. It's critical to log these results with the corresponding proposal ID and timestamp for time-series analysis. Here's a basic function skeleton using VADER:

python
from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer

def analyze_sentiment(text):
    analyzer = SentimentIntensityAnalyzer()
    scores = analyzer.polarity_scores(text)
    return {
        'compound': scores['compound'],
        'label': 'Positive' if scores['compound'] >= 0.05 else 'Negative' if scores['compound'] <= -0.05 else 'Neutral'
    }

For production-grade analysis, especially with transformer models, consider asynchronous processing and model caching to handle high volumes of proposals efficiently. You should also implement threshold calibration; the default 0.05 cutoff for VADER may not suit all governance contexts. Calibrate these thresholds by manually labeling a sample set of proposals from your target DAO (e.g., Uniswap, Aave) and comparing them to model outputs. This step tailors the analysis to the specific language and tone of the crypto governance community.

Finally, integrate this scoring module into a larger data pipeline. The sentiment scores should be stored in a database (like PostgreSQL or TimescaleDB) alongside proposal metadata. This enables downstream tasks such as trend analysis (e.g., tracking sentiment shifts before a vote), correlation studies with voting outcomes, and alerting for highly negative or contentious proposals. The end goal is to transform unstructured forum text into a quantifiable, queryable metric that informs delegate and voter decision-making.

on-chain-voter-data
DATA AGGREGATION

Step 3: Fetching On-Chain Voting and Whale Data

Collect and structure raw blockchain data to analyze governance proposal sentiment, focusing on voter behavior and whale influence.

To analyze governance sentiment, you must first collect the raw data. This involves querying the blockchain for all votes cast on a specific proposal. Using an RPC provider like Alchemy or Infura, you can call the proposal contract's getVotes function or use subgraph queries for protocols like Uniswap or Compound. The goal is to build a dataset containing the voter's address, their vote choice (e.g., For, Against, Abstain), the voting power used, and the block timestamp. This forms the foundation for all subsequent analysis.

Voting power is rarely a simple token count. You must account for delegation, where users assign their voting rights to another address. Furthermore, many protocols use time-weighted mechanisms like ve-token models (e.g., Curve's veCRV) or snapshot-based voting. Your data fetch must resolve the effective voting power at the precise block of the proposal snapshot. This often requires additional calls to staking or delegation contracts to get the correct balance, making the process more complex than a simple ERC-20 balanceOf query.

Identifying whale wallets—addresses holding disproportionately large voting power—is critical for sentiment analysis. After aggregating votes, sort the dataset by voting power descending. A common heuristic defines whales as addresses in the top 1% of voters by power. However, context matters: in a DAO with a concentrated treasury, a single multi-sig holding 40% of the supply is a whale regardless of percentile. Tracking these addresses across multiple proposals reveals consistent voting blocs and influential entities.

For practical implementation, here's a simplified Node.js snippet using ethers.js to fetch votes from a typical Governor contract:

javascript
const proposalVotes = await governorContract.queryFilter(
  governorContract.filters.VoteCast(null, proposalId)
);
const votesData = proposalVotes.map(vote => ({
  voter: vote.args.voter,
  support: vote.args.support, // 0=Against, 1=For, 2=Abstain
  weight: vote.args.weight.toString(),
}));

This raw event data must then be enriched with delegated voting power from the relevant token contract.

Finally, structure your fetched data into a clean format for analysis. A useful schema includes: voter_address, proposal_id, vote_choice, raw_voting_power, delegated_from (if applicable), and timestamp. Store this in a database or DataFrame. This dataset allows you to calculate metrics like total turnout, vote distribution, and whale alignment, setting the stage for the next step: running sentiment analysis algorithms on the voting patterns you've uncovered.

ANALYSIS TOOLS

Sentiment and Voting Metrics Comparison

Comparison of on-chain and off-chain methods for measuring community sentiment and proposal engagement.

Metric / MethodOn-Chain VotingOff-Chain SnapshotSocial Sentiment Analysis

Data Source

Smart contract events

Snapshot.org signatures

X (Twitter), Discord, Forums

Cost to Participate

Gas fee ($5-50+)

Gasless (signature only)

Free

Voter Identity

Wallet address

Token-weighted address

Pseudonymous social account

Sentiment Granularity

For/Against/Abstain

For/Against/Abstain + options

Positive/Neutral/Negative Score (0-1)

Manipulation Resistance

High (costly Sybil)

Medium (token-weighted)

Low (easy Sybil)

Real-time Analysis

No (final tally only)

No (poll duration)

Yes (continuous stream)

Typical Turnout Signal

Voting Power %

Voter Count & VP

Engagement Volume & Score

Integration Complexity

High (index events)

Medium (API queries)

Low to Medium (API/Scraper)

correlation-analysis
ANALYSIS

Step 4: Correlating Sentiment with Voting Outcomes

This step connects on-chain proposal sentiment with final voting results to identify predictive patterns and measure community alignment.

With sentiment scores calculated for each proposal, the next step is to correlate this data with the final on-chain voting outcomes. The goal is to determine if pre-vote discussion sentiment is a reliable predictor of a proposal's success or failure. You'll need to query the governance contract for each proposal's result—typically a binary passed or failed status, along with the final vote tally (e.g., forVotes, againstVotes, abstainVotes). This data is available from the proposal's state and vote count getter functions on the smart contract, such as proposals(proposalId).

For a meaningful correlation, you must align the temporal windows. The sentiment analysis should be performed on data collected before the voting period ends. This ensures you're analyzing predictive sentiment, not retrospective commentary. A common approach is to analyze forum posts and social media from the proposal's submission date up to 24-48 hours before the voting snapshot. This creates a clean dataset where sentiment_score is the independent variable and proposal_passed (boolean) is the dependent variable for statistical testing.

You can perform this analysis using statistical methods in Python with libraries like pandas and scipy. Calculate metrics such as the mean sentiment score for passed proposals versus failed proposals. Use a t-test to determine if the difference is statistically significant (p-value < 0.05). You can also calculate correlation coefficients (e.g., Pearson's r) between sentiment scores and the margin of victory (forVotes - againstVotes). This reveals if more positive sentiment correlates with larger voting margins.

Visualizing this correlation is crucial for interpretation. Create a scatter plot with sentiment score on the x-axis and vote margin percentage on the y-axis, color-coding points by pass/fail status. A clear upward trend indicates predictive power. For example, an analysis of 50 Compound Governance proposals might reveal that proposals with a sentiment score above +0.6 passed 85% of the time, while those below -0.2 failed 90% of the time. These thresholds can become valuable heuristics for delegates and proposers.

Beyond binary outcomes, analyze sentiment distribution across voter cohorts. Segment sentiment by the voting weight of participants in the discussion (e.g., sentiment from wallets holding >10,000 tokens vs. smaller holders). This can uncover if whale sentiment has a stronger correlation with outcomes than general community sentiment. This analysis often requires joining your sentiment dataset with on-chain balance data from a provider like The Graph or Covalent at the snapshot block.

The final output of this step is a validated model or set of clear, data-backed insights. You might conclude, "For DAO X, a pre-vote sentiment score above +0.5 predicts proposal passage with 80% accuracy." This empowers community members to gauge proposal traction and allows DAO tooling platforms to integrate sentiment as a leading indicator in governance dashboards, creating a more informed and efficient decision-making process.

prediction-model
GOVERNANCE SENTIMENT ANALYSIS

Step 5: Building a Simple Prediction Model

This guide walks through creating a machine learning model to predict the outcome of on-chain governance proposals based on community sentiment and metadata.

After collecting and processing proposal data, the next step is to build a prediction model. We'll use a simple binary classification approach to forecast whether a proposal will pass or fail. For this example, we'll leverage a Random Forest classifier from scikit-learn due to its robustness and ability to handle mixed data types. The model will be trained on features extracted from the previous steps, such as sentiment scores, voter turnout metrics, proposal age, and the proposer's historical success rate.

First, we need to prepare our feature matrix and target vector. The target is the binary outcome (1 for passed, 0 for failed). Features should be numerical; categorical data like proposal_type must be encoded. We'll also split the data into training and testing sets to evaluate performance. It's crucial to handle class imbalance if one outcome is significantly more common, which is typical in governance where most proposals pass.

Here's a basic code structure for model training:

python
from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import train_test_split
from sklearn.metrics import classification_report

# X: Feature matrix (sentiment, turnout, etc.)
# y: Target vector (1=pass, 0=fail)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

model = RandomForestClassifier(n_estimators=100, random_state=42)
model.fit(X_train, y_train)

y_pred = model.predict(X_test)
print(classification_report(y_test, y_pred))

This outputs precision, recall, and F1-score, giving you a baseline for model accuracy.

To improve the model, consider feature engineering. Create new features like the ratio of positive to negative sentiment comments in the first 24 hours, or the voting power of early supporters. Hyperparameter tuning using GridSearchCV can optimize the model's max_depth or min_samples_split. Always validate the model on out-of-sample data or recent proposals to test its predictive power on new, unseen discussions.

Finally, analyze the model's feature importance to understand what drives predictions. model.feature_importances_ will show which factors—like quorum percentage or sentiment volatility—are most influential. This insight is valuable for DAO members and analysts, revealing whether the community's discourse or structural proposal metrics are better predictors of success. Deploy the model as a simple API using FastAPI to provide real-time predictions for new proposal discussions.

GOVERNANCE SENTIMENT ANALYSIS

Frequently Asked Questions

Common questions and technical troubleshooting for developers implementing on-chain governance sentiment analysis using Chainscore's APIs and data.

Chainscore aggregates and processes data from multiple on-chain and off-chain sources to build a comprehensive sentiment signal. The primary sources include:

  • On-chain voting data: Proposal metadata, vote casts (for/against/abstain), and voter addresses from major DAO platforms like Compound Governor, Aave, Uniswap, and OpenZeppelin Governor.
  • Forum & social discussion: Snapshot space descriptions, Discourse forum posts, and relevant Twitter/X threads linked to proposal discussions.
  • Voter delegation graphs: Data on delegation patterns to identify influential voters and voting blocs.

Raw data is indexed, cleaned, and structured into our unified API, which provides fields like proposal_sentiment_score, voter_engagement_metrics, and discussion_activity.

conclusion-next-steps
IMPLEMENTATION SUMMARY

Conclusion and Next Steps

You have now built a functional system to analyze governance proposal sentiment. This guide covered the core workflow from data collection to actionable insights.

This guide walked through creating a sentiment analysis pipeline for on-chain governance. You learned to fetch proposal data using The Graph or direct RPC calls, process text with the VADER sentiment analyzer, and store results in a structured format. The key outcome is a system that can automatically score proposal descriptions and discussions, providing a quantitative measure of community sentiment that complements traditional voting metrics.

To enhance your analysis, consider these next steps:

  • Expand Data Sources: Integrate off-chain forums like Discourse and Commonwealth to capture pre-proposal sentiment.
  • Implement Advanced NLP: Move beyond lexicon-based models to fine-tuned transformer models (e.g., bert-base-uncased) for nuanced understanding of crypto-specific terminology.
  • Add Temporal Analysis: Track how sentiment evolves from a proposal's announcement through its execution by analyzing comment timestamps.
  • Build Alerting: Create a bot that triggers notifications when sentiment for a high-stakes proposal turns sharply negative.

For production deployment, focus on robustness and scalability. Use a message queue (e.g., RabbitMQ) to handle data fetching jobs, implement error handling for RPC rate limits, and consider using a vector database like Pinecone or Qdrant for semantic search across historical proposals. Always verify your sentiment scores against manual reviews to calibrate your model's accuracy for the specific jargon of each DAO.

The code and concepts here serve as a foundation. The real value comes from tailoring the system to a specific protocol's governance culture. By continuously refining your model and correlating sentiment scores with proposal outcomes, you can build a powerful tool for predicting governance engagement and identifying potential contention before votes are cast.

How to Analyze DAO Governance Proposal Sentiment | ChainScore Guides