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

Launching a Proposal and Voting System for Treatment Protocol Decisions

A technical tutorial for building an on-chain governance system where medical professionals can propose, debate, and ratify clinical practice guidelines using smart contracts.
Chainscore © 2026
introduction
GOVERNANCE

Introduction

A practical guide to implementing a decentralized proposal and voting system for on-chain protocol decisions.

Decentralized governance is a core tenet of Web3, enabling communities to collectively steer the evolution of protocols without centralized control. This guide details the architectural components and implementation steps for building a proposal and voting system, a fundamental mechanism for enacting changes to a protocol's parameters, treasury, or smart contract logic. We will focus on practical, on-chain execution using standards like OpenZeppelin's Governor contracts and common patterns such as token-weighted voting and timelocks.

The system's lifecycle typically follows a structured path: proposal submission, an active voting period, vote tallying, and finally, execution. Key decisions include choosing a voting token (e.g., a native governance token like UNI or COMP), setting quorum and vote thresholds, and integrating a timelock to delay execution, providing a safety window for the community to react to passed proposals. We'll explore how these parameters define the security and responsiveness of your governance model.

From a technical perspective, we will break down the essential smart contracts: the Governor contract that orchestrates the process, the Voting Token (often an ERC-20 with snapshot delegation), and an optional TimelockController for secure, delayed execution. The guide includes Solidity code snippets for customizing proposal logic and interacting with these contracts, providing a foundation you can adapt for specific use cases like adjusting treatment protocol fees or upgrading core modules.

Beyond code, we'll cover critical security considerations and best practices. This includes guarding against governance attacks like vote stuffing or flash loan manipulation, the importance of immutable core contracts behind a proxy, and strategies for setting initial parameters safely. A well-designed system balances community participation with protocol stability, ensuring decisions are legitimate and executable on-chain.

Finally, we'll outline the end-to-end workflow for users and developers: from a community member creating a proposal via a frontend interface, to delegates casting their votes, to a guardian or automated process executing the successful proposal's transactions. This guide provides the actionable knowledge to move from concept to a functional, auditable governance system for your protocol.

prerequisites
FOUNDATION

Prerequisites

Before building a proposal and voting system for a treatment protocol, you must establish the core technical and conceptual components. This section outlines the essential knowledge and tools required.

A robust governance system requires a secure and transparent execution layer. You will need a smart contract development environment like Hardhat or Foundry, and a solid understanding of the Ethereum Virtual Machine (EVM). Familiarity with Solidity is essential for writing the core contracts that will manage proposals, voting power, and execution logic. You should also have a test network (testnet) configured, such as Sepolia or Goerli, for deployment and experimentation.

The governance model must be clearly defined before a single line of code is written. Determine the key parameters: who are the voting members (e.g., token holders, designated committee addresses), what is the proposal lifecycle (submission, voting period, timelock, execution), and what voting mechanism will be used (e.g., simple majority, quadratic voting, token-weighted). These decisions will directly shape your contract architecture and are critical for community trust.

For on-chain voting, you must decide how voting power is calculated and represented. A common pattern is to use an ERC-20 token or an ERC-721 NFT (for non-transferable membership) to represent governance rights. You'll need to understand how to snapshot token balances at a specific block to prevent manipulation, a concept known as vote escrow or using a checkpoint system like that in OpenZeppelin's ERC20Votes contract.

Security is paramount. You must implement safeguards against common governance attacks, such as proposal spam, vote buying, and timelock bypasses. This involves setting sensible thresholds for proposal submission, incorporating a timelock delay between a vote passing and its execution, and using multi-signature wallets or a governor contract (like OpenZeppelin Governor) for secure execution of passed proposals.

Finally, consider the user interface and tooling. While the backend is on-chain, users will interact with your system through a frontend. You should be prepared to integrate a Web3 library like ethers.js or viem to connect wallets, fetch proposal data, and submit transactions. Planning for indexers like The Graph for efficient querying of proposal history and vote tallies will significantly improve the user experience.

system-architecture
SYSTEM ARCHITECTURE AND SMART CONTRACT DESIGN

Launching a Proposal and Voting System for Treatment Protocol Decisions

