Skip to content

What is this contract?

bartwr edited this page Oct 29, 2017 · 3 revisions

This contract does one simple thing on execution:

If there's more than 0.2 ETH on the address -> Pay out to defined addresses

The addresses are defined at time of deployment of the contract.

Details

contract MiningDAO {

The address variable contains an array with ETH addresses to pay out to.

  address[] public investors;

This is the default function that is called everytime anyone funds are sent to the contract:

function () payable {
    address contract_ = this;

We split the total balance of this contract over all payout addresses.

The contract keeps a bit of the balance for itself, so it can pay transaction costs.

    uint256 balance = contract_.balance;
    uint256 amount = (balance / investors.length) - 0.01 ether;

We check if the balance is more than 0.2 ether:

    if(amount >= 0.2 ether) {

if so: now we can send the chunks of balance to the payout addresses:

        for(uint x = 0; x < investors.length; x++) {
            if (!investors[x].send(amount)) {
               revert();
            }
        }
    }
}

(The payout address are given at deployment of the contract:)

function MiningDAO(address[] investors_) {
    investors = investors_;
}

}


The contract can be used if you want to automatically split the income of an Ethereum miner address, for example.

Do you have improvements, suggested modifications, etc? Place an issue!

Clone this wiki locally