2

If a proposal is approved, how are ethers in the DAO contract transferred to the project?

How does the DAO contract work?

1

If a proposal is approved, how are ethers in the DAO contract transferred to the project?

Ethers in the DAO are transferred to the project by calling executeProposal():

function executeProposal(
    uint _proposalID,
    bytes _transactionData
) noEther returns (bool _success) {

    Proposal p = proposals[_proposalID];

    uint waitPeriod = p.newCurator
        ? splitExecutionPeriod
        : executeProposalPeriod;
    // If we are over deadline and waiting period, assert proposal is closed
    if (p.open && now > p.votingDeadline + waitPeriod) {
        closeProposal(_proposalID);
        return;
    }

    // Check if the proposal can be executed
    if (now < p.votingDeadline  // has the voting deadline arrived?
        // Have the votes been counted?
        || !p.open
        // Does the transaction code match the proposal?
        || p.proposalHash != sha3(p.recipient, p.amount, _transactionData)) {

        throw;
    }

    // If the curator removed the recipient from the whitelist, close the proposal
    // in order to free the deposit and allow unblocking of voters
    if (!isRecipientAllowed(p.recipient)) {
        closeProposal(_proposalID);
        p.creator.send(p.proposalDeposit);
        return;
    }

    bool proposalCheck = true;

    if (p.amount > actualBalance())
        proposalCheck = false;

    uint quorum = p.yea + p.nay;

    // require 53% for calling newContract()
    if (_transactionData.length >= 4 && _transactionData[0] == 0x68
        && _transactionData[1] == 0x37 && _transactionData[2] == 0xff
        && _transactionData[3] == 0x1e
        && quorum < minQuorum(actualBalance() + rewardToken[address(this)])) {

            proposalCheck = false;
    }

    if (quorum >= minQuorum(p.amount)) {
        if (!p.creator.send(p.proposalDeposit))
            throw;

        lastTimeMinQuorumMet = now;
        // set the minQuorum to 20% again, in the case it has been reached
        if (quorum > totalSupply / 5)
            minQuorumDivisor = 5;
    }

    // Execute result
    if (quorum >= minQuorum(p.amount) && p.yea > p.nay && proposalCheck) {
        if (!p.recipient.call.value(p.amount)(_transactionData))
            throw;

        p.proposalPassed = true;
        _success = true;

        // only create reward tokens when ether is not sent to the DAO itself and
        // related addresses. Proxy addresses should be forbidden by the curator.
        if (p.recipient != address(this) && p.recipient != address(rewardAccount)
            && p.recipient != address(DAOrewardAccount)
            && p.recipient != address(extraBalance)
            && p.recipient != address(curator)) {

            rewardToken[address(this)] += p.amount;
            totalRewardToken += p.amount;
        }
    }

    closeProposal(_proposalID);

    // Initiate event
    ProposalTallied(_proposalID, _success, quorum);
}


Code In executeProposal() That Transfers The DAO's Ethers To The Project

After a whole lot of checks are done, the bit of code that does the transfer is p.recipient.call.value(p.amount)(_transactionData) after checking that the minimum quorum is met, and there are more yeas than nays as executed in the following code:

    // Execute result
    if (quorum >= minQuorum(p.amount) && p.yea > p.nay && proposalCheck) {
        if (!p.recipient.call.value(p.amount)(_transactionData))
            throw;
        ...



How does the DAO contract work?

It is too complex to answer this question in a small Q&A like this. While it may be straightforward to understand the execution of the code, there are many subtleties and implications that can arise from the interaction of the different parts of the code and how the token holders and contractors execute the code.

Your starting point is EtherScan.io - The DAO - Source Code.

Then it would be good if you could break up your big question "How does the DAO contract work?" into smaller questions that can be answered in more simply, like the first part of your question in this post.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.