Last active
January 4, 2019 20:59
-
-
Save decanus/b0a9cbed1fdeb299fe6c1da39ae5a9d5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity 0.4.11; | |
contract TokenTransferProxy is Ownable { | |
modifier onlyAuthorized { | |
require(authorized[msg.sender]); | |
_; | |
} | |
modifier onlyApprovedByUser(address user) { | |
require(approvedByUser[user][msg.sender]); | |
_; | |
} | |
mapping (address => bool) public authorized; | |
mapping (address => mapping (address => bool) public approvedByUser; | |
function transferFrom(address token, address from, address to, uint value) | |
public | |
onlyAuthorized | |
onlyApprovedByUser(from) | |
returns (bool) | |
{ | |
return Token(token).transferFrom(from, to, value); | |
} | |
function approve(address spender) public { | |
require(authorized[spender]); | |
authorizedByUser[msg.sender][spender] = true; | |
} | |
function unapprove(address spender) public { | |
authorizedByUser[msg.sender][spender] = false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment