How DAOs Work Under the Hood: Smart Contract Governance

Published on 4/11/2025 â€ĸ Categories: solidity, dao, web3, governance

How DAOs Work Under the Hood: Smart Contract Governance

What is a DAO?

A Decentralized Autonomous Organization is governed by code and token holders — not CEOs.

Key DAO Elements

  • Proposal creation
  • Voting (weighted by tokens)
  • Execution logic

Example DAO Contract

solidity
contract SimpleDAO {
struct Proposal {
address to;
bytes data;
uint votes;
bool executed;
}
Proposal[] public proposals;
mapping(uint => mapping(address => bool)) public voted;
function propose(address to, bytes calldata data) external {
proposals.push(Proposal(to, data, 0, false));
}
function vote(uint id) external {
require(!voted[id][msg.sender]);
proposals[id].votes += 1;
voted[id][msg.sender] = true;
}
function execute(uint id) external {
Proposal storage p = proposals[id];
require(!p.executed && p.votes > 5);
(bool success,) = p.to.call(p.data);
require(success);
p.executed = true;
}
}

UI Mockup

DAO UIDAO UI

Tooling

Tips

  • Delegate voting power
  • Use Safe multisig for treasury management