This guide details the implementation of an on-chain governance system for a decentralized treatment protocol, covering smart contract architecture, proposal lifecycle, and secure voting mechanics.

A decentralized governance system is essential for a treatment protocol to manage upgrades, parameter adjustments, and treasury allocations. The core architecture typically involves three main smart contracts: a Governor contract that orchestrates proposals, a Voting Token (ERC-20Votes) that represents voting power, and a Timelock Controller that enforces a delay between proposal execution and its effects. This separation of concerns enhances security by isolating permissions and introducing a critical review period. The Governor contract, often built using OpenZeppelin's Governor contracts, defines the rules for proposal creation, voting, and execution.

The proposal lifecycle begins when a user with sufficient proposal power submits a transaction. This transaction data includes the target contract addresses, the function to call (e.g., setTreatmentParameter), and the encoded arguments. The Governor contract stores this as a proposal with a unique ID and moves it to an active state after a voting delay. During the voting period, which may last several days, token holders cast their votes. Voting power is typically calculated via a snapshot of token balances at the start of the block when the proposal was created, preventing manipulation through token transfers during the voting window.

Implementing secure voting requires careful consideration of the voting mechanism. Common models include token-weighted voting, where one token equals one vote, and delegated voting, where users can delegate their voting power to representatives. The Governor contract tallies votes, and if the proposal meets predefined quorum and majority thresholds (e.g., 4% of total supply and >50% for), it is queued in the Timelock. The Timelock enforces a mandatory delay (e.g., 48 hours), providing a final window for users to review the executed transaction's bytecode before it irreversibly alters the protocol state.

Key technical parameters must be configured in the Governor contract's constructor. These include the votingDelay (blocks before voting starts), votingPeriod (blocks voting is active), proposalThreshold (minimum tokens needed to propose), and quorum (minimum voting power required for validity). For a treatment protocol, a higher quorum (e.g., based on a percentage of total token supply) ensures broad consensus for sensitive changes. The contract must also specify the voting token and timelock addresses. Testing this system thoroughly on a testnet like Sepolia is critical before mainnet deployment.

Integrating this system with the treatment protocol's existing contracts is the final step. The Timelock contract should be set as the owner or admin for any upgradeable contracts or critical functions (e.g., a ProtocolParameters contract). This means governance proposals execute calls from the Timelock address. Developers should use tools like Tenderly or OpenZeppelin Defender to simulate proposal execution and monitor the queue. A well-architected system balances security, decentralization, and efficiency, enabling a community to govern a protocol's evolution transparently and collectively.

proposal-contract-implementation
TUTORIAL

Implementing the Proposal and Peer-Review Contract

A technical guide to building a decentralized governance system for a treatment protocol, covering smart contract design for proposals, voting, and peer-review mechanisms.

A decentralized governance system for a treatment protocol requires a secure and transparent mechanism for proposing changes, voting, and implementing decisions. The core of this system is a smart contract that manages the proposal lifecycle. This contract must define the structure of a proposal, including its title, description, target contract address for execution, and the encoded function call data. It also sets governance parameters like the minimum voting period, quorum requirements, and the voting token used for weighting votes, such as the protocol's native TREAT token.

The voting mechanism is implemented using a state machine within the contract. A proposal starts in a Pending state. When a user submits a proposal by calling createProposal(), they must stake a predefined amount of tokens to prevent spam. The proposal then moves to Active for voting. During this period, token holders call castVote(proposalId, support) with options like For, Against, or Abstain. Votes are typically weighted by the voter's token balance at the time of proposal creation, a pattern known as snapshot voting, which prevents manipulation via token transfers.

After the voting period ends, the contract logic checks if the proposal met the minimum quorum (e.g., 4% of total token supply) and achieved a majority (e.g., >50% for). If successful, it enters a Queued state, followed by a timelock delay—a critical security feature that allows users to review the executed code before it takes effect. Finally, any user can call executeProposal() to run the encoded function call on the target contract, moving the proposal to Executed. Failed proposals are marked Defeated. This entire flow ensures changes are community-driven and resistant to rushed or malicious updates.

