A decentralized decision-making protocol implementing Condorcet-style Ranked Choice Voting with IPFS-based data storage and Bitcoin-signed message verification.
The Hivemind Protocol is a revolutionary approach to decentralized decision-making that combines:
- Condorcet-style ranked choice voting
- Immutable IPFS-based data storage
- Cryptographic verification using Bitcoin signed messages
- Flexible voting mechanisms and constraints
-
Decentralized & Transparent
- All voting data stored on IPFS
- Complete audit trail of decisions
- No central authority or server
- Cryptographically verifiable results
-
Advanced Voting Mechanisms
- Condorcet-style ranked choice voting
- Multiple ranking strategies (fixed, auto-high, auto-low)
- Support for various answer types (String, Integer, Float)
- Weighted voting capabilities
- Custom voting restrictions and rules
-
Secure & Verifiable
- Bitcoin-style message signing for vote verification
- Immutable voting history
- Cryptographic proof of participation
- Tamper-evident design
An issue represents a decision to be made. It can contain:
- Multiple questions
- Answer type constraints (String/Integer/Float)
- Participation rules
- Custom validation rules
issue = HivemindIssue()
issue.name = "Protocol Upgrade"
issue.add_question("Should we implement EIP-1559?")
issue.answer_type = "String"
Participants can submit options as potential answers:
- Each option is stored on IPFS
- Options are validated against issue constraints
- Options require cryptographic signatures
- Options can be added dynamically
option = HivemindOption()
option.set_hivemind_issue(issue.cid)
option.set("Yes, implement EIP-1559")
Participants express preferences through three ranking methods:
-
Fixed Ranking
opinion = HivemindOpinion() opinion.ranking.set_fixed([option1.cid, option2.cid]) # Explicit order
-
Auto-High Ranking
opinion.ranking.set_auto_high(preferred_option.cid) # Higher values preferred
-
Auto-Low Ranking
opinion.ranking.set_auto_low(preferred_option.cid) # Lower values preferred
The protocol maintains state through:
- Option tracking
- Opinion collection
- Signature verification
- Result calculation
- State transitions
state = HivemindState()
state.set_hivemind_issue(issue.cid)
state.add_option(timestamp, option.cid, voter_address, signature)
state.add_opinion(timestamp, opinion.cid, signature, voter_address)
Results are calculated using Condorcet method:
- Pairwise comparison of all options
- Preference matrix creation
- Winner determination
- Tie resolution
results = state.calculate_results()
winner = state.consensus()
Detailed examples can be found in the examples/
directory:
basic_voting.py
- Simple voting exampleadvanced_features.py
- Advanced protocol featuresprotocol_upgrade.py
- Governance decision example
Each example is thoroughly documented and can be run independently. See the examples README for more details.
pip install hivemind-python
Import the package:
import hivemind # Note: Import as 'hivemind', not 'hivemind_python'
# Create a new voting issue
issue = hivemind.HivemindIssue("My voting issue")
- Python 3.10 or higher
- ipfs-dict-chain >= 1.0.9
- A running IPFS node (see IPFS Installation Guide)
- The IPFS daemon must be running and accessible via the default API endpoint
- Default endpoint: http://127.0.0.1:5001
issue.set_constraints({
'min_value': 0,
'max_value': 100,
'specs': {'type': 'Integer'}
})
issue.set_restrictions({
'min_participants': 5,
'allowed_addresses': ['addr1', 'addr2'],
'min_weight': 10
})
option1.set(75) # Integer value
option2.set(25) # Integer value
opinion.ranking.set_auto_high(option1.cid) # Will rank options by proximity to 75
-
Governance Decisions
- Protocol upgrades
- Parameter adjustments
- Resource allocation
-
Community Polling
- Feature prioritization
- Community preferences
- Strategic decisions
-
Multi-stakeholder Decisions
- Investment decisions
- Project prioritization
- Resource allocation
Full documentation is available at https://valyriantech.github.io/hivemind-python/
This project is licensed under the MIT License - see the LICENSE file for details.