title: How to fix "Gas estimation failed error" when transferring Minter and Owner roles to a new account in one function?
body: <p>I have a simple ERC20 contract which is ERC20Detailed, ERC20Mintable and Ownable. On deployment I want:</p>
  
  <ol>
  <li>Add Minter to a new account, passed in the argument</li>
  <li>Remove deployer from Minter role</li>
  <li>Transfer Ownership to a new account, passed in the argument</li>
  </ol>
  
  <p>Same actions I have declared in another function called <em>transferRights()</em></p>
  
  <p>The problem is that I am getting "Gas estimation failed error", which isn't because I don't have enough gas, but there might be a bug in the code. If I remove first two (addMinter, renounceMinter) actions, then it's all good (No warning).</p>
  
  <p>I have deployed this contract on Ropsten, where I was getting same error in the beginning, but by commenting first two actions and adding them again transaction went through without any warning and Contract works as it supposed to be.</p>
  
  <pre><code>pragma solidity ^0.5.0;
  
  import "github.com/OpenZeppelin/openzeppelin-solidity/contracts/token/ERC20/ERC20Detailed.sol";
  import "github.com/OpenZeppelin/openzeppelin-solidity/contracts/token/ERC20/ERC20Mintable.sol";
  import "github.com/OpenZeppelin/openzeppelin-solidity/contracts/ownership/Ownable.sol";
  
  
  contract MyToken is ERC20Detailed, ERC20Mintable, Ownable {    
  
      uint256 private msgCount;
      address constant ETHER = address(0);
      mapping(uint256 =&gt; string) private message;
  
      constructor(string memory name, string memory symbol, uint8 decimals, address _newOwner) ERC20Detailed(name, symbol, decimals) public {
          addMinter(_newOwner);
          renounceMinter();
          transferOwnership(_newOwner);
      }
  
      function doMint(uint256 _amount, address _beneficiary1, address _beneficiary2, address _beneficiary3) public onlyOwner {
          require (_amount &gt;= 0);
          require(_beneficiary1 != ETHER &amp;&amp; _beneficiary2 != ETHER &amp;&amp; _beneficiary3 != ETHER);
          require(mint(_beneficiary1, _amount.mul(20).div(100)));
          require(mint(_beneficiary2, _amount.mul(30).div(100)));
          require(mint(_beneficiary3, _amount.mul(50).div(100)));
      }
  
      function setMessage(string memory _message) public onlyOwner {
          message[msgCount] = _message;
          msgCount = msgCount.add(1);
      }
  
      function readMessage(uint256 _msgId) public view returns(string memory) {
          return message[_msgId];
      }
  
      function transferRights(address _newOwner) public onlyOwner {
          addMinter(_newOwner);
          renounceMinter();
          transferOwnership(_newOwner);
      }
  }
  </code></pre>
  
  <p>I can still send a transaction and deploy I guess (as mentioned above I did it on testnet), even though it is saying "The transaction execution will likely fail", but I want to make sure that code is bug free. Any feedback would be greatly appreciated. Thanks!</p>
  
  <p><strong>UPDATE</strong>
  Problem found! In the constructor I was passing the same account address as I was using for deploying. Thus, it resulted adding the Minter role to myself, which I already had. </p>