Integrating a peer-review mechanism adds a layer of expert validation before execution. This can be implemented as a multi-signature scheme or a council of approved addresses. The proposal contract can require that after a successful vote, the proposal must also be approved by, for example, 3 out of 5 designated reviewer addresses by calling submitReview(proposalId, approval). Only after this secondary approval does the proposal become eligible for the timelock and execution. This model balances direct community voting with expert oversight, which is crucial for high-stakes decisions in a medical or scientific protocol.

Key security considerations include using OpenZeppelin's governance contracts as a foundation, which provide battle-tested implementations of Governor and TimelockController. All state changes and user interactions should emit clear events for off-chain tracking. Thorough testing with frameworks like Hardhat or Foundry is essential, simulating various attack vectors such as proposal spam, flash loan attacks to manipulate voting power, and reentrancy in the execution phase. The final contract should be verified on block explorers like Etherscan for complete transparency.

voting-governor-implementation
TREATMENT PROTOCOL GOVERNANCE

Building the Time-Locked Voting Governor

This guide details the implementation of a decentralized, time-locked voting system for making protocol-level decisions, such as adjusting fee parameters or upgrading smart contracts.

A Time-Locked Voting Governor is a smart contract system that manages the lifecycle of on-chain proposals. It is a core component of decentralized autonomous organization (DAO) governance, allowing token holders to propose, vote on, and execute changes to a protocol. The "time-locked" aspect introduces mandatory delays between a vote's success and its execution, providing a critical security window for the community to review and react to potentially malicious proposals. This model is widely used by protocols like Compound and Uniswap.

The system typically involves three core contracts: the Governor contract, which manages proposal logic and voting; a Voting Token (often an ERC-20 or ERC-721), which determines voting power; and a TimelockController. The TimelockController is a queue-and-delay mechanism that sits between the Governor and the protocol's other smart contracts. When a proposal passes, it is not executed immediately but is instead scheduled on the Timelock for execution after a predefined delay, such as 48 hours.

Proposals are created by submitting a list of target addresses, calldata values, and ether values for the transactions to be executed. For example, a proposal could call setFeePercentage(uint256) on the protocol's treasury contract with a new value. The proposal enters a voting period where token holders cast their votes, with weight determined by their token balance at a specific snapshot block. Voting strategies can vary, including simple majority, quorum requirements, and vote delegation.

Implementing this requires careful security considerations. The Timelock delay is the primary defense against governance attacks, allowing users to exit the protocol if a harmful proposal passes. The Governor contract must also implement proper access controls, ensuring only it can schedule operations on the Timelock. Furthermore, proposal thresholds (minimum token required to propose) and quorum (minimum voting participation) must be set to balance accessibility with protection against spam.

Here is a simplified code snippet for a proposal's execution path using OpenZeppelin's Governor and Timelock contracts:

solidity
// After a successful vote, the Governor calls the Timelock
function execute(
    address[] memory targets,
    uint256[] memory values,
    bytes[] memory calldatas,
    bytes32 descriptionHash
) public payable override {
    // This will schedule the operation on the Timelock
    _execute(targets, values, calldatas, descriptionHash);
}
// The operation executes automatically after the delay elapses

To deploy a complete system, you would first deploy the TimelockController with a minimum delay (e.g., 2 days) and admin addresses. Next, deploy the Governor contract, configuring it with the Timelock's address as the executor, and set voting parameters like voting delay, voting period, and proposal threshold. Finally, you must grant the Governor the PROPOSER_ROLE on the Timelock and revoke the role from any other addresses, ensuring it is the sole entity that can schedule operations, thereby completing the secure governance loop.

GOVERNANCE FRAMEWORK

Proposal Categories and Parameters

Core proposal types and their configurable parameters for a decentralized treatment protocol.

Parameter / CategoryProtocol UpgradeTreasury AllocationTreatment Parameter UpdateEmergency Action

Voting Duration

7 days

5 days

3 days

48 hours

Quorum Threshold

10% of veTREAT

7% of veTREAT

5% of veTREAT

15% of veTREAT

Approval Threshold

66%

50%

50%

75%

Proposal Bond

500 TREAT

200 TREAT

100 TREAT

