A factory library that deploys payment splitting contracts
Historical Significance
Part of a 2016 attempt to sell working organisations as deployable parts: a governance contract, a token or a payment splitter bought from a counter for a fee, with the created contract's shape published on chain beside it.
Context
Deployed in the Homestead era, when deploying a contract meant compiling one yourself.
Key Facts
Description
CreatorSplitter is a factory library in Airalab's DAO toolkit. Its create function deploys a Splitter, a contract that divides everything sent to it between a list of recipients by share, so an organisation can route income without a human step. Deployed on 23 November 2016 by 0x4af013afbadb22d8a88c92d68fc96b033b9ebb8a and recovered from airalab/core.
Spurious Dragon Era
Continued DoS protection. State trie clearing.
Bytecode Overview
Verified Source Available
This contract has verified source code on Etherscan.
Show source code (Solidity)
// Submitted by EthereumHistory (ethereumhistory.com)
pragma solidity ^0.4.4;
contract Splitter {
struct Holder {
address account;
uint8 part;
uint payout;
}
Holder[] holders;
mapping(address => uint) holderId;
function getHolder(uint _index) constant returns (address, uint8, uint) {
var holder = holders[_index];
return (holder.account, holder.part, holder.payout);
}
function Splitter(address[] _accounts, uint8[] _parts) {
if (_accounts.length != _parts.length) throw;
uint8 sum = 0;
for (uint i = 0; i < _accounts.length; ++i) {
// Append holder
holders.push(Holder(_accounts[i], _parts[i], 0));
// Indexing by address
holderId[_accounts[i]] = holders.length - 1;
// Sum part
sum += _parts[i];
}
// Check when parts correct
if (sum != 100) throw;
}
/**
* @dev Withdraw accumulated contract value according to ratio percent
*/
function withdraw() {
var id = holderId[msg.sender];
if (holders[id].part == 0) throw;
// Total holder value
var value = totalReceived * holders[id].part / 100;
// Check for payout
if (value > holders[id].payout) {
// Cacl payout diff
var out = value - holders[id].payout;
// Send difference
if (!holders[id].account.send(out)) throw;
holders[id].payout += out;
}
}
/* Total received money to contract */
uint public totalReceived = 0;
/**
* @dev Received log
*/
function () payable {
Received(msg.sender, msg.value);
totalReceived += msg.value;
}
event Received(address indexed sender, uint indexed value);
}
pragma solidity ^0.4.4;
library CreatorSplitter {
function create(address[] _accounts, uint8[] _parts) returns (Splitter)
{ return new Splitter(_accounts, _parts); }
function version() constant returns (string)
{ return "v0.5.0 (8d598c30)"; }
function abi() constant returns (string)
{ return '[{"constant":false,"inputs":[],"name":"withdraw","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"totalReceived","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_index","type":"uint256"}],"name":"getHolder","outputs":[{"name":"","type":"address"},{"name":"","type":"uint8"},{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"inputs":[{"name":"_accounts","type":"address[]"},{"name":"_parts","type":"uint8[]"}],"type":"constructor"},{"payable":true,"type":"fallback"},{"anonymous":false,"inputs":[{"indexed":true,"name":"sender","type":"address"},{"indexed":true,"name":"value","type":"uint256"}],"name":"Received","type":"event"}]'; }
}
External Links
Related contracts
AddressList
Same deployerA doubly linked list of addresses, deployed as a shared library
0xb0af78...dff94bAugust 18, 2016Contract 0x7e62ca...86e943
Same deployerAn address to address map with iteration, deployed as a shared library
0x7e62ca...86e943August 18, 2016CreatorTokenEmission
Same deployerA factory library that deploys mintable and burnable tokens, and hands back their ABI
0x63bfd6...63231eAugust 18, 2016CreatorTokenEther
Same deployerA factory library that deploys tokens backed one for one by ether held in the token
0x01f568...7b8312August 18, 2016AddressList
Same deployerA doubly linked list of addresses, deployed as a shared library
0xb51afd...224574August 25, 2016Contract 0xed6216...c0bce9
Same deployerAn address to address map with iteration, deployed as a shared library
0xed6216...c0bce9August 25, 2016