Created
July 21, 2018 23:08
-
-
Save kejace/20ec7a4ba669ccdebbba71717ff9f038 to your computer and use it in GitHub Desktop.
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=undefined&optimize=false&gist=
This file contains 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
contract TokenControllerI { | |
function transferAllowed(address _from, address _to) external view returns (bool); | |
} | |
contract TokenController is TokenControllerI{ | |
uint MIN_COUNT = 10; // this should be _from specific | |
address tokenContract = 0xabba; | |
address registryContract = 0xdeadbeef; | |
mapping(address => uint) numTransfers; | |
function transferAllowed(address _from, address _to) external view returns (bool){ | |
tallyTransfer(_from, _to); | |
if(numTransfers[_from] > MIN_COUNT){ | |
return true; | |
} else { | |
return false; | |
} | |
} | |
function tallyTransfer (address _from, address _to) private { | |
// insert proper logic here | |
if(msg.sender == tokenContract && _to == registryContract){ | |
numTransfers[_from]++; | |
} else { | |
// someone else than tokenContract called tallyTransfer so do nothing | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment