I'm trying to create a crowdsale contract with open-zeppelin.
I want to pause the sale of tokens during the ICO period. I see there is this Pausable.sol which is to pause the contract (as per my understanding). I've called this pausable function in my crowdsale contract like the following:
contract SampleCrowdsale is CappedCrowdsale, Pausable { function SampleCrowdsale(uint256 _startTime, uint256 _endTime, uint256 _rate, uint256 _cap, address _wallet) public CappedCrowdsale(_cap) Crowdsale(_startTime, _endTime, _rate, _wallet) { } function createTokenContract() internal returns (MintableToken) { return new SampleCrowdsaleToken(); } }
After deploying the contract, , in the contract management page in Mist I can see the pause and unpause option. However, triggering them doesn't make any difference and the sale goes on. Am I doing something wrong here or this is not the way the pausable function works in opnezeppelin?
Best Answer
The
Pausable
contract you're inheriting from just addspause
andunpause
, which updates a state variablepaused
. But that's all it does by itself.You'll need to use the modifiers
whenPaused
andwhenNotPaused
in your contract. If you putwhenNotPaused
on a function, then that function won't be callable when the contract is in thepaused
state. (For example, you might want to put that on whatever function is selling people coins during your ICO.)