1000 TREAT

Execution Delay

48 hours

24 hours

Immediate

Immediate

Can be Vetoed by Multisig?

Requires Audit?

Typical Gas Cost for Execution

$150-300

$80-120

$40-60

$200-500

integration-frontend
FRONTEND INTEGRATION AND USER FLOW

Launching a Proposal and Voting System for Treatment Protocol Decisions

This guide details the frontend implementation for a decentralized governance system, enabling token holders to propose, discuss, and vote on changes to a shared treatment protocol.

The user flow begins with proposal creation. A frontend interface, built with frameworks like React or Vue.js, connects to a user's Web3 wallet (e.g., MetaMask) via libraries such as ethers.js or viem. The interface presents a form where users can submit a proposal title, description, and the specific on-chain function call data for the proposed protocol change. Before submission, the contract's propose function is called, which typically requires the proposer to hold a minimum token balance. The frontend must handle transaction signing, gas estimation, and provide clear feedback on submission status.

Once a proposal is live, the frontend fetches and displays its state from the governance smart contract. This includes the proposal ID, creator, description, and crucially, the voting timeline (e.g., snapshot block, start time, end time). The UI should render a real-time vote tally, showing counts for For, Against, and Abstain options. For a seamless experience, integrate a discussion forum component or link to an external platform like a Snapshot forum or Discord thread, allowing voters to deliberate before casting their votes. This combines on-chain data with off-chain discourse.

The voting interface is the core interactive element. It must first check the user's voting power, which is often calculated from a token snapshot at a specific block. The user selects their vote (For/Against/Abstain) and submits a transaction to the contract's castVote function. The frontend should display the user's pending vote and confirm when the transaction is mined. Advanced features include vote delegation UI, where users can delegate their voting power to another address, and integration with gasless voting solutions like Snapshot's off-chain signing or relayers for on-chain votes to reduce user friction.

After the voting period ends, the frontend must facilitate the execution of successful proposals. It should display proposals that have passed the required quorum and vote threshold. An "Execute" button then becomes active, triggering the queued transaction that modifies the treatment protocol's parameters or logic. The UI must also handle failed or expired proposals, clearly archiving them. For transparency, all historical proposal data, including voter addresses and weights, should be queryable and displayable, often requiring integration with a subgraph on The Graph for efficient indexing of past events.

security-considerations
PROPOSAL & VOTING SYSTEMS

Security and Compliance Considerations

Implementing a secure and compliant on-chain governance system for treatment protocols requires addressing key risks in smart contract security, voter privacy, and regulatory adherence.

testing-deployment
GOVERNANCE

Launching a Proposal and Voting System for Treatment Protocol Decisions

This guide details the implementation of an on-chain governance system for a treatment protocol, covering smart contract development, testing strategies, deployment, and upgrade mechanisms to ensure secure and decentralized decision-making.

A robust on-chain governance system is essential for decentralized protocols, allowing stakeholders to propose, debate, and vote on critical changes. For a treatment protocol, this could include decisions on protocol parameters, fee structures, treasury allocations, or smart contract upgrades. The core components are a proposal factory contract that creates new proposals, a voting token (often an ERC-20 or ERC-721) that determines voting power, and a governor contract (like OpenZeppelin's Governor) that manages the proposal lifecycle. This architecture separates concerns, enabling modular upgrades and clear permission boundaries.

Implementing the system begins with writing and testing the smart contracts. Use a framework like OpenZeppelin Contracts, which provides battle-tested, modular components for governance. A typical setup involves deploying a MyToken (ERC20Votes) for voting power, a TimelockController to queue executed proposals, and a custom TreatmentGovernor contract that extends Governor. The governor's settings—such as voting delay, voting period, proposal threshold, and quorum—must be carefully calibrated based on token distribution and desired decision speed. Thorough unit and integration tests should simulate the full proposal lifecycle: proposal creation, voting, vote tallying, queueing to the timelock, and final execution.

Testing must cover edge cases and attack vectors specific to governance. Key scenarios include: testing quorum logic under low participation, ensuring vote delegation works correctly, verifying the timelock prevents immediate execution, and simulating proposal cancellation. Use forked mainnet tests with tools like Hardhat or Foundry to interact with real token distributions. It's also critical to test upgrade paths; if using a transparent proxy pattern (e.g., via OpenZeppelin's UpgradeableGovernor), ensure that governance retains the ability to upgrade the logic contract itself, a process known as meta-governance.

