{"id":50966938,"url":"https://github.com/blockful/ranked-choice-voting","last_synced_at":"2026-06-18T21:04:05.380Z","repository":{"id":360611049,"uuid":"1248911573","full_name":"blockful/ranked-choice-voting","owner":"blockful","description":"Onchain ranked-choice voting for DAOs with Copeland and Schulze methods","archived":false,"fork":false,"pushed_at":"2026-05-27T05:12:58.000Z","size":97,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-27T07:10:49.657Z","etag":null,"topics":["condorcet","copeland","dao","ethereum","foundry","governance","ranked-choice-voting","schulze","smart-contracts","solidity","voting"],"latest_commit_sha":null,"homepage":null,"language":"Solidity","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/blockful.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-05-25T06:59:12.000Z","updated_at":"2026-05-27T05:13:02.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/blockful/ranked-choice-voting","commit_stats":null,"previous_names":["blockful/ranked-choice-voting"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/blockful/ranked-choice-voting","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blockful%2Franked-choice-voting","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blockful%2Franked-choice-voting/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blockful%2Franked-choice-voting/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blockful%2Franked-choice-voting/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/blockful","download_url":"https://codeload.github.com/blockful/ranked-choice-voting/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blockful%2Franked-choice-voting/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34507171,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-18T02:00:06.871Z","response_time":128,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["condorcet","copeland","dao","ethereum","foundry","governance","ranked-choice-voting","schulze","smart-contracts","solidity","voting"],"created_at":"2026-06-18T21:04:04.402Z","updated_at":"2026-06-18T21:04:05.374Z","avatar_url":"https://github.com/blockful.png","language":"Solidity","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ranked-choice-voting\n\nOnchain ranked-choice voting for DAOs with Copeland and Schulze methods.\n\n![CI](https://github.com/blockful/ranked-choice-voting/actions/workflows/test.yml/badge.svg) ![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg) ![Solidity](https://img.shields.io/badge/Solidity-%5E0.8.26-363636) ![Built with Foundry](https://img.shields.io/badge/Built%20with-Foundry-FFDB1C?logo=ethereum\u0026logoColor=black)\n\n## Overview\n\nTwo standalone Solidity contracts that run pairwise-Condorcet ranked-choice elections fully onchain. Voters submit ranked ballots weighted by `IVotes` (ERC20Votes / ERC721Votes) snapshots. `CopelandVoting` and `SchulzeVoting` both implement the common `IRankedChoiceVoting` interface — integrate once, swap methods with a single constructor change. Each contract outputs a deterministic strict total order over all candidates; downstream consumers (Governors, council selectors, budget allocators) interpret that ordering however they need.\n\nAimed at DAOs and onchain organizations that need a Condorcet-method election — council selection, grant allocation, prioritized lists, multi-winner committees — where the canonical \"winner-take-all\" Governor pattern doesn't fit and an ordered ranking is the natural output.\n\nExplicitly **not**: an audited contract, an instant-runoff (IRV) implementation, or an OpenZeppelin Governor replacement. It produces a ranking; combining that ranking with proposal execution is the integrator's job.\n\n## Features\n\n- Two methods, one interface — swap `CopelandVoting` \u003c-\u003e `SchulzeVoting` with no integration changes.\n- Standalone — no coupling to OpenZeppelin Governor or any DAO framework.\n- Generic — any `IVotes` token works (ERC20Votes, ERC721Votes, custom checkpointed tokens).\n- Permissionless — anyone can create an election, cast, tally, or finalize.\n- Replaceable ballots — voters can recast at any time before the deadline.\n- Lazy batched tally — pay gas only when you need the result; spread across multiple transactions.\n- Live preview — `getCurrentResult(id)` returns the ranking the contract would produce if `finalize()` were called right now, at any lifecycle phase.\n- Deterministic ordering — always a strict total order, with method-specific tiebreaks (Copeland: Minimax then index; Schulze: strongest-path then index).\n- Partial rankings — voters rank any subset of candidates; unranked candidates contribute nothing.\n\n## Methods\n\n- **Copeland** — each candidate's score is (head-to-head wins − losses); Minimax breaks ties, then candidate index. Cheaper to finalize (O(C²)) and easier to explain. Default choice unless you specifically expect cyclical preferences.\n- **Schulze** — Floyd-Warshall over the widest-path semiring produces strongest-path scores; candidate index breaks ties. Resolves asymmetric Condorcet cycles decisively at the cost of O(C³) finalize.\n\nFull methodology, worked examples and tiebreak rules: [docs/voting-methods.md](docs/voting-methods.md).\n\n## Quick start\n\n```bash\nforge install\nforge build\nforge test\n```\n\nRequires [Foundry](https://book.getfoundry.sh/).\n\n## Usage\n\n```solidity\nimport {IRankedChoiceVoting} from \"src/interfaces/IRankedChoiceVoting.sol\";\nimport {CopelandVoting} from \"src/CopelandVoting.sol\";\n// or: import {SchulzeVoting} from \"src/SchulzeVoting.sol\";\n\n// Integrate against the common interface — swap methods freely.\nIRankedChoiceVoting voting = IRankedChoiceVoting(address(new CopelandVoting()));\n\n// 1. Create an election\nbytes32[] memory candidates = new bytes32[](3);\ncandidates[0] = keccak256(\"Alice\");\ncandidates[1] = keccak256(\"Bob\");\ncandidates[2] = keccak256(\"Carol\");\n\nuint256 electionId = voting.createElection(IRankedChoiceVoting.ElectionConfig({\n    candidates: candidates,\n    votingToken: ensToken,\n    snapshotBlock: block.number - 1,\n    startTime: uint64(block.timestamp),\n    endTime: uint64(block.timestamp + 7 days),\n    metadataURI: bytes32(0)\n}));\n\n// 2. Voters cast ranked ballots\nuint8[] memory ranking = new uint8[](3);\nranking[0] = 2; // Carol first\nranking[1] = 0; // Alice second\nranking[2] = 1; // Bob third\nvoting.castBallot(electionId, ranking);\n\n// 3. Live preview at any time — no need to wait for finalize.\nuint8[] memory provisional = voting.getCurrentResult(electionId);\n\n// 4. After endTime, anyone tallies and finalizes\nwhile (!voting.tallyBallots(electionId, 50)) {} // batched\nvoting.finalize(electionId);\n\n// 5. Read the final result\nuint8[] memory orderedWinners = voting.getRanking(electionId);\n// orderedWinners[0] is the top-ranked candidate index\n```\n\nLimits: maximum 64 candidates per election; voter weights bounded by `int256` max.\n\n## Deployments\n\nNot yet deployed to mainnet. Run via the deploy scripts in [`script/`](script/) (`DeployCopelandVoting.s.sol`, `DeploySchulzeVoting.s.sol`).\n\n## Documentation\n\n- [docs/voting-methods.md](docs/voting-methods.md) — full methodology, worked examples, gas table, tiebreak rules.\n- [docs/superpowers/specs/2026-05-25-multi-method-voting-design.md](docs/superpowers/specs/2026-05-25-multi-method-voting-design.md) — multi-method design spec.\n- [docs/superpowers/specs/2026-05-24-copeland-voting-design.md](docs/superpowers/specs/2026-05-24-copeland-voting-design.md) — original Copeland design rationale and decision log.\n- [docs/superpowers/plans/2026-05-25-multi-method-voting.md](docs/superpowers/plans/2026-05-25-multi-method-voting.md) — multi-method implementation plan.\n\n## Contributing\n\nContributions welcome. See [CONTRIBUTING.md](CONTRIBUTING.md) for setup, conventions, and PR process.\n\n## Security\n\nReport vulnerabilities per [SECURITY.md](SECURITY.md). **These contracts have not been independently audited** — production deployments should commission an audit first.\n\n## License\n\n[MIT](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblockful%2Franked-choice-voting","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fblockful%2Franked-choice-voting","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblockful%2Franked-choice-voting/lists"}