Propozycje i głosowanie
Kontrakty Governor
Propozycje i głosowanie to bezpłatna lekcja Web3 & DApp Development Fundamentals na CoddyKit. To lekcja 3 z 4. Możesz przeczytać całą lekcję poniżej za darmo — a potem ćwiczyć ją interaktywnie w przeglądarce z wbudowanym edytorem kodu i tutorem AI dostępnym 24/7. To część ścieżki edukacyjnej Web3 & DApp Development Fundamentals, a Twój postęp synchronizuje się między webem a aplikacją CoddyKit. Kurs Web3 & DApp Development Fundamentals zawiera 4 lekcji w sumie.
Części tej lekcji nie zostały jeszcze przetłumaczone i są wyświetlane po angielsku.
The Governance Lifecycle
On-chain governance follows a clear lifecycle: propose, vote, queue, execute.
Each stage is handled by a Governor smart contract that enforces the rules automatically.
The Governor Contract
OpenZeppelin's Governor is the standard framework for DAO voting. It manages proposals, tallies votes, and triggers execution.
It is modular: you plug in a vote-counting strategy, a token, and timing parameters.
contract MyGovernor is
Governor,
GovernorVotes,
GovernorVotesQuorumFraction,
GovernorTimelockControl
{ /* ... */ }Creating a Proposal
A proposal bundles the actions to execute: target contracts, call data, and values, plus a human-readable description.
governor.propose(
[targetContract], // addresses
[0], // ETH values
[callData], // encoded function calls
"Increase reward rate to 5%"
);The Voting Delay
After a proposal is created, a voting delay passes before voting opens.
This gives members time to review and lets the snapshot block settle so balances are fixed.
votingDelay = 1 block // wait before voting
votingPeriod = 50400 blocks // ~1 week of votingCasting Votes
During the voting period, members cast votes weighted by their delegated power at the snapshot block.
Standard options are For, Against, and Abstain.
governor.castVote(proposalId, 1);
// 0 = Against, 1 = For, 2 = AbstainVote Counting and Quorum
When voting ends, the Governor tallies the weighted votes. A proposal succeeds only if it has more For than Against votes and meets the quorum.
Abstain votes typically count toward quorum but not toward the For/Against decision.
Proposal States
A proposal moves through defined states:
- Pending — waiting for voting delay
- Active — voting open
- Defeated or Succeeded
- Queued then Executed
Queuing a Successful Proposal
A succeeded proposal is usually queued in a timelock before it can run.
This delay (covered next lesson) is a safety buffer letting users react before the change takes effect.
governor.queue(targets, values, calldatas, descHash);Execution
After the timelock delay, anyone can call execute to carry out the proposal's actions on-chain.
The Governor (or its timelock) holds the permissions needed to make the changes.
governor.execute(targets, values, calldatas, descHash);
// the approved actions now runGas Costs and Off-Chain Voting
On-chain voting costs gas per vote. To save costs, many DAOs deliberate and signal off-chain (Snapshot) and only push final, binding actions on-chain.
This hybrid keeps participation cheap while preserving trustless execution.
Putting It Together
Governor contracts standardize the propose-vote-queue-execute flow. Voting delays, periods, quorum, and proposal states make governance predictable and secure.
Next we focus on timelocks, the safety layer before execution.
Quick Check
Test your understanding of the governance flow.
Recap: Proposals and Voting
You learned that:
- Governance follows propose, vote, queue, execute
- The Governor contract enforces the rules
- A voting delay and period structure the timeline
- Success needs a majority For plus quorum
- Proposals pass through defined states
Next: timelocks and safe execution.
Ucz się Web3 & DApp Development Fundamentals dzięki korepetycjom AI — za darmo
Pisz i uruchamiaj kod w przeglądarce, otrzymuj natychmiastową pomoc od korepetytora AI dostępnego 24/7 i kontynuuj naukę w sieci lub w aplikacji.
- Kursy
- 29
- Lekcje
- 105
Często zadawane pytania
Czy lekcja „Propozycje i głosowanie” jest bezpłatna?
Tak — pełny tekst „Propozycje i głosowanie” jest dostępny za darmo tutaj w sieci. Aby ćwiczyć ją interaktywnie (wbudowany edytor kodu i tutor AI dostępny 24/7) i odblokować resztę kursu Web3 & DApp Development Fundamentals, przejdź na CoddyKit PRO. Kurs Web3 & DApp Development Fundamentals zawiera 4 lekcji w sumie.
Co nauczysz się w „Propozycje i głosowanie”?
Kontrakty Governor Ćwiczysz Web3 & DApp Development Fundamentals z praktycznym kodem, który uruchamiasz bezpośrednio w przeglądarce, a tutor AI dostępny 24/7 odpowiada na Twoje pytania podczas pracy nad lekcją.
Czy potrzebuję doświadczenia, aby zacząć Web3 & DApp Development Fundamentals?
Nie wymagamy żadnego doświadczenia. Web3 & DApp Development Fundamentals w CoddyKit jest strukturyzowany dla początkujących i zaawansowanych użytkowników, więc możesz zacząć tutaj lub od początku i uczyć się w swoim tempie. To lekcja 3 z 4.
Ile czasu zajmuje lekcja „Propozycje i głosowanie”?
Większość lekcji CoddyKit trwa około 5–10 minut. Każda lekcja to mały, interaktywny krok, dzięki czemu robisz systematyczne postępy i zawsze wracasz dokładnie do tego samego miejsca — na webie i w aplikacji.
Czy mogę pisać i uruchamiać kod w tej lekcji Web3 & DApp Development Fundamentals?
Tak. Każda lekcja Web3 & DApp Development Fundamentals zawiera wbudowany edytor kodu, więc piszesz i uruchamiasz prawdziwy kod bezpośrednio w przeglądarce i od razu otrzymujesz sprzężenie zwrotne od AI — bez konfiguracji na komputerze.
Wszystkie lekcje w tym kursie
- Czym jest DAO
- Tokeny zarządzania
- Propozycje i głosowanie
- Timelocki i wykonywanie