Skip to content

Instantly share code, notes, and snippets.

@buddies2705
Created October 29, 2018 00:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save buddies2705/a8bcb120e030672340547bdb9ffe08c7 to your computer and use it in GitHub Desktop.
Save buddies2705/a8bcb120e030672340547bdb9ffe08c7 to your computer and use it in GitHub Desktop.
Open Zeppelin secondary permission manager
pragma solidity ^0.4.24;
import "../../math/SafeMath.sol";
import "../../ownership/Secondary.sol";
contract Escrow is Secondary {
using SafeMath for uint256;
event Deposited(address indexed payee, uint256 weiAmount);
event Withdrawn(address indexed payee, uint256 weiAmount);
mapping(address => uint256) private _deposits;
function depositsOf(address payee) public view returns (uint256) {
return _deposits[payee];
}
function deposit(address payee) public onlyPrimary payable {
uint256 amount = msg.value;
_deposits[payee] = _deposits[payee].add(amount);
emit Deposited(payee, amount);
}
function withdraw(address payee) public onlyPrimary {
uint256 payment = _deposits[payee];
_deposits[payee] = 0;
payee.transfer(payment);
emit Withdrawn(payee, payment);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment