ข้อเสนอและการลงคะแนน
สัญญาผู้ควบคุม
ข้อเสนอและการลงคะแนน เป็นบทเรียน Web3 & DApp Development Fundamentals ฟรีบน CoddyKit นี่คือบทเรียนที่ 3 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน Web3 & DApp Development Fundamentals และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส Web3 & DApp Development Fundamentals มีบทเรียนทั้งหมด 4 บทเรียน
บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ
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.
เรียนรู้ Web3 & DApp Development Fundamentals ด้วย AI tutor — ฟรี
เขียนและเรียกใช้โค้ดจริงในเบราว์เซอร์ของคุณ รับความช่วยเหลือทันทีจาก AI tutor 24/7 และเรียนรู้ต่อจากที่คุณหยุดบนเว็บหรือในแอป
- คอร์ส
- 29
- บทเรียน
- 105
คำถามที่พบบ่อย
บทเรียน “ข้อเสนอและการลงคะแนน” ฟรีหรือไม่
ใช่ — ข้อความเต็มของ “ข้อเสนอและการลงคะแนน” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Web3 & DApp Development Fundamentals ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Web3 & DApp Development Fundamentals มีบทเรียนทั้งหมด 4 บทเรียน
คุณจะเรียนรู้อะไรในบทเรียน “ข้อเสนอและการลงคะแนน”
สัญญาผู้ควบคุม คุณปฏิบัติ Web3 & DApp Development Fundamentals ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน
คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Web3 & DApp Development Fundamentals หรือไม่
ไม่จำเป็นต้องมีประสบการณ์มาก่อน Web3 & DApp Development Fundamentals บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 3 จากทั้งหมด 4 บทเรียน
บทเรียน “ข้อเสนอและการลงคะแนน” ใช้เวลานานแค่ไหน
บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย
ฉันเขียนและรันโค้ดในบทเรียน Web3 & DApp Development Fundamentals นี้ได้ไหม
ได้ บทเรียน Web3 & DApp Development Fundamentals ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ
บทเรียนทั้งหมดในหลักสูตรนี้
- DAO คืออะไร
- โทเค็นธรรมาภิบาล
- ข้อเสนอและการลงคะแนน
- ไทม์ล็อกและการดำเนินการ