OpenZeppelin Pausable Contract – Pausable Contract in OpenZeppelin

icoopenzeppelintokens

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 adds pause and unpause, which updates a state variable paused. But that's all it does by itself.

You'll need to use the modifiers whenPaused and whenNotPaused in your contract. If you put whenNotPaused on a function, then that function won't be callable when the contract is in the paused state. (For example, you might want to put that on whatever function is selling people coins during your ICO.)

Related Topic