Deployment follows a sequential, verified process. First, deploy the voting token contract. Second, deploy the TimelockController, with the protocol's multi-sig wallet as the initial admin. Third, deploy the TreatmentGovernor contract, configuring it to use the token and timelock. Finally, transfer administrative privileges (like minting or pausing) from the deployer wallet to the timelock contract. This ensures all future administrative actions must pass through a governance proposal. Verify all contracts on block explorers like Etherscan and consider using a defender service for proposal creation and automation.

Upgradability is a critical design consideration. Using an upgradeable proxy pattern allows you to fix bugs or add features without migrating state. However, governance upgrades require special care. The standard pattern is to have the governance contract itself be upgradeable, controlled by the same governance process—a self-governing upgrade mechanism. When writing new logic versions, maintain storage compatibility to prevent state corruption. Always test upgrades on a testnet with a full governance simulation before proposing them on mainnet. Document all changes and their rationale in the proposal to ensure informed voter participation.

Once live, the system enables decentralized stewardship. Community members can submit proposals via an interface like Tally or Snapshot (for gasless signaling). Successful proposals are executed automatically by the timelock after a delay, providing a safety window for users to react to potentially malicious actions. This transparent, on-chain process ensures the treatment protocol evolves according to the collective will of its stakeholders, aligning long-term incentives and securing the protocol's future.

DEVELOPER FAQ

Frequently Asked Questions

Common technical questions and troubleshooting for building a decentralized governance system for treatment protocols.

On-chain voting executes votes directly as transactions on the blockchain (e.g., using a governor contract like OpenZeppelin's). This is fully transparent and trustless but incurs gas costs for every vote.

Off-chain voting (e.g., using Snapshot) collects votes via signed messages, which are free for voters. The results are then executed by a trusted party or via a relayer. The choice depends on your need for cost, speed, and finality.

Key Considerations:

  • On-chain: Higher cost, slower, cryptographically final.
  • Off-chain: Gasless, faster, requires a separate execution step.
conclusion
IMPLEMENTATION CHECKLIST

Conclusion and Next Steps

You have now explored the core components for building a decentralized proposal and voting system. This guide covered the essential smart contract architecture, governance token mechanics, and frontend integration patterns. The next step is to launch and manage your system in a live environment.

Before deploying your contracts to a mainnet like Ethereum or an L2 such as Arbitrum, conduct thorough testing. Use a local development environment like Hardhat or Foundry to write unit tests for all voting logic, including edge cases for quorum, vote weighting, and proposal state transitions. Deploy to a testnet (e.g., Sepolia, Goerli) and run integration tests with a frontend client to simulate the complete user flow from proposal creation to execution. Consider using a time-lock contract for critical protocol upgrades to introduce a mandatory delay between a vote passing and its execution, providing a final safety check.

For ongoing governance, establish clear processes. Define proposal templates in your frontend to standardize submissions, requiring fields like title, description, and on-chain calldata. Set realistic voting parameters: a quorum (e.g., 5-20% of circulating supply) to ensure sufficient participation, a voting delay (1-2 days) for discussion, and a voting period (3-7 days) for casting votes. Monitor delegate activity and voter apathy; tools like Tally or Boardroom can provide analytics. Encourage participation through governance forums like Commonwealth or Discourse for off-chain signaling before formal on-chain proposals.

The final step is fostering a sustainable DAO. Use the ERC20Votes token you implemented not just for governance but also to incentivize participation—consider vote-escrowed models (ve-tokenomics) where longer-term token locking grants greater voting power. Integrate with Snapshot for gas-free signaling votes on non-critical decisions, reserving on-chain voting for treasury movements or smart contract upgrades. Continuously audit and upgrade your contracts; platforms like OpenZeppelin Defender can help automate governance proposal creation and execution. Your system is now a foundational piece for decentralized, community-led protocol evolution.