Transaction Hash:
Block:
7784735 at May-18-2019 02:43:55 PM +UTC
Transaction Fee:
0.000265375 ETH
$0.54
Gas Used:
24,125 Gas / 11 Gwei
Account State Difference:
| Address | Before | After | State Difference | ||
|---|---|---|---|---|---|
|
0x2a65Aca4...135398226
Miner
| (DwarfPool) | 831.443149735395070401 Eth | 831.443415110395070401 Eth | 0.000265375 | |
| 0xeA82738e...7615CB349 |
0.015988684873448 Eth
Nonce: 283
|
0.015723309873448 Eth
Nonce: 284
| 0.000265375 |
Execution Trace
RateChangeCrowdsaleToken.transfer( to=0x004968535989d1B61b4fFf94DeDF0e369B1524bE, value=1000000000 )
{"mongo-use-first.sol":{"content":"pragma solidity 0.5.2;\n\nlibrary Roles {\n struct Role {\n mapping (address =\u003e bool) bearer;\n }\n\n /**\n * @dev give an account access to this role\n */\n function add(Role storage role, address account) internal {\n require(account != address(0));\n require(!has(role, account));\n\n role.bearer[account] = true;\n }\n\n /**\n * @dev remove an account\u0027s access to this role\n */\n function remove(Role storage role, address account) internal {\n require(account != address(0));\n require(has(role, account));\n\n role.bearer[account] = false;\n }\n\n /**\n * @dev check if an account has this role\n * @return bool\n */\n function has(Role storage role, address account) internal view returns (bool) {\n require(account != address(0));\n return role.bearer[account];\n }\n}\n\ncontract ReentrancyGuard {\n /// @dev counter to allow mutex lock with only one SSTORE operation\n uint256 private _guardCounter;\n\n constructor () internal {\n // The counter starts at one to prevent changing it from zero to a non-zero\n // value, which is a more expensive operation.\n _guardCounter = 1;\n }\n\n /**\n * @dev Prevents a contract from calling itself, directly or indirectly.\n * Calling a `nonReentrant` function from another `nonReentrant`\n * function is not supported. It is possible to prevent this from happening\n * by making the `nonReentrant` function external, and make it call a\n * `private` function that does the actual work.\n */\n modifier nonReentrant() {\n _guardCounter += 1;\n uint256 localCounter = _guardCounter;\n _;\n require(localCounter == _guardCounter);\n }\n}\n\nlibrary SafeMath {\n /**\n * @dev Multiplies two unsigned integers, reverts on overflow.\n */\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n // Gas optimization: this is cheaper than requiring \u0027a\u0027 not being zero, but the\n // benefit is lost if \u0027b\u0027 is also tested.\n // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n require(c / a == b);\n\n return c;\n }\n\n /**\n * @dev Integer division of two unsigned integers truncating the quotient, reverts on division by zero.\n */\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n // Solidity only automatically asserts when dividing by 0\n require(b \u003e 0);\n uint256 c = a / b;\n // assert(a == b * c + a % b); // There is no case in which this doesn\u0027t hold\n\n return c;\n }\n\n /**\n * @dev Subtracts two unsigned integers, reverts on overflow (i.e. if subtrahend is greater than minuend).\n */\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n require(b \u003c= a);\n uint256 c = a - b;\n\n return c;\n }\n\n /**\n * @dev Adds two unsigned integers, reverts on overflow.\n */\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n require(c \u003e= a);\n\n return c;\n }\n\n /**\n * @dev Divides two unsigned integers and returns the remainder (unsigned integer modulo),\n * reverts when dividing by zero.\n */\n function mod(uint256 a, uint256 b) internal pure returns (uint256) {\n require(b != 0);\n return a % b;\n }\n}\n\ninterface IERC20 {\n function transfer(address to, uint256 value) external returns (bool);\n\n function approve(address spender, uint256 value) external returns (bool);\n\n function transferFrom(address from, address to, uint256 value) external returns (bool);\n\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address who) external view returns (uint256);\n\n function allowance(address owner, address spender) external view returns (uint256);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(address indexed owner, address indexed spender, uint256 value);\n}\n\ncontract IgnorePausedRole {\n using Roles for Roles.Role;\n\n event IgnorePausedAdded(address indexed account);\n event IgnorePausedRemoved(address indexed account);\n\n Roles.Role private _ignorePausers;\n\n constructor () internal {\n _addIgnorePaused(msg.sender);\n }\n\n modifier onlyIgnorePaused() {\n require(isIgnorePaused(msg.sender));\n _;\n }\n\n function isIgnorePaused(address account) public view returns (bool) {\n return _ignorePausers.has(account);\n }\n\n function addIgnorePaused(address account) public onlyIgnorePaused {\n _addIgnorePaused(account);\n }\n\n function renounceIgnorePaused() public {\n _removeIgnorePaused(msg.sender);\n }\n\n function _addIgnorePaused(address account) internal {\n _ignorePausers.add(account);\n emit IgnorePausedAdded(account);\n }\n\n function _removeIgnorePaused(address account) internal {\n _ignorePausers.remove(account);\n emit IgnorePausedRemoved(account);\n }\n}\n\ncontract ERC20 is IERC20 {\n using SafeMath for uint256;\n\n mapping (address =\u003e uint256) private _balances;\n\n mapping (address =\u003e mapping (address =\u003e uint256)) private _allowed;\n\n uint256 private _totalSupply;\n\n /**\n * @dev Total number of tokens in existence\n */\n function totalSupply() public view returns (uint256) {\n return _totalSupply;\n }\n\n /**\n * @dev Gets the balance of the specified address.\n * @param owner The address to query the balance of.\n * @return An uint256 representing the amount owned by the passed address.\n */\n function balanceOf(address owner) public view returns (uint256) {\n return _balances[owner];\n }\n\n /**\n * @dev Function to check the amount of tokens that an owner allowed to a spender.\n * @param owner address The address which owns the funds.\n * @param spender address The address which will spend the funds.\n * @return A uint256 specifying the amount of tokens still available for the spender.\n */\n function allowance(address owner, address spender) public view returns (uint256) {\n return _allowed[owner][spender];\n }\n\n /**\n * @dev Transfer token for a specified address\n * @param to The address to transfer to.\n * @param value The amount to be transferred.\n */\n function transfer(address to, uint256 value) public returns (bool) {\n _transfer(msg.sender, to, value);\n return true;\n }\n\n /**\n * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.\n * Beware that changing an allowance with this method brings the risk that someone may use both the old\n * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this\n * race condition is to first reduce the spender\u0027s allowance to 0 and set the desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n * @param spender The address which will spend the funds.\n * @param value The amount of tokens to be spent.\n */\n function approve(address spender, uint256 value) public returns (bool) {\n _approve(msg.sender, spender, value);\n return true;\n }\n\n /**\n * @dev Transfer tokens from one address to another.\n * Note that while this function emits an Approval event, this is not required as per the specification,\n * and other compliant implementations may not emit the event.\n * @param from address The address which you want to send tokens from\n * @param to address The address which you want to transfer to\n * @param value uint256 the amount of tokens to be transferred\n */\n function transferFrom(address from, address to, uint256 value) public returns (bool) {\n _transfer(from, to, value);\n _approve(from, msg.sender, _allowed[from][msg.sender].sub(value));\n return true;\n }\n\n /**\n * @dev Increase the amount of tokens that an owner allowed to a spender.\n * approve should be called when allowed_[_spender] == 0. To increment\n * allowed value is better to use this function to avoid 2 calls (and wait until\n * the first transaction is mined)\n * From MonolithDAO Token.sol\n * Emits an Approval event.\n * @param spender The address which will spend the funds.\n * @param addedValue The amount of tokens to increase the allowance by.\n */\n function increaseAllowance(address spender, uint256 addedValue) public returns (bool) {\n _approve(msg.sender, spender, _allowed[msg.sender][spender].add(addedValue));\n return true;\n }\n\n /**\n * @dev Decrease the amount of tokens that an owner allowed to a spender.\n * approve should be called when allowed_[_spender] == 0. To decrement\n * allowed value is better to use this function to avoid 2 calls (and wait until\n * the first transaction is mined)\n * From MonolithDAO Token.sol\n * Emits an Approval event.\n * @param spender The address which will spend the funds.\n * @param subtractedValue The amount of tokens to decrease the allowance by.\n */\n function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) {\n _approve(msg.sender, spender, _allowed[msg.sender][spender].sub(subtractedValue));\n return true;\n }\n\n /**\n * @dev Transfer token for a specified addresses\n * @param from The address to transfer from.\n * @param to The address to transfer to.\n * @param value The amount to be transferred.\n */\n function _transfer(address from, address to, uint256 value) internal {\n require(to != address(0));\n\n _balances[from] = _balances[from].sub(value);\n _balances[to] = _balances[to].add(value);\n emit Transfer(from, to, value);\n }\n\n /**\n * @dev Internal function that mints an amount of the token and assigns it to\n * an account. This encapsulates the modification of balances such that the\n * proper events are emitted.\n * @param account The account that will receive the created tokens.\n * @param value The amount that will be created.\n */\n function _mint(address account, uint256 value) internal {\n require(account != address(0));\n\n _totalSupply = _totalSupply.add(value);\n _balances[account] = _balances[account].add(value);\n emit Transfer(address(0), account, value);\n }\n\n /**\n * @dev Internal function that burns an amount of the token of a given\n * account.\n * @param account The account whose tokens will be burnt.\n * @param value The amount that will be burnt.\n */\n function _burn(address account, uint256 value) internal {\n require(account != address(0));\n\n _totalSupply = _totalSupply.sub(value);\n _balances[account] = _balances[account].sub(value);\n emit Transfer(account, address(0), value);\n }\n\n /**\n * @dev Approve an address to spend another addresses\u0027 tokens.\n * @param owner The address that owns the tokens.\n * @param spender The address that will spend the tokens.\n * @param value The number of tokens that can be spent.\n */\n function _approve(address owner, address spender, uint256 value) internal {\n require(spender != address(0));\n require(owner != address(0));\n\n _allowed[owner][spender] = value;\n emit Approval(owner, spender, value);\n }\n\n /**\n * @dev Internal function that burns an amount of the token of a given\n * account, deducting from the sender\u0027s allowance for said account. Uses the\n * internal burn function.\n * Emits an Approval event (reflecting the reduced allowance).\n * @param account The account whose tokens will be burnt.\n * @param value The amount that will be burnt.\n */\n function _burnFrom(address account, uint256 value) internal {\n _burn(account, value);\n _approve(account, msg.sender, _allowed[account][msg.sender].sub(value));\n }\n}\n\ncontract RateChangerRole {\n using Roles for Roles.Role;\n\n event RateChangerAdded(address indexed account);\n event RateChangerRemoved(address indexed account);\n\n Roles.Role private _RateChangers;\n\n constructor () internal {\n _addRateChanger(msg.sender);\n }\n\n modifier onlyRateChanger() {\n require(isRateChanger(msg.sender), \"Sender not authorized to change the rate\");\n _;\n }\n\n function isRateChanger(address account) public view returns (bool) {\n return _RateChangers.has(account);\n }\n\n function addRateChanger(address account) public onlyRateChanger {\n _addRateChanger(account);\n }\n\n function renounceRateChanger() public {\n _removeRateChanger(msg.sender);\n }\n\n function _addRateChanger(address account) internal {\n _RateChangers.add(account);\n emit RateChangerAdded(account);\n }\n\n function _removeRateChanger(address account) internal {\n _RateChangers.remove(account);\n emit RateChangerRemoved(account);\n }\n}\n\ncontract ERC20Detailed is IERC20 {\n string private _name;\n string private _symbol;\n uint8 private _decimals;\n\n constructor (string memory name, string memory symbol, uint8 decimals) public {\n _name = name;\n _symbol = symbol;\n _decimals = decimals;\n }\n\n /**\n * @return the name of the token.\n */\n function name() public view returns (string memory) {\n return _name;\n }\n\n /**\n * @return the symbol of the token.\n */\n function symbol() public view returns (string memory) {\n return _symbol;\n }\n\n /**\n * @return the number of decimals of the token.\n */\n function decimals() public view returns (uint8) {\n return _decimals;\n }\n}\n\ncontract MinterRole {\n using Roles for Roles.Role;\n\n event MinterAdded(address indexed account);\n event MinterRemoved(address indexed account);\n\n Roles.Role private _minters;\n\n constructor () internal {\n _addMinter(msg.sender);\n }\n\n modifier onlyMinter() {\n require(isMinter(msg.sender));\n _;\n }\n\n function isMinter(address account) public view returns (bool) {\n return _minters.has(account);\n }\n\n function addMinter(address account) public onlyMinter {\n _addMinter(account);\n }\n\n function renounceMinter() public {\n _removeMinter(msg.sender);\n }\n\n function _addMinter(address account) internal {\n _minters.add(account);\n emit MinterAdded(account);\n }\n\n function _removeMinter(address account) internal {\n _minters.remove(account);\n emit MinterRemoved(account);\n }\n}\n\ncontract PauserRole {\n using Roles for Roles.Role;\n\n event PauserAdded(address indexed account);\n event PauserRemoved(address indexed account);\n\n Roles.Role private _pausers;\n\n constructor () internal {\n _addPauser(msg.sender);\n }\n\n modifier onlyPauser() {\n require(isPauser(msg.sender));\n _;\n }\n\n function isPauser(address account) public view returns (bool) {\n return _pausers.has(account);\n }\n\n function addPauser(address account) public onlyPauser {\n _addPauser(account);\n }\n\n function renouncePauser() public {\n _removePauser(msg.sender);\n }\n\n function _addPauser(address account) internal {\n _pausers.add(account);\n emit PauserAdded(account);\n }\n\n function _removePauser(address account) internal {\n _pausers.remove(account);\n emit PauserRemoved(account);\n }\n}\n\ncontract WhitelistAdminRole {\n using Roles for Roles.Role;\n\n event WhitelistAdminAdded(address indexed account);\n event WhitelistAdminRemoved(address indexed account);\n\n Roles.Role private _whitelistAdmins;\n\n constructor () internal {\n _addWhitelistAdmin(msg.sender);\n }\n\n modifier onlyWhitelistAdmin() {\n require(isWhitelistAdmin(msg.sender));\n _;\n }\n\n function isWhitelistAdmin(address account) public view returns (bool) {\n return _whitelistAdmins.has(account);\n }\n\n function addWhitelistAdmin(address account) public onlyWhitelistAdmin {\n _addWhitelistAdmin(account);\n }\n\n function renounceWhitelistAdmin() public {\n _removeWhitelistAdmin(msg.sender);\n }\n\n function _addWhitelistAdmin(address account) internal {\n _whitelistAdmins.add(account);\n emit WhitelistAdminAdded(account);\n }\n\n function _removeWhitelistAdmin(address account) internal {\n _whitelistAdmins.remove(account);\n emit WhitelistAdminRemoved(account);\n }\n}\n\nlibrary SafeERC20 {\n using SafeMath for uint256;\n\n function safeTransfer(IERC20 token, address to, uint256 value) internal {\n require(token.transfer(to, value), \"Token could not be transfered\");\n }\n\n function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {\n require(token.transferFrom(from, to, value), \"Token could not be transfered\");\n }\n\n function safeApprove(IERC20 token, address spender, uint256 value) internal {\n // safeApprove should only be called when setting an initial allowance,\n // or when resetting it to zero. To increase and decrease it, use\n // \u0027safeIncreaseAllowance\u0027 and \u0027safeDecreaseAllowance\u0027\n require((value == 0) || (token.allowance(msg.sender, spender) == 0));\n require(token.approve(spender, value));\n }\n\n function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {\n uint256 newAllowance = token.allowance(address(this), spender).add(value);\n require(token.approve(spender, newAllowance));\n }\n\n function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {\n uint256 newAllowance = token.allowance(address(this), spender).sub(value);\n require(token.approve(spender, newAllowance));\n }\n}\n\ncontract WhitelistedRole is WhitelistAdminRole {\n using Roles for Roles.Role;\n\n event WhitelistedAdded(address indexed account);\n event WhitelistedRemoved(address indexed account);\n\n Roles.Role private _whitelisteds;\n\n modifier onlyWhitelisted() {\n require(isWhitelisted(msg.sender));\n _;\n }\n\n function isWhitelisted(address account) public view returns (bool) {\n return _whitelisteds.has(account);\n }\n\n function addWhitelisted(address account) public onlyWhitelistAdmin {\n _addWhitelisted(account);\n }\n\n function removeWhitelisted(address account) public onlyWhitelistAdmin {\n _removeWhitelisted(account);\n }\n\n function renounceWhitelisted() public {\n _removeWhitelisted(msg.sender);\n }\n\n function _addWhitelisted(address account) internal {\n _whitelisteds.add(account);\n emit WhitelistedAdded(account);\n }\n\n function _removeWhitelisted(address account) internal {\n _whitelisteds.remove(account);\n emit WhitelistedRemoved(account);\n }\n}\n\ncontract Crowdsale is ReentrancyGuard, RateChangerRole {\n using SafeMath for uint256;\n using SafeERC20 for IERC20;\n\n // The token being sold\n IERC20 private _token;\n\n // Address where funds are collected\n address payable private _wallet;\n\n // How many wei it cost for a token unit.\n // The rate is the conversion between wei and the smallest and indivisible token unit.\n // So, if you are using a rate of 1 with a ERC20Detailed token with 3 decimals called TOK\n // 1 wei will give you 1 unit, or 0.001 TOK.\n uint256 private _rate;\n\n // Amount of wei raised\n uint256 private _weiRaised;\n\n /** \n * @param rate Number of wei it costs for a token unit.\n * @dev The rate is the conversion between wei and the smallest and indivisible\n * token unit. So, if you are using a rate of 1 with a ERC20Detailed token\n * with 3 decimals called TOK, 1 wei will give you 1 unit, or 0.001 TOK.\n */\n function changeRate(uint256 rate)\n public onlyRateChanger\n {\n require(rate \u003e 0);\n _rate = rate;\n }\n\n /**\n * Event for token purchase logging\n * @param purchaser who paid for the tokens\n * @param beneficiary who got the tokens\n * @param value weis paid for purchase\n * @param amount amount of tokens purchased\n */\n event TokensPurchased(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount);\n\n /**\n * @param initialRate Number of token units a buyer gets per wei\n * @dev The initial rate is the conversion between wei and the smallest and indivisible\n * token unit. So, if you are using a rate of 1 with a ERC20Detailed token\n * with 3 decimals called TOK, 1 wei will give you 1 unit, or 0.001 TOK.\n * @param wallet Address where collected funds will be forwarded to\n * @param token Address of the token being sold\n */\n constructor (/*uint256 initialCoinsForCreator,*/ uint256 initialRate, address payable wallet, IERC20 token) public {\n require(initialRate \u003e 0, \"The initial rate must be above 0\");\n require(wallet != address(0), \"The wallet address must not be 0x0\");\n require(address(token) != address(0), \"The token address must not be 0x0\");\n\n _rate = initialRate;\n _wallet = wallet;\n _token = token;\n }\n\n /**\n * @dev fallback function ***DO NOT OVERRIDE***\n * Note that other contracts will transfer fund with a base gas stipend\n * of 2300, which is not enough to call buyTokens. Consider calling\n * buyTokens directly when purchasing tokens from a contract.\n */\n function () external payable {\n buyTokens(msg.sender);\n }\n\n /**\n * @return the token being sold.\n */\n function token() public view returns (IERC20) {\n return _token;\n }\n\n /**\n * @return the address where funds are collected.\n */\n function wallet() public view returns (address payable) {\n return _wallet;\n }\n\n /**\n * @return the number of token units a buyer gets per wei.\n */\n function rate() public view returns (uint256) {\n return _rate;\n }\n\n /**\n * @return the amount of wei raised.\n */\n function weiRaised() public view returns (uint256) {\n return _weiRaised;\n }\n\n /**\n * @dev low level token purchase ***DO NOT OVERRIDE***\n * This function has a non-reentrancy guard, so it shouldn\u0027t be called by\n * another `nonReentrant` function.\n * @param beneficiary Recipient of the token purchase\n */\n function buyTokens(address beneficiary) public nonReentrant payable {\n uint256 weiAmount = msg.value;\n _preValidatePurchase(beneficiary, weiAmount);\n\n // calculate token amount to be created\n uint256 tokens = _getTokenAmount(weiAmount);\n\n // update state\n _weiRaised = _weiRaised.add(weiAmount);\n\n _processPurchase(beneficiary, tokens);\n emit TokensPurchased(msg.sender, beneficiary, weiAmount, tokens);\n\n _updatePurchasingState(beneficiary, weiAmount);\n\n _forwardFunds();\n _postValidatePurchase(beneficiary, weiAmount);\n }\n\n /**\n * @dev Validation of an incoming purchase. Use require statements to revert state when conditions are not met.\n * Use `super` in contracts that inherit from Crowdsale to extend their validations.\n * Example from CappedCrowdsale.sol\u0027s _preValidatePurchase method:\n * super._preValidatePurchase(beneficiary, weiAmount);\n * require(weiRaised().add(weiAmount) \u003c= cap);\n * @param beneficiary Address performing the token purchase\n * @param weiAmount Value in wei involved in the purchase\n */\n function _preValidatePurchase(address beneficiary, uint256 weiAmount) internal view {\n require(beneficiary != address(0), \"Cannot send to 0 address\");\n require(weiAmount != 0, \"No ether sent\");\n }\n\n /**\n * @dev Validation of an executed purchase. Observe state and use revert statements to undo rollback when valid\n * conditions are not met.\n * @param beneficiary Address performing the token purchase\n * @param weiAmount Value in wei involved in the purchase\n */\n function _postValidatePurchase(address beneficiary, uint256 weiAmount) internal view {\n // solhint-disable-previous-line no-empty-blocks\n }\n\n /**\n * @dev Source of tokens. Override this method to modify the way in which the crowdsale ultimately gets and sends\n * its tokens.\n * @param beneficiary Address performing the token purchase\n * @param tokenAmount Number of tokens to be emitted\n */\n function _deliverTokens(address beneficiary, uint256 tokenAmount) internal {\n _token.safeTransfer(beneficiary, tokenAmount);\n }\n\n /**\n * @dev Executed when a purchase has been validated and is ready to be executed. Doesn\u0027t necessarily emit/send\n * tokens.\n * @param beneficiary Address receiving the tokens\n * @param tokenAmount Number of tokens to be purchased\n */\n function _processPurchase(address beneficiary, uint256 tokenAmount) internal {\n _deliverTokens(beneficiary, tokenAmount);\n }\n\n /**\n * @dev Override for extensions that require an internal state to check for validity (current user contributions,\n * etc.)\n * @param beneficiary Address receiving the tokens\n * @param weiAmount Value in wei involved in the purchase\n */\n function _updatePurchasingState(address beneficiary, uint256 weiAmount) internal {\n // solhint-disable-previous-line no-empty-blocks\n }\n\n /**\n * @dev Override to extend the way in which ether is converted to tokens.\n * @param weiAmount Value in wei to be converted into tokens\n * @return Number of tokens that can be purchased with the specified _weiAmount\n */\n function _getTokenAmount(uint256 weiAmount) internal view returns (uint256) {\n return weiAmount.div(_rate);\n }\n\n /**\n * @dev Determines how ETH is stored/forwarded on purchases.\n */\n function _forwardFunds() internal {\n _wallet.transfer(msg.value);\n }\n}\n\ncontract Pausable is PauserRole, IgnorePausedRole {\n event Paused(address account);\n event Unpaused(address account);\n\n bool private _paused;\n\n address private _creator;\n\n constructor () internal {\n _paused = false;\n _creator = msg.sender;\n }\n\n /**\n * @return true if the contract is paused, false otherwise.\n */\n function paused() public view returns (bool) {\n return _paused;\n }\n\n /**\n * @dev Modifier to make a function callable only when the contract is not paused. Allow the contract creator to have super powers.\n */\n modifier whenNotPaused() {\n require(!_paused || isIgnorePaused(msg.sender), \"Contract paused\");\n _;\n }\n\n /**\n * @dev Modifier to make a function callable only when the contract is paused.\n */\n modifier whenPaused() {\n require(_paused, \"Contract not paused\");\n _;\n }\n\n /**\n * @dev called by the owner to pause, triggers stopped state\n */\n function pause() public onlyPauser whenNotPaused {\n _paused = true;\n emit Paused(msg.sender);\n }\n\n /**\n * @dev called by the owner to unpause, returns to normal state\n */\n function unpause() public onlyPauser whenPaused {\n _paused = false;\n emit Unpaused(msg.sender);\n }\n}\n\ncontract ERC20Mintable is ERC20, MinterRole {\n /**\n * @dev Function to mint tokens\n * @param to The address that will receive the minted tokens.\n * @param value The amount of tokens to mint.\n * @return A boolean that indicates if the operation was successful.\n */\n function mint(address to, uint256 value) public onlyMinter returns (bool) {\n _mint(to, value);\n return true;\n }\n}\n\ncontract MintedCrowdsale is Crowdsale {\n /**\n * @dev Overrides delivery by minting tokens upon purchase.\n * @param beneficiary Token purchaser\n * @param tokenAmount Number of tokens to be minted\n */\n function _deliverTokens(address beneficiary, uint256 tokenAmount) internal {\n // Potentially dangerous assumption about the type of the token.\n require(ERC20Mintable(address(token())).mint(beneficiary, tokenAmount));\n }\n}\n\ncontract WhitelistCrowdsale is WhitelistedRole, Crowdsale {\n /**\n * @dev Extend parent behavior requiring beneficiary to be whitelisted. Note that no\n * restriction is imposed on the account sending the transaction.\n * @param _beneficiary Token beneficiary\n * @param _weiAmount Amount of wei contributed\n */\n function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal view {\n require(isWhitelisted(_beneficiary), \"Beneficiary address is not whitelisted\");\n super._preValidatePurchase(_beneficiary, _weiAmount);\n }\n}\n\ncontract ERC20Pausable is ERC20, Pausable {\n function transfer(address to, uint256 value) public whenNotPaused returns (bool) {\n return super.transfer(to, value);\n }\n\n function transferFrom(address from, address to, uint256 value) public whenNotPaused returns (bool) {\n return super.transferFrom(from, to, value);\n }\n\n function approve(address spender, uint256 value) public whenNotPaused returns (bool) {\n return super.approve(spender, value);\n }\n\n function increaseAllowance(address spender, uint addedValue) public whenNotPaused returns (bool success) {\n return super.increaseAllowance(spender, addedValue);\n }\n\n function decreaseAllowance(address spender, uint subtractedValue) public whenNotPaused returns (bool success) {\n return super.decreaseAllowance(spender, subtractedValue);\n }\n}\n\ncontract PausableCrowdsale is Crowdsale, Pausable {\n /**\n * @dev Validation of an incoming purchase. Use require statements to revert state when conditions are not met.\n * Use super to concatenate validations.\n * Adds the validation that the crowdsale must not be paused.\n * @param _beneficiary Address performing the token purchase\n * @param _weiAmount Value in wei involved in the purchase\n */\n function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal view whenNotPaused {\n return super._preValidatePurchase(_beneficiary, _weiAmount);\n }\n}\n\ncontract RateChangeCrowdsaleToken is ERC20, ERC20Detailed, ERC20Pausable {\n constructor (uint256 initialSupply, string memory name, string memory symbol, uint8 decimals) public ERC20Detailed(name, symbol, decimals) {\n // solhint-disable-previous-line no-empty-blocks\n _mint(msg.sender, initialSupply);\n }\n}\n\n/**\n * @title RateChangeCrowdsale\n * @dev This is an example of a fully fledged crowdsale.\n * The way to add new features to a base crowdsale is by multiple inheritance.\n *\n * After adding multiple features it\u0027s good practice to run integration tests\n * to ensure that subcontracts works together as intended.\n */\ncontract RateChangeCrowdsale is Crowdsale, WhitelistCrowdsale, PausableCrowdsale {\n constructor (\n uint256 rate,\n IERC20 token\n )\n public\n Crowdsale(rate, msg.sender, token)\n {}\n}\n"},"mongo-use-second.sol":{"content":"pragma solidity 0.5.2;\n// produced by the Solididy File Flattener (c) David Appleton 2018\n// contact : dave@akomba.com\n// released under Apache 2.0 licence\n// input /Users/mason/contracting/mongo/mongo-coin/crowdsale-contract/contracts/RateChangeCrowdsale.sol\n// flattened : Friday, 15-Feb-19 20:25:18 UTC\nlibrary Roles {\n struct Role {\n mapping (address =\u003e bool) bearer;\n }\n\n /**\n * @dev give an account access to this role\n */\n function add(Role storage role, address account) internal {\n require(account != address(0));\n require(!has(role, account));\n\n role.bearer[account] = true;\n }\n\n /**\n * @dev remove an account\u0027s access to this role\n */\n function remove(Role storage role, address account) internal {\n require(account != address(0));\n require(has(role, account));\n\n role.bearer[account] = false;\n }\n\n /**\n * @dev check if an account has this role\n * @return bool\n */\n function has(Role storage role, address account) internal view returns (bool) {\n require(account != address(0));\n return role.bearer[account];\n }\n}\n\ncontract ReentrancyGuard {\n /// @dev counter to allow mutex lock with only one SSTORE operation\n uint256 private _guardCounter;\n\n constructor () internal {\n // The counter starts at one to prevent changing it from zero to a non-zero\n // value, which is a more expensive operation.\n _guardCounter = 1;\n }\n\n /**\n * @dev Prevents a contract from calling itself, directly or indirectly.\n * Calling a `nonReentrant` function from another `nonReentrant`\n * function is not supported. It is possible to prevent this from happening\n * by making the `nonReentrant` function external, and make it call a\n * `private` function that does the actual work.\n */\n modifier nonReentrant() {\n _guardCounter += 1;\n uint256 localCounter = _guardCounter;\n _;\n require(localCounter == _guardCounter);\n }\n}\n\nlibrary SafeMath {\n /**\n * @dev Multiplies two unsigned integers, reverts on overflow.\n */\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n // Gas optimization: this is cheaper than requiring \u0027a\u0027 not being zero, but the\n // benefit is lost if \u0027b\u0027 is also tested.\n // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n require(c / a == b);\n\n return c;\n }\n\n /**\n * @dev Integer division of two unsigned integers truncating the quotient, reverts on division by zero.\n */\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n // Solidity only automatically asserts when dividing by 0\n require(b \u003e 0);\n uint256 c = a / b;\n // assert(a == b * c + a % b); // There is no case in which this doesn\u0027t hold\n\n return c;\n }\n\n /**\n * @dev Subtracts two unsigned integers, reverts on overflow (i.e. if subtrahend is greater than minuend).\n */\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n require(b \u003c= a);\n uint256 c = a - b;\n\n return c;\n }\n\n /**\n * @dev Adds two unsigned integers, reverts on overflow.\n */\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n require(c \u003e= a);\n\n return c;\n }\n\n /**\n * @dev Divides two unsigned integers and returns the remainder (unsigned integer modulo),\n * reverts when dividing by zero.\n */\n function mod(uint256 a, uint256 b) internal pure returns (uint256) {\n require(b != 0);\n return a % b;\n }\n}\n\ninterface IERC20 {\n function transfer(address to, uint256 value) external returns (bool);\n\n function approve(address spender, uint256 value) external returns (bool);\n\n function transferFrom(address from, address to, uint256 value) external returns (bool);\n\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address who) external view returns (uint256);\n\n function allowance(address owner, address spender) external view returns (uint256);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(address indexed owner, address indexed spender, uint256 value);\n}\n\ncontract IgnorePausedRole {\n using Roles for Roles.Role;\n\n event IgnorePausedAdded(address indexed account);\n event IgnorePausedRemoved(address indexed account);\n\n Roles.Role private _ignorePausers;\n\n constructor () internal {\n _addIgnorePaused(msg.sender);\n }\n\n modifier onlyIgnorePaused() {\n require(isIgnorePaused(msg.sender));\n _;\n }\n\n function isIgnorePaused(address account) public view returns (bool) {\n return _ignorePausers.has(account);\n }\n\n function addIgnorePaused(address account) public onlyIgnorePaused {\n _addIgnorePaused(account);\n }\n\n function renounceIgnorePaused() public {\n _removeIgnorePaused(msg.sender);\n }\n\n function _addIgnorePaused(address account) internal {\n _ignorePausers.add(account);\n emit IgnorePausedAdded(account);\n }\n\n function _removeIgnorePaused(address account) internal {\n _ignorePausers.remove(account);\n emit IgnorePausedRemoved(account);\n }\n}\n\ncontract ERC20 is IERC20 {\n using SafeMath for uint256;\n\n mapping (address =\u003e uint256) private _balances;\n\n mapping (address =\u003e mapping (address =\u003e uint256)) private _allowed;\n\n uint256 private _totalSupply;\n\n /**\n * @dev Total number of tokens in existence\n */\n function totalSupply() public view returns (uint256) {\n return _totalSupply;\n }\n\n /**\n * @dev Gets the balance of the specified address.\n * @param owner The address to query the balance of.\n * @return An uint256 representing the amount owned by the passed address.\n */\n function balanceOf(address owner) public view returns (uint256) {\n return _balances[owner];\n }\n\n /**\n * @dev Function to check the amount of tokens that an owner allowed to a spender.\n * @param owner address The address which owns the funds.\n * @param spender address The address which will spend the funds.\n * @return A uint256 specifying the amount of tokens still available for the spender.\n */\n function allowance(address owner, address spender) public view returns (uint256) {\n return _allowed[owner][spender];\n }\n\n /**\n * @dev Transfer token for a specified address\n * @param to The address to transfer to.\n * @param value The amount to be transferred.\n */\n function transfer(address to, uint256 value) public returns (bool) {\n _transfer(msg.sender, to, value);\n return true;\n }\n\n /**\n * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.\n * Beware that changing an allowance with this method brings the risk that someone may use both the old\n * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this\n * race condition is to first reduce the spender\u0027s allowance to 0 and set the desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n * @param spender The address which will spend the funds.\n * @param value The amount of tokens to be spent.\n */\n function approve(address spender, uint256 value) public returns (bool) {\n _approve(msg.sender, spender, value);\n return true;\n }\n\n /**\n * @dev Transfer tokens from one address to another.\n * Note that while this function emits an Approval event, this is not required as per the specification,\n * and other compliant implementations may not emit the event.\n * @param from address The address which you want to send tokens from\n * @param to address The address which you want to transfer to\n * @param value uint256 the amount of tokens to be transferred\n */\n function transferFrom(address from, address to, uint256 value) public returns (bool) {\n _transfer(from, to, value);\n _approve(from, msg.sender, _allowed[from][msg.sender].sub(value));\n return true;\n }\n\n /**\n * @dev Increase the amount of tokens that an owner allowed to a spender.\n * approve should be called when allowed_[_spender] == 0. To increment\n * allowed value is better to use this function to avoid 2 calls (and wait until\n * the first transaction is mined)\n * From MonolithDAO Token.sol\n * Emits an Approval event.\n * @param spender The address which will spend the funds.\n * @param addedValue The amount of tokens to increase the allowance by.\n */\n function increaseAllowance(address spender, uint256 addedValue) public returns (bool) {\n _approve(msg.sender, spender, _allowed[msg.sender][spender].add(addedValue));\n return true;\n }\n\n /**\n * @dev Decrease the amount of tokens that an owner allowed to a spender.\n * approve should be called when allowed_[_spender] == 0. To decrement\n * allowed value is better to use this function to avoid 2 calls (and wait until\n * the first transaction is mined)\n * From MonolithDAO Token.sol\n * Emits an Approval event.\n * @param spender The address which will spend the funds.\n * @param subtractedValue The amount of tokens to decrease the allowance by.\n */\n function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) {\n _approve(msg.sender, spender, _allowed[msg.sender][spender].sub(subtractedValue));\n return true;\n }\n\n /**\n * @dev Transfer token for a specified addresses\n * @param from The address to transfer from.\n * @param to The address to transfer to.\n * @param value The amount to be transferred.\n */\n function _transfer(address from, address to, uint256 value) internal {\n require(to != address(0));\n\n _balances[from] = _balances[from].sub(value);\n _balances[to] = _balances[to].add(value);\n emit Transfer(from, to, value);\n }\n\n /**\n * @dev Internal function that mints an amount of the token and assigns it to\n * an account. This encapsulates the modification of balances such that the\n * proper events are emitted.\n * @param account The account that will receive the created tokens.\n * @param value The amount that will be created.\n */\n function _mint(address account, uint256 value) internal {\n require(account != address(0));\n\n _totalSupply = _totalSupply.add(value);\n _balances[account] = _balances[account].add(value);\n emit Transfer(address(0), account, value);\n }\n\n /**\n * @dev Internal function that burns an amount of the token of a given\n * account.\n * @param account The account whose tokens will be burnt.\n * @param value The amount that will be burnt.\n */\n function _burn(address account, uint256 value) internal {\n require(account != address(0));\n\n _totalSupply = _totalSupply.sub(value);\n _balances[account] = _balances[account].sub(value);\n emit Transfer(account, address(0), value);\n }\n\n /**\n * @dev Approve an address to spend another addresses\u0027 tokens.\n * @param owner The address that owns the tokens.\n * @param spender The address that will spend the tokens.\n * @param value The number of tokens that can be spent.\n */\n function _approve(address owner, address spender, uint256 value) internal {\n require(spender != address(0));\n require(owner != address(0));\n\n _allowed[owner][spender] = value;\n emit Approval(owner, spender, value);\n }\n\n /**\n * @dev Internal function that burns an amount of the token of a given\n * account, deducting from the sender\u0027s allowance for said account. Uses the\n * internal burn function.\n * Emits an Approval event (reflecting the reduced allowance).\n * @param account The account whose tokens will be burnt.\n * @param value The amount that will be burnt.\n */\n function _burnFrom(address account, uint256 value) internal {\n _burn(account, value);\n _approve(account, msg.sender, _allowed[account][msg.sender].sub(value));\n }\n}\n\ncontract RateChangerRole {\n using Roles for Roles.Role;\n\n event RateChangerAdded(address indexed account);\n event RateChangerRemoved(address indexed account);\n\n Roles.Role private _RateChangers;\n\n constructor () internal {\n _addRateChanger(msg.sender);\n }\n\n modifier onlyRateChanger() {\n require(isRateChanger(msg.sender), \"Sender not authorized to change the rate\");\n _;\n }\n\n function isRateChanger(address account) public view returns (bool) {\n return _RateChangers.has(account);\n }\n\n function addRateChanger(address account) public onlyRateChanger {\n _addRateChanger(account);\n }\n\n function renounceRateChanger() public {\n _removeRateChanger(msg.sender);\n }\n\n function _addRateChanger(address account) internal {\n _RateChangers.add(account);\n emit RateChangerAdded(account);\n }\n\n function _removeRateChanger(address account) internal {\n _RateChangers.remove(account);\n emit RateChangerRemoved(account);\n }\n}\n\ncontract ERC20Detailed is IERC20 {\n string private _name;\n string private _symbol;\n uint8 private _decimals;\n\n constructor (string memory name, string memory symbol, uint8 decimals) public {\n _name = name;\n _symbol = symbol;\n _decimals = decimals;\n }\n\n /**\n * @return the name of the token.\n */\n function name() public view returns (string memory) {\n return _name;\n }\n\n /**\n * @return the symbol of the token.\n */\n function symbol() public view returns (string memory) {\n return _symbol;\n }\n\n /**\n * @return the number of decimals of the token.\n */\n function decimals() public view returns (uint8) {\n return _decimals;\n }\n}\n\ncontract MinterRole {\n using Roles for Roles.Role;\n\n event MinterAdded(address indexed account);\n event MinterRemoved(address indexed account);\n\n Roles.Role private _minters;\n\n constructor () internal {\n _addMinter(msg.sender);\n }\n\n modifier onlyMinter() {\n require(isMinter(msg.sender));\n _;\n }\n\n function isMinter(address account) public view returns (bool) {\n return _minters.has(account);\n }\n\n function addMinter(address account) public onlyMinter {\n _addMinter(account);\n }\n\n function renounceMinter() public {\n _removeMinter(msg.sender);\n }\n\n function _addMinter(address account) internal {\n _minters.add(account);\n emit MinterAdded(account);\n }\n\n function _removeMinter(address account) internal {\n _minters.remove(account);\n emit MinterRemoved(account);\n }\n}\n\ncontract PauserRole {\n using Roles for Roles.Role;\n\n event PauserAdded(address indexed account);\n event PauserRemoved(address indexed account);\n\n Roles.Role private _pausers;\n\n constructor () internal {\n _addPauser(msg.sender);\n }\n\n modifier onlyPauser() {\n require(isPauser(msg.sender));\n _;\n }\n\n function isPauser(address account) public view returns (bool) {\n return _pausers.has(account);\n }\n\n function addPauser(address account) public onlyPauser {\n _addPauser(account);\n }\n\n function renouncePauser() public {\n _removePauser(msg.sender);\n }\n\n function _addPauser(address account) internal {\n _pausers.add(account);\n emit PauserAdded(account);\n }\n\n function _removePauser(address account) internal {\n _pausers.remove(account);\n emit PauserRemoved(account);\n }\n}\n\ncontract WhitelistAdminRole {\n using Roles for Roles.Role;\n\n event WhitelistAdminAdded(address indexed account);\n event WhitelistAdminRemoved(address indexed account);\n\n Roles.Role private _whitelistAdmins;\n\n constructor () internal {\n _addWhitelistAdmin(msg.sender);\n }\n\n modifier onlyWhitelistAdmin() {\n require(isWhitelistAdmin(msg.sender));\n _;\n }\n\n function isWhitelistAdmin(address account) public view returns (bool) {\n return _whitelistAdmins.has(account);\n }\n\n function addWhitelistAdmin(address account) public onlyWhitelistAdmin {\n _addWhitelistAdmin(account);\n }\n\n function renounceWhitelistAdmin() public {\n _removeWhitelistAdmin(msg.sender);\n }\n\n function _addWhitelistAdmin(address account) internal {\n _whitelistAdmins.add(account);\n emit WhitelistAdminAdded(account);\n }\n\n function _removeWhitelistAdmin(address account) internal {\n _whitelistAdmins.remove(account);\n emit WhitelistAdminRemoved(account);\n }\n}\n\nlibrary SafeERC20 {\n using SafeMath for uint256;\n\n function safeTransfer(IERC20 token, address to, uint256 value) internal {\n require(token.transfer(to, value), \"Token could not be transfered\");\n }\n\n function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {\n require(token.transferFrom(from, to, value), \"Token could not be transfered\");\n }\n\n function safeApprove(IERC20 token, address spender, uint256 value) internal {\n // safeApprove should only be called when setting an initial allowance,\n // or when resetting it to zero. To increase and decrease it, use\n // \u0027safeIncreaseAllowance\u0027 and \u0027safeDecreaseAllowance\u0027\n require((value == 0) || (token.allowance(msg.sender, spender) == 0));\n require(token.approve(spender, value));\n }\n\n function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {\n uint256 newAllowance = token.allowance(address(this), spender).add(value);\n require(token.approve(spender, newAllowance));\n }\n\n function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {\n uint256 newAllowance = token.allowance(address(this), spender).sub(value);\n require(token.approve(spender, newAllowance));\n }\n}\n\ncontract WhitelistedRole is WhitelistAdminRole {\n using Roles for Roles.Role;\n\n event WhitelistedAdded(address indexed account);\n event WhitelistedRemoved(address indexed account);\n\n Roles.Role private _whitelisteds;\n\n modifier onlyWhitelisted() {\n require(isWhitelisted(msg.sender));\n _;\n }\n\n function isWhitelisted(address account) public view returns (bool) {\n return _whitelisteds.has(account);\n }\n\n function addWhitelisted(address account) public onlyWhitelistAdmin {\n _addWhitelisted(account);\n }\n\n function removeWhitelisted(address account) public onlyWhitelistAdmin {\n _removeWhitelisted(account);\n }\n\n function renounceWhitelisted() public {\n _removeWhitelisted(msg.sender);\n }\n\n function _addWhitelisted(address account) internal {\n _whitelisteds.add(account);\n emit WhitelistedAdded(account);\n }\n\n function _removeWhitelisted(address account) internal {\n _whitelisteds.remove(account);\n emit WhitelistedRemoved(account);\n }\n}\n\ncontract Crowdsale is ReentrancyGuard, RateChangerRole {\n using SafeMath for uint256;\n using SafeERC20 for IERC20;\n\n // The token being sold\n IERC20 private _token;\n\n // Address where funds are collected\n address payable private _wallet;\n\n // How many wei it cost for a token unit.\n // The rate is the conversion between wei and the smallest and indivisible token unit.\n // So, if you are using a rate of 1 with a ERC20Detailed token with 3 decimals called TOK\n // 1 wei will give you 1 unit, or 0.001 TOK.\n uint256 private _rate;\n\n // Amount of wei raised\n uint256 private _weiRaised;\n\n /** \n * @param rate Number of wei it costs for a token unit.\n * @dev The rate is the conversion between wei and the smallest and indivisible\n * token unit. So, if you are using a rate of 1 with a ERC20Detailed token\n * with 3 decimals called TOK, 1 wei will give you 1 unit, or 0.001 TOK.\n */\n function changeRate(uint256 rate)\n public onlyRateChanger\n {\n require(rate \u003e 0);\n _rate = rate;\n }\n\n /**\n * Event for token purchase logging\n * @param purchaser who paid for the tokens\n * @param beneficiary who got the tokens\n * @param value weis paid for purchase\n * @param amount amount of tokens purchased\n */\n event TokensPurchased(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount);\n\n /**\n * @param initialRate Number of token units a buyer gets per wei\n * @dev The initial rate is the conversion between wei and the smallest and indivisible\n * token unit. So, if you are using a rate of 1 with a ERC20Detailed token\n * with 3 decimals called TOK, 1 wei will give you 1 unit, or 0.001 TOK.\n * @param wallet Address where collected funds will be forwarded to\n * @param token Address of the token being sold\n */\n constructor (/*uint256 initialCoinsForCreator,*/ uint256 initialRate, address payable wallet, IERC20 token) public {\n require(initialRate \u003e 0, \"The initial rate must be above 0\");\n require(wallet != address(0), \"The wallet address must not be 0x0\");\n require(address(token) != address(0), \"The token address must not be 0x0\");\n\n _rate = initialRate;\n _wallet = wallet;\n _token = token;\n }\n\n /**\n * @dev fallback function ***DO NOT OVERRIDE***\n * Note that other contracts will transfer fund with a base gas stipend\n * of 2300, which is not enough to call buyTokens. Consider calling\n * buyTokens directly when purchasing tokens from a contract.\n */\n function () external payable {\n buyTokens(msg.sender);\n }\n\n /**\n * @return the token being sold.\n */\n function token() public view returns (IERC20) {\n return _token;\n }\n\n /**\n * @return the address where funds are collected.\n */\n function wallet() public view returns (address payable) {\n return _wallet;\n }\n\n /**\n * @return the number of token units a buyer gets per wei.\n */\n function rate() public view returns (uint256) {\n return _rate;\n }\n\n /**\n * @return the amount of wei raised.\n */\n function weiRaised() public view returns (uint256) {\n return _weiRaised;\n }\n\n /**\n * @dev low level token purchase ***DO NOT OVERRIDE***\n * This function has a non-reentrancy guard, so it shouldn\u0027t be called by\n * another `nonReentrant` function.\n * @param beneficiary Recipient of the token purchase\n */\n function buyTokens(address beneficiary) public nonReentrant payable {\n uint256 weiAmount = msg.value;\n _preValidatePurchase(beneficiary, weiAmount);\n\n // calculate token amount to be created\n uint256 tokens = _getTokenAmount(weiAmount);\n\n // update state\n _weiRaised = _weiRaised.add(weiAmount);\n\n _processPurchase(beneficiary, tokens);\n emit TokensPurchased(msg.sender, beneficiary, weiAmount, tokens);\n\n _updatePurchasingState(beneficiary, weiAmount);\n\n _forwardFunds();\n _postValidatePurchase(beneficiary, weiAmount);\n }\n\n /**\n * @dev Validation of an incoming purchase. Use require statements to revert state when conditions are not met.\n * Use `super` in contracts that inherit from Crowdsale to extend their validations.\n * Example from CappedCrowdsale.sol\u0027s _preValidatePurchase method:\n * super._preValidatePurchase(beneficiary, weiAmount);\n * require(weiRaised().add(weiAmount) \u003c= cap);\n * @param beneficiary Address performing the token purchase\n * @param weiAmount Value in wei involved in the purchase\n */\n function _preValidatePurchase(address beneficiary, uint256 weiAmount) internal view {\n require(beneficiary != address(0), \"Cannot send to 0 address\");\n require(weiAmount != 0, \"No ether sent\");\n }\n\n /**\n * @dev Validation of an executed purchase. Observe state and use revert statements to undo rollback when valid\n * conditions are not met.\n * @param beneficiary Address performing the token purchase\n * @param weiAmount Value in wei involved in the purchase\n */\n function _postValidatePurchase(address beneficiary, uint256 weiAmount) internal view {\n // solhint-disable-previous-line no-empty-blocks\n }\n\n /**\n * @dev Source of tokens. Override this method to modify the way in which the crowdsale ultimately gets and sends\n * its tokens.\n * @param beneficiary Address performing the token purchase\n * @param tokenAmount Number of tokens to be emitted\n */\n function _deliverTokens(address beneficiary, uint256 tokenAmount) internal {\n _token.safeTransfer(beneficiary, tokenAmount);\n }\n\n /**\n * @dev Executed when a purchase has been validated and is ready to be executed. Doesn\u0027t necessarily emit/send\n * tokens.\n * @param beneficiary Address receiving the tokens\n * @param tokenAmount Number of tokens to be purchased\n */\n function _processPurchase(address beneficiary, uint256 tokenAmount) internal {\n _deliverTokens(beneficiary, tokenAmount);\n }\n\n /**\n * @dev Override for extensions that require an internal state to check for validity (current user contributions,\n * etc.)\n * @param beneficiary Address receiving the tokens\n * @param weiAmount Value in wei involved in the purchase\n */\n function _updatePurchasingState(address beneficiary, uint256 weiAmount) internal {\n // solhint-disable-previous-line no-empty-blocks\n }\n\n /**\n * @dev Override to extend the way in which ether is converted to tokens.\n * @param weiAmount Value in wei to be converted into tokens\n * @return Number of tokens that can be purchased with the specified _weiAmount\n */\n function _getTokenAmount(uint256 weiAmount) internal view returns (uint256) {\n return weiAmount.div(_rate);\n }\n\n /**\n * @dev Determines how ETH is stored/forwarded on purchases.\n */\n function _forwardFunds() internal {\n _wallet.transfer(msg.value);\n }\n}\n\ncontract Pausable is PauserRole, IgnorePausedRole {\n event Paused(address account);\n event Unpaused(address account);\n\n bool private _paused;\n\n address private _creator;\n\n constructor () internal {\n _paused = false;\n _creator = msg.sender;\n }\n\n /**\n * @return true if the contract is paused, false otherwise.\n */\n function paused() public view returns (bool) {\n return _paused;\n }\n\n /**\n * @dev Modifier to make a function callable only when the contract is not paused. Allow the contract creator to have super powers.\n */\n modifier whenNotPaused() {\n require(!_paused || isIgnorePaused(msg.sender), \"Contract paused\");\n _;\n }\n\n /**\n * @dev Modifier to make a function callable only when the contract is paused.\n */\n modifier whenPaused() {\n require(_paused, \"Contract not paused\");\n _;\n }\n\n /**\n * @dev called by the owner to pause, triggers stopped state\n */\n function pause() public onlyPauser whenNotPaused {\n _paused = true;\n emit Paused(msg.sender);\n }\n\n /**\n * @dev called by the owner to unpause, returns to normal state\n */\n function unpause() public onlyPauser whenPaused {\n _paused = false;\n emit Unpaused(msg.sender);\n }\n}\n\ncontract ERC20Mintable is ERC20, MinterRole {\n /**\n * @dev Function to mint tokens\n * @param to The address that will receive the minted tokens.\n * @param value The amount of tokens to mint.\n * @return A boolean that indicates if the operation was successful.\n */\n function mint(address to, uint256 value) public onlyMinter returns (bool) {\n _mint(to, value);\n return true;\n }\n}\n\ncontract MintedCrowdsale is Crowdsale {\n /**\n * @dev Overrides delivery by minting tokens upon purchase.\n * @param beneficiary Token purchaser\n * @param tokenAmount Number of tokens to be minted\n */\n function _deliverTokens(address beneficiary, uint256 tokenAmount) internal {\n // Potentially dangerous assumption about the type of the token.\n require(ERC20Mintable(address(token())).mint(beneficiary, tokenAmount));\n }\n}\n\ncontract WhitelistCrowdsale is WhitelistedRole, Crowdsale {\n /**\n * @dev Extend parent behavior requiring beneficiary to be whitelisted. Note that no\n * restriction is imposed on the account sending the transaction.\n * @param _beneficiary Token beneficiary\n * @param _weiAmount Amount of wei contributed\n */\n function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal view {\n require(isWhitelisted(_beneficiary), \"Beneficiary address is not whitelisted\");\n super._preValidatePurchase(_beneficiary, _weiAmount);\n }\n}\n\ncontract ERC20Pausable is ERC20, Pausable {\n function transfer(address to, uint256 value) public whenNotPaused returns (bool) {\n return super.transfer(to, value);\n }\n\n function transferFrom(address from, address to, uint256 value) public whenNotPaused returns (bool) {\n return super.transferFrom(from, to, value);\n }\n\n function approve(address spender, uint256 value) public whenNotPaused returns (bool) {\n return super.approve(spender, value);\n }\n\n function increaseAllowance(address spender, uint addedValue) public whenNotPaused returns (bool success) {\n return super.increaseAllowance(spender, addedValue);\n }\n\n function decreaseAllowance(address spender, uint subtractedValue) public whenNotPaused returns (bool success) {\n return super.decreaseAllowance(spender, subtractedValue);\n }\n}\n\ncontract PausableCrowdsale is Crowdsale, Pausable {\n /**\n * @dev Validation of an incoming purchase. Use require statements to revert state when conditions are not met.\n * Use super to concatenate validations.\n * Adds the validation that the crowdsale must not be paused.\n * @param _beneficiary Address performing the token purchase\n * @param _weiAmount Value in wei involved in the purchase\n */\n function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal view whenNotPaused {\n return super._preValidatePurchase(_beneficiary, _weiAmount);\n }\n}\n\ncontract RateChangeCrowdsaleToken is ERC20, ERC20Detailed, ERC20Pausable {\n constructor (uint256 initialSupply, string memory name, string memory symbol, uint8 decimals) public ERC20Detailed(name, symbol, decimals) {\n // solhint-disable-previous-line no-empty-blocks\n _mint(msg.sender, initialSupply);\n }\n}\n\n/**\n * @title RateChangeCrowdsale\n * @dev This is an example of a fully fledged crowdsale.\n * The way to add new features to a base crowdsale is by multiple inheritance.\n *\n * After adding multiple features it\u0027s good practice to run integration tests\n * to ensure that subcontracts works together as intended.\n */\ncontract RateChangeCrowdsale is Crowdsale, WhitelistCrowdsale, PausableCrowdsale {\n constructor (\n uint256 rate,\n IERC20 token\n )\n public\n Crowdsale(rate, msg.sender, token)\n {}\n}\n"}}