5

I run a mining farm along with other partners. Using eth-proxy I can only set one payout address for each machine. I'd like to setup a contract so that any payments that go to the primary mining payout address are automatically split up and sent to 3 addresses, with each address getting a percentage.

5

You can't exactly automatically distribute the payments, but you can come pretty close.

contract SplitPayment{

    address[3] addresses;

    function SplitPayment(address[3] addrs){
        addresses = addrs;
    }

    function sendPayment() public {
        uint balance = this.balance;
        for(uint i; i<3; i++){
            addresses[i].send(balance/3);
        }
    }

    function(){
        sendPayment();
    }
}

If you deploy this contract, then mine to that address, you can then send a transaction to it, with no value, and it will distribute the Ether it has collected evenly to the 3 accounts.

| improve this answer | |
  • Where and how would i specify the addresses to be send the payment? I am assuming under constructor parameters, but putting a comma separated list seems to result in my eth going nowhere when the contract is executed. Do i need to add brackets or something else? – user6363152 May 21 '16 at 2:34
  • Use an array: ["0xabc","0xdef","0x123"] – Tjaden Hess May 21 '16 at 2:39
  • You can also write an script on node.js for example that at every hour call the function of that contract. Of course you will need to do it from a address with founds. – AugustoL May 21 '16 at 7:25
  • Actually, if you wanted to you could use the alarm clock – Tjaden Hess May 21 '16 at 14:14
2

Calling a contract require more gas, so be sure either you solo mine (network looks to be unlimited on gas when sending rewards) or make sure that your pool put enough gas in the transaction. You can look at a previous answer about splitting rewards with a smart contract.

Then, if you are sure that the reward transaction will be provided with enough gas, the contract is a simple contract as shown in the @TjadenHess answer. The addresses to split the reward to are set at contract creation in it's constructor. You only have to set the contract address in your miner and you're done.

| improve this answer | |
0

As addition to Tjaden Hess' answer:

In order to make a clean split with no ether left in the balance of the contract, you could do something like this:

function sendPayment() public {
    uint balance = this.balance;
    uint l = addresses.length;

    for(uint i=0; i<l-1; i++){
        addresses[i].send(balance/l);
    }

    // send the rest to the last address
    addresses[l-1].send(this.balance);
}
| 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.