Question regarding to Pausable Token Smart Contracts

Hi ! I just used OpenZeppelin not long time ago.
I need more information regarding to Pausable Token.

I have a few questions about it:

  1. These are my current code :

contract CustomToken is ERC20Detailed, ERC20Mintable {
string private constant token_name = "Custom Token";
string private constant token_symbol = "CST";
uint8 private constant token_decimals = 18;

    uint256 private constant INITIAL_SUPPLY = 5000;
    
    constructor () public ERC20Detailed(token_name, token_symbol, token_decimals) {
        _mint(msg.sender, INITIAL_SUPPLY * (10 ** uint256(token_decimals)));
    }
}

My first question is, if I want to add Pausable features, do I need simply change the 1st line to:

contract CustomToken is ERC20Detailed, ERC20Mintable, ERC20Pausable {}

Is this correct ? Or do I need to do additional steps ?

  1. By default, if I add ERC20Pausable to my token. It is paused already ? Or do I have to paused it after the smart contract is deployed ?

  2. By default, do we need to add PauserRole to the sender ? Or is it behaving like ERC20Mintable ? Where the deployer is automatically added as the first MinterRole.

  3. In case, I want to pause the trade only limited to some specific accounts not all, is this possible ?
    Is it currently supported ?

  4. If the token trade is paused. Does the CrowdSale still able to be done ?

Thank you.

Warm regards.

1 Like

Hi @Charles808

  1. Adding ERC20Pausable is the correct way

  2. It is not paused by default - there is the constructor of Pausable.sol

                constructor () internal {
                     _paused = false;
                 }
    
  3. msg.sender is a pauser by default - there is the constructor of PauserRole.sol

       constructor () internal {
                _addPauser(_msgSender());
            }
    
  4. I think it’s not supported

  5. PausableToken.sol pauses functions: transfer, transferFrom, approve, increaseApproval and decreaseApproval . If your Crowdsale contract uses one of those function it can’t work (it probably uses transfer for token delivery)

All the best

3 Likes

Hi @Charles808
Assuming @paulinablaszk excellent reply answered your question, can you please mark it as the solution to your question.

ERC20Pausable doesn’t stop token minting (you could add this functionality to your token) and if you use a MintedCrowdsale, then pausing the token doesn’t pause the Crowdsale as mint is used to deliver the tokens. Though you could allow pausing a Crowdsale using PausableCrowdsale

1 Like

Hi @paulinablaszk,

Thank you for response.
All of the answers actually can be found from the source code just like what you had stated.

But, since I’m still new using this library and also the solidity language. I still have doubt whether it is working as what I’ve thought.
Your answers has cleared doubt.

Great answers!

2 Likes

Hi @abcoathup,

Yes @paulinablaszk excellent reply had help me to clear my doubts.

But, while her answer is straight to the point.
Your answer give me more clue for how to handle it on different case.

So, it’s great that you anticipated what I’m going to ask next. Those extra information is really useful.

Thank you.

2 Likes

Hi @Charles808 please ask (and answer) all the questions that you need. It helps everyone in the community now and in the future.

It’s nice I could help :slight_smile: It is important to dispel all doubts, especially in the case of smart contracts

1 Like

Hi paulinablaszk
How did you implement Pausable functionality in smart contract i need to know i am new in to ethereum and solidity and i am working on ERC20 Project

Maybe you can have a look this Pausable ERC20 token: openzeppelin-contracts/ERC20Pausable.sol