Skip to content

Instantly share code, notes, and snippets.

@libertylocked
Last active November 29, 2017 20:17
Show Gist options
  • Save libertylocked/2d70739b23ec5d3f7b4d02bb15ed05c2 to your computer and use it in GitHub Desktop.
Save libertylocked/2d70739b23ec5d3f7b4d02bb15ed05c2 to your computer and use it in GitHub Desktop.
Basic payment mixing contract
/**
* Basic payment mixing contract
* Do not copy this contract! It's never been tested or audited
* It also lacks a withdraw function for payers
*/
pragma solidity 0.4.18;
contract MixingBasic {
address owner;
uint public amount;
mapping(address => bool) recipients;
mapping(address => bool) payers;
bool withdrawEnabled = false;
modifier onlyOwner() {
require(owner == msg.sender);
_;
}
modifier onlyRecipient() {
require(recipients[msg.sender]);
_;
}
function MixingBasic(uint _amount) public {
owner = msg.sender;
amount = _amount;
}
function addRecipient(address addr) onlyOwner() public {
require(!recipients[addr]);
recipients[addr] = true;
}
function openWidthdraw() onlyOwner() public {
require(!withdrawEnabled);
withdrawEnabled = true;
}
function sendMoney() payable public {
require(!payers[msg.sender]);
require(msg.value == amount);
payers[msg.sender] = true;
}
function recipientWithdraw() onlyRecipient() public {
require(withdrawEnabled);
recipients[msg.sender] = false;
msg.sender.transfer(amount);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment