Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
97 lines (83 sloc) 2.94 KB
pragma solidity ^0.4.21;
import './ManagedToken.sol';
/**
* @title TransferLimitedToken
* @dev Token with ability to limit transfers within wallets included in limitedWallets list for certain period of time
*/
contract TransferLimitedToken is ManagedToken {
uint256 public constant LIMIT_TRANSFERS_PERIOD = 365 days;
mapping(address => bool) public limitedWallets;
uint256 public limitEndDate;
address public limitedWalletsManager;
bool public isLimitEnabled;
event TransfersEnabled();
modifier onlyManager() {
require(msg.sender == limitedWalletsManager);
_;
}
/**
* @dev Check if transfer between addresses is available
* @param _from From address
* @param _to To address
*/
modifier canTransfer(address _from, address _to) {
require(now >= limitEndDate || !isLimitEnabled || (!limitedWallets[_from] && !limitedWallets[_to]));
_;
}
/**
* @dev TransferLimitedToken constructor
* @param _limitStartDate Limit start date
* @param _listener Token listener(address can be 0x0)
* @param _owners Owners list
* @param _limitedWalletsManager Address used to add/del wallets from limitedWallets
*/
function TransferLimitedToken(
uint256 _limitStartDate,
address _listener,
address[] _owners,
address _limitedWalletsManager
) public ManagedToken(_listener, _owners)
{
limitEndDate = _limitStartDate + LIMIT_TRANSFERS_PERIOD;
isLimitEnabled = true;
limitedWalletsManager = _limitedWalletsManager;
}
/**
* @dev Enable token transfers
*/
function enableTransfers() public {
require(msg.sender == limitedWalletsManager);
allowTransfers = true;
TransfersEnabled();
}
/**
* @dev Add address to limitedWallets
* @dev Can be called only by manager
*/
function addLimitedWalletAddress(address _wallet) public {
require(msg.sender == limitedWalletsManager || ownerByAddress[msg.sender]);
limitedWallets[_wallet] = true;
}
/**
* @dev Del address from limitedWallets
* @dev Can be called only by manager
*/
function delLimitedWalletAddress(address _wallet) public onlyManager {
limitedWallets[_wallet] = false;
}
/**
* @dev Disable transfer limit manually. Can be called only by manager
*/
function disableLimit() public onlyManager {
isLimitEnabled = false;
}
function transfer(address _to, uint256 _value) public canTransfer(msg.sender, _to) returns (bool) {
return super.transfer(_to, _value);
}
function transferFrom(address _from, address _to, uint256 _value) public canTransfer(_from, _to) returns (bool) {
return super.transferFrom(_from, _to, _value);
}
function approve(address _spender, uint256 _value) public canTransfer(msg.sender, _spender) returns (bool) {
return super.approve(_spender,_value);
}
}
You can’t perform that action at this time.