You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.3 KiB
51 lines
1.3 KiB
pragma solidity ^0.4.24;
|
|
|
|
import "../validation/TimedCrowdsale.sol";
|
|
import "../../token/ERC20/IERC20.sol";
|
|
import "../../math/SafeMath.sol";
|
|
|
|
/**
|
|
* @title PostDeliveryCrowdsale
|
|
* @dev Crowdsale that locks tokens from withdrawal until it ends.
|
|
*/
|
|
contract PostDeliveryCrowdsale is TimedCrowdsale {
|
|
using SafeMath for uint256;
|
|
|
|
mapping(address => uint256) private _balances;
|
|
|
|
constructor() internal {}
|
|
|
|
/**
|
|
* @dev Withdraw tokens only after crowdsale ends.
|
|
* @param beneficiary Whose tokens will be withdrawn.
|
|
*/
|
|
function withdrawTokens(address beneficiary) public {
|
|
require(hasClosed());
|
|
uint256 amount = _balances[beneficiary];
|
|
require(amount > 0);
|
|
_balances[beneficiary] = 0;
|
|
_deliverTokens(beneficiary, amount);
|
|
}
|
|
|
|
/**
|
|
* @return the balance of an account.
|
|
*/
|
|
function balanceOf(address account) public view returns(uint256) {
|
|
return _balances[account];
|
|
}
|
|
|
|
/**
|
|
* @dev Overrides parent by storing balances instead of issuing tokens right away.
|
|
* @param beneficiary Token purchaser
|
|
* @param tokenAmount Amount of tokens purchased
|
|
*/
|
|
function _processPurchase(
|
|
address beneficiary,
|
|
uint256 tokenAmount
|
|
)
|
|
internal
|
|
{
|
|
_balances[beneficiary] = _balances[beneficiary].add(tokenAmount);
|
|
}
|
|
|
|
}
|
|
|