Iammrjude

Kofi.sol

Sep 23rd, 2020
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  *Submitted for verification at Etherscan.io on 2020-04-28
  3. */
  4.  
  5. // BUILT FOR FREE ON https://vittominacori.github.io/erc20-generator
  6.  
  7. // File: @openzeppelin/contracts/GSN/Context.sol
  8.  
  9. pragma solidity ^0.6.0;
  10.  
  11. /*
  12.  * @dev Provides information about the current execution context, including the
  13.  * sender of the transaction and its data. While these are generally available
  14.  * via msg.sender and msg.data, they should not be accessed in such a direct
  15.  * manner, since when dealing with GSN meta-transactions the account sending and
  16.  * paying for execution may not be the actual sender (as far as an application
  17.  * is concerned).
  18.  *
  19.  * This contract is only required for intermediate, library-like contracts.
  20.  */
  21. contract Context {
  22.     // Empty internal constructor, to prevent people from mistakenly deploying
  23.     // an instance of this contract, which should be used via inheritance.
  24.     constructor () internal { }
  25.  
  26.     function _msgSender() internal view virtual returns (address payable) {
  27.         return msg.sender;
  28.     }
  29.  
  30.     function _msgData() internal view virtual returns (bytes memory) {
  31.         this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
  32.         return msg.data;
  33.     }
  34. }
  35.  
  36. // File: @openzeppelin/contracts/token/ERC20/IERC20.sol
  37.  
  38. pragma solidity ^0.6.0;
  39.  
  40. /**
  41.  * @dev Interface of the ERC20 standard as defined in the EIP.
  42.  */
  43. interface IERC20 {
  44.     /**
  45.      * @dev Returns the amount of tokens in existence.
  46.      */
  47.     function totalSupply() external view returns (uint256);
  48.  
  49.     /**
  50.      * @dev Returns the amount of tokens owned by `account`.
  51.      */
  52.     function balanceOf(address account) external view returns (uint256);
  53.  
  54.     /**
  55.      * @dev Moves `amount` tokens from the caller's account to `recipient`.
  56.      *
  57.      * Returns a boolean value indicating whether the operation succeeded.
  58.      *
  59.      * Emits a {Transfer} event.
  60.      */
  61.     function transfer(address recipient, uint256 amount) external returns (bool);
  62.  
  63.     /**
  64.      * @dev Returns the remaining number of tokens that `spender` will be
  65.      * allowed to spend on behalf of `owner` through {transferFrom}. This is
  66.      * zero by default.
  67.      *
  68.      * This value changes when {approve} or {transferFrom} are called.
  69.      */
  70.     function allowance(address owner, address spender) external view returns (uint256);
  71.  
  72.     /**
  73.      * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
  74.      *
  75.      * Returns a boolean value indicating whether the operation succeeded.
  76.      *
  77.      * IMPORTANT: Beware that changing an allowance with this method brings the risk
  78.      * that someone may use both the old and the new allowance by unfortunate
  79.      * transaction ordering. One possible solution to mitigate this race
  80.      * condition is to first reduce the spender's allowance to 0 and set the
  81.      * desired value afterwards:
  82.      * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
  83.      *
  84.      * Emits an {Approval} event.
  85.      */
  86.     function approve(address spender, uint256 amount) external returns (bool);
  87.  
  88.     /**
  89.      * @dev Moves `amount` tokens from `sender` to `recipient` using the
  90.      * allowance mechanism. `amount` is then deducted from the caller's
  91.      * allowance.
  92.      *
  93.      * Returns a boolean value indicating whether the operation succeeded.
  94.      *
  95.      * Emits a {Transfer} event.
  96.      */
  97.     function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
  98.  
  99.     /**
  100.      * @dev Emitted when `value` tokens are moved from one account (`from`) to
  101.      * another (`to`).
  102.      *
  103.      * Note that `value` may be zero.
  104.      */
  105.     event Transfer(address indexed from, address indexed to, uint256 value);
  106.  
  107.     /**
  108.      * @dev Emitted when the allowance of a `spender` for an `owner` is set by
  109.      * a call to {approve}. `value` is the new allowance.
  110.      */
  111.     event Approval(address indexed owner, address indexed spender, uint256 value);
  112. }
  113.  
  114. // File: @openzeppelin/contracts/math/SafeMath.sol
  115.  
  116. pragma solidity ^0.6.0;
  117.  
  118. /**
  119.  * @dev Wrappers over Solidity's arithmetic operations with added overflow
  120.  * checks.
  121.  *
  122.  * Arithmetic operations in Solidity wrap on overflow. This can easily result
  123.  * in bugs, because programmers usually assume that an overflow raises an
  124.  * error, which is the standard behavior in high level programming languages.
  125.  * `SafeMath` restores this intuition by reverting the transaction when an
  126.  * operation overflows.
  127.  *
  128.  * Using this library instead of the unchecked operations eliminates an entire
  129.  * class of bugs, so it's recommended to use it always.
  130.  */
  131. library SafeMath {
  132.     /**
  133.      * @dev Returns the addition of two unsigned integers, reverting on
  134.      * overflow.
  135.      *
  136.      * Counterpart to Solidity's `+` operator.
  137.      *
  138.      * Requirements:
  139.      * - Addition cannot overflow.
  140.      */
  141.     function add(uint256 a, uint256 b) internal pure returns (uint256) {
  142.         uint256 c = a + b;
  143.         require(c >= a, "SafeMath: addition overflow");
  144.  
  145.         return c;
  146.     }
  147.  
  148.     /**
  149.      * @dev Returns the subtraction of two unsigned integers, reverting on
  150.      * overflow (when the result is negative).
  151.      *
  152.      * Counterpart to Solidity's `-` operator.
  153.      *
  154.      * Requirements:
  155.      * - Subtraction cannot overflow.
  156.      */
  157.     function sub(uint256 a, uint256 b) internal pure returns (uint256) {
  158.         return sub(a, b, "SafeMath: subtraction overflow");
  159.     }
  160.  
  161.     /**
  162.      * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
  163.      * overflow (when the result is negative).
  164.      *
  165.      * Counterpart to Solidity's `-` operator.
  166.      *
  167.      * Requirements:
  168.      * - Subtraction cannot overflow.
  169.      */
  170.     function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
  171.         require(b <= a, errorMessage);
  172.         uint256 c = a - b;
  173.  
  174.         return c;
  175.     }
  176.  
  177.     /**
  178.      * @dev Returns the multiplication of two unsigned integers, reverting on
  179.      * overflow.
  180.      *
  181.      * Counterpart to Solidity's `*` operator.
  182.      *
  183.      * Requirements:
  184.      * - Multiplication cannot overflow.
  185.      */
  186.     function mul(uint256 a, uint256 b) internal pure returns (uint256) {
  187.         // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
  188.         // benefit is lost if 'b' is also tested.
  189.         // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
  190.         if (a == 0) {
  191.             return 0;
  192.         }
  193.  
  194.         uint256 c = a * b;
  195.         require(c / a == b, "SafeMath: multiplication overflow");
  196.  
  197.         return c;
  198.     }
  199.  
  200.     /**
  201.      * @dev Returns the integer division of two unsigned integers. Reverts on
  202.      * division by zero. The result is rounded towards zero.
  203.      *
  204.      * Counterpart to Solidity's `/` operator. Note: this function uses a
  205.      * `revert` opcode (which leaves remaining gas untouched) while Solidity
  206.      * uses an invalid opcode to revert (consuming all remaining gas).
  207.      *
  208.      * Requirements:
  209.      * - The divisor cannot be zero.
  210.      */
  211.     function div(uint256 a, uint256 b) internal pure returns (uint256) {
  212.         return div(a, b, "SafeMath: division by zero");
  213.     }
  214.  
  215.     /**
  216.      * @dev Returns the integer division of two unsigned integers. Reverts with custom message on
  217.      * division by zero. The result is rounded towards zero.
  218.      *
  219.      * Counterpart to Solidity's `/` operator. Note: this function uses a
  220.      * `revert` opcode (which leaves remaining gas untouched) while Solidity
  221.      * uses an invalid opcode to revert (consuming all remaining gas).
  222.      *
  223.      * Requirements:
  224.      * - The divisor cannot be zero.
  225.      */
  226.     function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
  227.         // Solidity only automatically asserts when dividing by 0
  228.         require(b > 0, errorMessage);
  229.         uint256 c = a / b;
  230.         // assert(a == b * c + a % b); // There is no case in which this doesn't hold
  231.  
  232.         return c;
  233.     }
  234.  
  235.     /**
  236.      * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
  237.      * Reverts when dividing by zero.
  238.      *
  239.      * Counterpart to Solidity's `%` operator. This function uses a `revert`
  240.      * opcode (which leaves remaining gas untouched) while Solidity uses an
  241.      * invalid opcode to revert (consuming all remaining gas).
  242.      *
  243.      * Requirements:
  244.      * - The divisor cannot be zero.
  245.      */
  246.     function mod(uint256 a, uint256 b) internal pure returns (uint256) {
  247.         return mod(a, b, "SafeMath: modulo by zero");
  248.     }
  249.  
  250.     /**
  251.      * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
  252.      * Reverts with custom message when dividing by zero.
  253.      *
  254.      * Counterpart to Solidity's `%` operator. This function uses a `revert`
  255.      * opcode (which leaves remaining gas untouched) while Solidity uses an
  256.      * invalid opcode to revert (consuming all remaining gas).
  257.      *
  258.      * Requirements:
  259.      * - The divisor cannot be zero.
  260.      */
  261.     function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
  262.         require(b != 0, errorMessage);
  263.         return a % b;
  264.     }
  265. }
  266.  
  267. // File: @openzeppelin/contracts/utils/Address.sol
  268.  
  269. pragma solidity ^0.6.2;
  270.  
  271. /**
  272.  * @dev Collection of functions related to the address type
  273.  */
  274. library Address {
  275.     /**
  276.      * @dev Returns true if `account` is a contract.
  277.      *
  278.      * [IMPORTANT]
  279.      * ====
  280.      * It is unsafe to assume that an address for which this function returns
  281.      * false is an externally-owned account (EOA) and not a contract.
  282.      *
  283.      * Among others, `isContract` will return false for the following
  284.      * types of addresses:
  285.      *
  286.      *  - an externally-owned account
  287.      *  - a contract in construction
  288.      *  - an address where a contract will be created
  289.      *  - an address where a contract lived, but was destroyed
  290.      * ====
  291.      */
  292.     function isContract(address account) internal view returns (bool) {
  293.         // According to EIP-1052, 0x0 is the value returned for not-yet created accounts
  294.         // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
  295.         // for accounts without code, i.e. `keccak256('')`
  296.         bytes32 codehash;
  297.         bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
  298.         // solhint-disable-next-line no-inline-assembly
  299.         assembly { codehash := extcodehash(account) }
  300.         return (codehash != accountHash && codehash != 0x0);
  301.     }
  302.  
  303.     /**
  304.      * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
  305.      * `recipient`, forwarding all available gas and reverting on errors.
  306.      *
  307.      * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
  308.      * of certain opcodes, possibly making contracts go over the 2300 gas limit
  309.      * imposed by `transfer`, making them unable to receive funds via
  310.      * `transfer`. {sendValue} removes this limitation.
  311.      *
  312.      * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
  313.      *
  314.      * IMPORTANT: because control is transferred to `recipient`, care must be
  315.      * taken to not create reentrancy vulnerabilities. Consider using
  316.      * {ReentrancyGuard} or the
  317.      * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
  318.      */
  319.     function sendValue(address payable recipient, uint256 amount) internal {
  320.         require(address(this).balance >= amount, "Address: insufficient balance");
  321.  
  322.         // solhint-disable-next-line avoid-low-level-calls, avoid-call-value
  323.         (bool success, ) = recipient.call{ value: amount }("");
  324.         require(success, "Address: unable to send value, recipient may have reverted");
  325.     }
  326. }
  327.  
  328. // File: @openzeppelin/contracts/token/ERC20/ERC20.sol
  329.  
  330. pragma solidity ^0.6.0;
  331.  
  332.  
  333.  
  334.  
  335.  
  336. /**
  337.  * @dev Implementation of the {IERC20} interface.
  338.  *
  339.  * This implementation is agnostic to the way tokens are created. This means
  340.  * that a supply mechanism has to be added in a derived contract using {_mint}.
  341.  * For a generic mechanism see {ERC20MinterPauser}.
  342.  *
  343.  * TIP: For a detailed writeup see our guide
  344.  * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
  345.  * to implement supply mechanisms].
  346.  *
  347.  * We have followed general OpenZeppelin guidelines: functions revert instead
  348.  * of returning `false` on failure. This behavior is nonetheless conventional
  349.  * and does not conflict with the expectations of ERC20 applications.
  350.  *
  351.  * Additionally, an {Approval} event is emitted on calls to {transferFrom}.
  352.  * This allows applications to reconstruct the allowance for all accounts just
  353.  * by listening to said events. Other implementations of the EIP may not emit
  354.  * these events, as it isn't required by the specification.
  355.  *
  356.  * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
  357.  * functions have been added to mitigate the well-known issues around setting
  358.  * allowances. See {IERC20-approve}.
  359.  */
  360. contract ERC20 is Context, IERC20 {
  361.     using SafeMath for uint256;
  362.     using Address for address;
  363.  
  364.     mapping (address => uint256) private _balances;
  365.  
  366.     mapping (address => mapping (address => uint256)) private _allowances;
  367.  
  368.     uint256 private _totalSupply;
  369.  
  370.     string private _name;
  371.     string private _symbol;
  372.     uint8 private _decimals;
  373.  
  374.     /**
  375.      * @dev Sets the values for {name} and {symbol}, initializes {decimals} with
  376.      * a default value of 18.
  377.      *
  378.      * To select a different value for {decimals}, use {_setupDecimals}.
  379.      *
  380.      * All three of these values are immutable: they can only be set once during
  381.      * construction.
  382.      */
  383.     constructor (string memory name, string memory symbol) public {
  384.         _name = name;
  385.         _symbol = symbol;
  386.         _decimals = 18;
  387.     }
  388.  
  389.     /**
  390.      * @dev Returns the name of the token.
  391.      */
  392.     function name() public view returns (string memory) {
  393.         return _name;
  394.     }
  395.  
  396.     /**
  397.      * @dev Returns the symbol of the token, usually a shorter version of the
  398.      * name.
  399.      */
  400.     function symbol() public view returns (string memory) {
  401.         return _symbol;
  402.     }
  403.  
  404.     /**
  405.      * @dev Returns the number of decimals used to get its user representation.
  406.      * For example, if `decimals` equals `2`, a balance of `505` tokens should
  407.      * be displayed to a user as `5,05` (`505 / 10 ** 2`).
  408.      *
  409.      * Tokens usually opt for a value of 18, imitating the relationship between
  410.      * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
  411.      * called.
  412.      *
  413.      * NOTE: This information is only used for _display_ purposes: it in
  414.      * no way affects any of the arithmetic of the contract, including
  415.      * {IERC20-balanceOf} and {IERC20-transfer}.
  416.      */
  417.     function decimals() public view returns (uint8) {
  418.         return _decimals;
  419.     }
  420.  
  421.     /**
  422.      * @dev See {IERC20-totalSupply}.
  423.      */
  424.     function totalSupply() public view override returns (uint256) {
  425.         return _totalSupply;
  426.     }
  427.  
  428.     /**
  429.      * @dev See {IERC20-balanceOf}.
  430.      */
  431.     function balanceOf(address account) public view override returns (uint256) {
  432.         return _balances[account];
  433.     }
  434.  
  435.     /**
  436.      * @dev See {IERC20-transfer}.
  437.      *
  438.      * Requirements:
  439.      *
  440.      * - `recipient` cannot be the zero address.
  441.      * - the caller must have a balance of at least `amount`.
  442.      */
  443.     function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
  444.         _transfer(_msgSender(), recipient, amount);
  445.         return true;
  446.     }
  447.  
  448.     /**
  449.      * @dev See {IERC20-allowance}.
  450.      */
  451.     function allowance(address owner, address spender) public view virtual override returns (uint256) {
  452.         return _allowances[owner][spender];
  453.     }
  454.  
  455.     /**
  456.      * @dev See {IERC20-approve}.
  457.      *
  458.      * Requirements:
  459.      *
  460.      * - `spender` cannot be the zero address.
  461.      */
  462.     function approve(address spender, uint256 amount) public virtual override returns (bool) {
  463.         _approve(_msgSender(), spender, amount);
  464.         return true;
  465.     }
  466.  
  467.     /**
  468.      * @dev See {IERC20-transferFrom}.
  469.      *
  470.      * Emits an {Approval} event indicating the updated allowance. This is not
  471.      * required by the EIP. See the note at the beginning of {ERC20};
  472.      *
  473.      * Requirements:
  474.      * - `sender` and `recipient` cannot be the zero address.
  475.      * - `sender` must have a balance of at least `amount`.
  476.      * - the caller must have allowance for ``sender``'s tokens of at least
  477.      * `amount`.
  478.      */
  479.     function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
  480.         _transfer(sender, recipient, amount);
  481.         _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
  482.         return true;
  483.     }
  484.  
  485.     /**
  486.      * @dev Atomically increases the allowance granted to `spender` by the caller.
  487.      *
  488.      * This is an alternative to {approve} that can be used as a mitigation for
  489.      * problems described in {IERC20-approve}.
  490.      *
  491.      * Emits an {Approval} event indicating the updated allowance.
  492.      *
  493.      * Requirements:
  494.      *
  495.      * - `spender` cannot be the zero address.
  496.      */
  497.     function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
  498.         _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
  499.         return true;
  500.     }
  501.  
  502.     /**
  503.      * @dev Atomically decreases the allowance granted to `spender` by the caller.
  504.      *
  505.      * This is an alternative to {approve} that can be used as a mitigation for
  506.      * problems described in {IERC20-approve}.
  507.      *
  508.      * Emits an {Approval} event indicating the updated allowance.
  509.      *
  510.      * Requirements:
  511.      *
  512.      * - `spender` cannot be the zero address.
  513.      * - `spender` must have allowance for the caller of at least
  514.      * `subtractedValue`.
  515.      */
  516.     function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
  517.         _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
  518.         return true;
  519.     }
  520.  
  521.     /**
  522.      * @dev Moves tokens `amount` from `sender` to `recipient`.
  523.      *
  524.      * This is internal function is equivalent to {transfer}, and can be used to
  525.      * e.g. implement automatic token fees, slashing mechanisms, etc.
  526.      *
  527.      * Emits a {Transfer} event.
  528.      *
  529.      * Requirements:
  530.      *
  531.      * - `sender` cannot be the zero address.
  532.      * - `recipient` cannot be the zero address.
  533.      * - `sender` must have a balance of at least `amount`.
  534.      */
  535.     function _transfer(address sender, address recipient, uint256 amount) internal virtual {
  536.         require(sender != address(0), "ERC20: transfer from the zero address");
  537.         require(recipient != address(0), "ERC20: transfer to the zero address");
  538.  
  539.         _beforeTokenTransfer(sender, recipient, amount);
  540.  
  541.         _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
  542.         _balances[recipient] = _balances[recipient].add(amount);
  543.         emit Transfer(sender, recipient, amount);
  544.     }
  545.  
  546.     /** @dev Creates `amount` tokens and assigns them to `account`, increasing
  547.      * the total supply.
  548.      *
  549.      * Emits a {Transfer} event with `from` set to the zero address.
  550.      *
  551.      * Requirements
  552.      *
  553.      * - `to` cannot be the zero address.
  554.      */
  555.     function _mint(address account, uint256 amount) internal virtual {
  556.         require(account != address(0), "ERC20: mint to the zero address");
  557.  
  558.         _beforeTokenTransfer(address(0), account, amount);
  559.  
  560.         _totalSupply = _totalSupply.add(amount);
  561.         _balances[account] = _balances[account].add(amount);
  562.         emit Transfer(address(0), account, amount);
  563.     }
  564.  
  565.     /**
  566.      * @dev Destroys `amount` tokens from `account`, reducing the
  567.      * total supply.
  568.      *
  569.      * Emits a {Transfer} event with `to` set to the zero address.
  570.      *
  571.      * Requirements
  572.      *
  573.      * - `account` cannot be the zero address.
  574.      * - `account` must have at least `amount` tokens.
  575.      */
  576.     function _burn(address account, uint256 amount) internal virtual {
  577.         require(account != address(0), "ERC20: burn from the zero address");
  578.  
  579.         _beforeTokenTransfer(account, address(0), amount);
  580.  
  581.         _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
  582.         _totalSupply = _totalSupply.sub(amount);
  583.         emit Transfer(account, address(0), amount);
  584.     }
  585.  
  586.     /**
  587.      * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
  588.      *
  589.      * This is internal function is equivalent to `approve`, and can be used to
  590.      * e.g. set automatic allowances for certain subsystems, etc.
  591.      *
  592.      * Emits an {Approval} event.
  593.      *
  594.      * Requirements:
  595.      *
  596.      * - `owner` cannot be the zero address.
  597.      * - `spender` cannot be the zero address.
  598.      */
  599.     function _approve(address owner, address spender, uint256 amount) internal virtual {
  600.         require(owner != address(0), "ERC20: approve from the zero address");
  601.         require(spender != address(0), "ERC20: approve to the zero address");
  602.  
  603.         _allowances[owner][spender] = amount;
  604.         emit Approval(owner, spender, amount);
  605.     }
  606.  
  607.     /**
  608.      * @dev Sets {decimals} to a value other than the default one of 18.
  609.      *
  610.      * WARNING: This function should only be called from the constructor. Most
  611.      * applications that interact with token contracts will not expect
  612.      * {decimals} to ever change, and may work incorrectly if it does.
  613.      */
  614.     function _setupDecimals(uint8 decimals_) internal {
  615.         _decimals = decimals_;
  616.     }
  617.  
  618.     /**
  619.      * @dev Hook that is called before any transfer of tokens. This includes
  620.      * minting and burning.
  621.      *
  622.      * Calling conditions:
  623.      *
  624.      * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
  625.      * will be to transferred to `to`.
  626.      * - when `from` is zero, `amount` tokens will be minted for `to`.
  627.      * - when `to` is zero, `amount` of ``from``'s tokens will be burned.
  628.      * - `from` and `to` are never both zero.
  629.      *
  630.      * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
  631.      */
  632.     function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
  633. }
  634.  
  635. // File: @openzeppelin/contracts/token/ERC20/ERC20Capped.sol
  636.  
  637. pragma solidity ^0.6.0;
  638.  
  639.  
  640. /**
  641.  * @dev Extension of {ERC20} that adds a cap to the supply of tokens.
  642.  */
  643. abstract contract ERC20Capped is ERC20 {
  644.     uint256 private _cap;
  645.  
  646.     /**
  647.      * @dev Sets the value of the `cap`. This value is immutable, it can only be
  648.      * set once during construction.
  649.      */
  650.     constructor (uint256 cap) public {
  651.         require(cap > 0, "ERC20Capped: cap is 0");
  652.         _cap = cap;
  653.     }
  654.  
  655.     /**
  656.      * @dev Returns the cap on the token's total supply.
  657.      */
  658.     function cap() public view returns (uint256) {
  659.         return _cap;
  660.     }
  661.  
  662.     /**
  663.      * @dev See {ERC20-_beforeTokenTransfer}.
  664.      *
  665.      * Requirements:
  666.      *
  667.      * - minted tokens must not cause the total supply to go over the cap.
  668.      */
  669.     function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override {
  670.         super._beforeTokenTransfer(from, to, amount);
  671.  
  672.         if (from == address(0)) { // When minting tokens
  673.             require(totalSupply().add(amount) <= _cap, "ERC20Capped: cap exceeded");
  674.         }
  675.     }
  676. }
  677.  
  678. // File: @openzeppelin/contracts/token/ERC20/ERC20Burnable.sol
  679.  
  680. pragma solidity ^0.6.0;
  681.  
  682.  
  683.  
  684. /**
  685.  * @dev Extension of {ERC20} that allows token holders to destroy both their own
  686.  * tokens and those that they have an allowance for, in a way that can be
  687.  * recognized off-chain (via event analysis).
  688.  */
  689. abstract contract ERC20Burnable is Context, ERC20 {
  690.     /**
  691.      * @dev Destroys `amount` tokens from the caller.
  692.      *
  693.      * See {ERC20-_burn}.
  694.      */
  695.     function burn(uint256 amount) public virtual {
  696.         _burn(_msgSender(), amount);
  697.     }
  698.  
  699.     /**
  700.      * @dev Destroys `amount` tokens from `account`, deducting from the caller's
  701.      * allowance.
  702.      *
  703.      * See {ERC20-_burn} and {ERC20-allowance}.
  704.      *
  705.      * Requirements:
  706.      *
  707.      * - the caller must have allowance for ``accounts``'s tokens of at least
  708.      * `amount`.
  709.      */
  710.     function burnFrom(address account, uint256 amount) public virtual {
  711.         uint256 decreasedAllowance = allowance(account, _msgSender()).sub(amount, "ERC20: burn amount exceeds allowance");
  712.  
  713.         _approve(account, _msgSender(), decreasedAllowance);
  714.         _burn(account, amount);
  715.     }
  716. }
  717.  
  718. // File: @openzeppelin/contracts/introspection/IERC165.sol
  719.  
  720. pragma solidity ^0.6.0;
  721.  
  722. /**
  723.  * @dev Interface of the ERC165 standard, as defined in the
  724.  * https://eips.ethereum.org/EIPS/eip-165[EIP].
  725.  *
  726.  * Implementers can declare support of contract interfaces, which can then be
  727.  * queried by others ({ERC165Checker}).
  728.  *
  729.  * For an implementation, see {ERC165}.
  730.  */
  731. interface IERC165 {
  732.     /**
  733.      * @dev Returns true if this contract implements the interface defined by
  734.      * `interfaceId`. See the corresponding
  735.      * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
  736.      * to learn more about how these ids are created.
  737.      *
  738.      * This function call must use less than 30 000 gas.
  739.      */
  740.     function supportsInterface(bytes4 interfaceId) external view returns (bool);
  741. }
  742.  
  743. // File: erc-payable-token/contracts/token/ERC1363/IERC1363.sol
  744.  
  745. pragma solidity ^0.6.0;
  746.  
  747.  
  748.  
  749. /**
  750.  * @title IERC1363 Interface
  751.  * @author Vittorio Minacori (https://github.com/vittominacori)
  752.  * @dev Interface for a Payable Token contract as defined in
  753.  *  https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1363.md
  754.  */
  755. interface IERC1363 is IERC20, IERC165 {
  756.     /*
  757.      * Note: the ERC-165 identifier for this interface is 0x4bbee2df.
  758.      * 0x4bbee2df ===
  759.      *   bytes4(keccak256('transferAndCall(address,uint256)')) ^
  760.      *   bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^
  761.      *   bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^
  762.      *   bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)'))
  763.      */
  764.  
  765.     /*
  766.      * Note: the ERC-165 identifier for this interface is 0xfb9ec8ce.
  767.      * 0xfb9ec8ce ===
  768.      *   bytes4(keccak256('approveAndCall(address,uint256)')) ^
  769.      *   bytes4(keccak256('approveAndCall(address,uint256,bytes)'))
  770.      */
  771.  
  772.     /**
  773.      * @notice Transfer tokens from `msg.sender` to another address and then call `onTransferReceived` on receiver
  774.      * @param to address The address which you want to transfer to
  775.      * @param value uint256 The amount of tokens to be transferred
  776.      * @return true unless throwing
  777.      */
  778.     function transferAndCall(address to, uint256 value) external returns (bool);
  779.  
  780.     /**
  781.      * @notice Transfer tokens from `msg.sender` to another address and then call `onTransferReceived` on receiver
  782.      * @param to address The address which you want to transfer to
  783.      * @param value uint256 The amount of tokens to be transferred
  784.      * @param data bytes Additional data with no specified format, sent in call to `to`
  785.      * @return true unless throwing
  786.      */
  787.     function transferAndCall(address to, uint256 value, bytes calldata data) external returns (bool);
  788.  
  789.     /**
  790.      * @notice Transfer tokens from one address to another and then call `onTransferReceived` on receiver
  791.      * @param from address The address which you want to send tokens from
  792.      * @param to address The address which you want to transfer to
  793.      * @param value uint256 The amount of tokens to be transferred
  794.      * @return true unless throwing
  795.      */
  796.     function transferFromAndCall(address from, address to, uint256 value) external returns (bool);
  797.  
  798.     /**
  799.      * @notice Transfer tokens from one address to another and then call `onTransferReceived` on receiver
  800.      * @param from address The address which you want to send tokens from
  801.      * @param to address The address which you want to transfer to
  802.      * @param value uint256 The amount of tokens to be transferred
  803.      * @param data bytes Additional data with no specified format, sent in call to `to`
  804.      * @return true unless throwing
  805.      */
  806.     function transferFromAndCall(address from, address to, uint256 value, bytes calldata data) external returns (bool);
  807.  
  808.     /**
  809.      * @notice Approve the passed address to spend the specified amount of tokens on behalf of msg.sender
  810.      * and then call `onApprovalReceived` on spender.
  811.      * Beware that changing an allowance with this method brings the risk that someone may use both the old
  812.      * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
  813.      * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
  814.      * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
  815.      * @param spender address The address which will spend the funds
  816.      * @param value uint256 The amount of tokens to be spent
  817.      */
  818.     function approveAndCall(address spender, uint256 value) external returns (bool);
  819.  
  820.     /**
  821.      * @notice Approve the passed address to spend the specified amount of tokens on behalf of msg.sender
  822.      * and then call `onApprovalReceived` on spender.
  823.      * Beware that changing an allowance with this method brings the risk that someone may use both the old
  824.      * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
  825.      * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
  826.      * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
  827.      * @param spender address The address which will spend the funds
  828.      * @param value uint256 The amount of tokens to be spent
  829.      * @param data bytes Additional data with no specified format, sent in call to `spender`
  830.      */
  831.     function approveAndCall(address spender, uint256 value, bytes calldata data) external returns (bool);
  832. }
  833.  
  834. // File: erc-payable-token/contracts/token/ERC1363/IERC1363Receiver.sol
  835.  
  836. pragma solidity ^0.6.0;
  837.  
  838. /**
  839.  * @title IERC1363Receiver Interface
  840.  * @author Vittorio Minacori (https://github.com/vittominacori)
  841.  * @dev Interface for any contract that wants to support transferAndCall or transferFromAndCall
  842.  *  from ERC1363 token contracts as defined in
  843.  *  https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1363.md
  844.  */
  845. interface IERC1363Receiver {
  846.     /*
  847.      * Note: the ERC-165 identifier for this interface is 0x88a7ca5c.
  848.      * 0x88a7ca5c === bytes4(keccak256("onTransferReceived(address,address,uint256,bytes)"))
  849.      */
  850.  
  851.     /**
  852.      * @notice Handle the receipt of ERC1363 tokens
  853.      * @dev Any ERC1363 smart contract calls this function on the recipient
  854.      * after a `transfer` or a `transferFrom`. This function MAY throw to revert and reject the
  855.      * transfer. Return of other than the magic value MUST result in the
  856.      * transaction being reverted.
  857.      * Note: the token contract address is always the message sender.
  858.      * @param operator address The address which called `transferAndCall` or `transferFromAndCall` function
  859.      * @param from address The address which are token transferred from
  860.      * @param value uint256 The amount of tokens transferred
  861.      * @param data bytes Additional data with no specified format
  862.      * @return `bytes4(keccak256("onTransferReceived(address,address,uint256,bytes)"))`
  863.      *  unless throwing
  864.      */
  865.     function onTransferReceived(address operator, address from, uint256 value, bytes calldata data) external returns (bytes4); // solhint-disable-line  max-line-length
  866. }
  867.  
  868. // File: erc-payable-token/contracts/token/ERC1363/IERC1363Spender.sol
  869.  
  870. pragma solidity ^0.6.0;
  871.  
  872. /**
  873.  * @title IERC1363Spender Interface
  874.  * @author Vittorio Minacori (https://github.com/vittominacori)
  875.  * @dev Interface for any contract that wants to support approveAndCall
  876.  *  from ERC1363 token contracts as defined in
  877.  *  https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1363.md
  878.  */
  879. interface IERC1363Spender {
  880.     /*
  881.      * Note: the ERC-165 identifier for this interface is 0x7b04a2d0.
  882.      * 0x7b04a2d0 === bytes4(keccak256("onApprovalReceived(address,uint256,bytes)"))
  883.      */
  884.  
  885.     /**
  886.      * @notice Handle the approval of ERC1363 tokens
  887.      * @dev Any ERC1363 smart contract calls this function on the recipient
  888.      * after an `approve`. This function MAY throw to revert and reject the
  889.      * approval. Return of other than the magic value MUST result in the
  890.      * transaction being reverted.
  891.      * Note: the token contract address is always the message sender.
  892.      * @param owner address The address which called `approveAndCall` function
  893.      * @param value uint256 The amount of tokens to be spent
  894.      * @param data bytes Additional data with no specified format
  895.      * @return `bytes4(keccak256("onApprovalReceived(address,uint256,bytes)"))`
  896.      *  unless throwing
  897.      */
  898.     function onApprovalReceived(address owner, uint256 value, bytes calldata data) external returns (bytes4);
  899. }
  900.  
  901. // File: @openzeppelin/contracts/introspection/ERC165Checker.sol
  902.  
  903. pragma solidity ^0.6.2;
  904.  
  905. /**
  906.  * @dev Library used to query support of an interface declared via {IERC165}.
  907.  *
  908.  * Note that these functions return the actual result of the query: they do not
  909.  * `revert` if an interface is not supported. It is up to the caller to decide
  910.  * what to do in these cases.
  911.  */
  912. library ERC165Checker {
  913.     // As per the EIP-165 spec, no interface should ever match 0xffffffff
  914.     bytes4 private constant _INTERFACE_ID_INVALID = 0xffffffff;
  915.  
  916.     /*
  917.      * bytes4(keccak256('supportsInterface(bytes4)')) == 0x01ffc9a7
  918.      */
  919.     bytes4 private constant _INTERFACE_ID_ERC165 = 0x01ffc9a7;
  920.  
  921.     /**
  922.      * @dev Returns true if `account` supports the {IERC165} interface,
  923.      */
  924.     function supportsERC165(address account) internal view returns (bool) {
  925.         // Any contract that implements ERC165 must explicitly indicate support of
  926.         // InterfaceId_ERC165 and explicitly indicate non-support of InterfaceId_Invalid
  927.         return _supportsERC165Interface(account, _INTERFACE_ID_ERC165) &&
  928.             !_supportsERC165Interface(account, _INTERFACE_ID_INVALID);
  929.     }
  930.  
  931.     /**
  932.      * @dev Returns true if `account` supports the interface defined by
  933.      * `interfaceId`. Support for {IERC165} itself is queried automatically.
  934.      *
  935.      * See {IERC165-supportsInterface}.
  936.      */
  937.     function supportsInterface(address account, bytes4 interfaceId) internal view returns (bool) {
  938.         // query support of both ERC165 as per the spec and support of _interfaceId
  939.         return supportsERC165(account) &&
  940.             _supportsERC165Interface(account, interfaceId);
  941.     }
  942.  
  943.     /**
  944.      * @dev Returns true if `account` supports all the interfaces defined in
  945.      * `interfaceIds`. Support for {IERC165} itself is queried automatically.
  946.      *
  947.      * Batch-querying can lead to gas savings by skipping repeated checks for
  948.      * {IERC165} support.
  949.      *
  950.      * See {IERC165-supportsInterface}.
  951.      */
  952.     function supportsAllInterfaces(address account, bytes4[] memory interfaceIds) internal view returns (bool) {
  953.         // query support of ERC165 itself
  954.         if (!supportsERC165(account)) {
  955.             return false;
  956.         }
  957.  
  958.         // query support of each interface in _interfaceIds
  959.         for (uint256 i = 0; i < interfaceIds.length; i++) {
  960.             if (!_supportsERC165Interface(account, interfaceIds[i])) {
  961.                 return false;
  962.             }
  963.         }
  964.  
  965.         // all interfaces supported
  966.         return true;
  967.     }
  968.  
  969.     /**
  970.      * @notice Query if a contract implements an interface, does not check ERC165 support
  971.      * @param account The address of the contract to query for support of an interface
  972.      * @param interfaceId The interface identifier, as specified in ERC-165
  973.      * @return true if the contract at account indicates support of the interface with
  974.      * identifier interfaceId, false otherwise
  975.      * @dev Assumes that account contains a contract that supports ERC165, otherwise
  976.      * the behavior of this method is undefined. This precondition can be checked
  977.      * with {supportsERC165}.
  978.      * Interface identification is specified in ERC-165.
  979.      */
  980.     function _supportsERC165Interface(address account, bytes4 interfaceId) private view returns (bool) {
  981.         // success determines whether the staticcall succeeded and result determines
  982.         // whether the contract at account indicates support of _interfaceId
  983.         (bool success, bool result) = _callERC165SupportsInterface(account, interfaceId);
  984.  
  985.         return (success && result);
  986.     }
  987.  
  988.     /**
  989.      * @notice Calls the function with selector 0x01ffc9a7 (ERC165) and suppresses throw
  990.      * @param account The address of the contract to query for support of an interface
  991.      * @param interfaceId The interface identifier, as specified in ERC-165
  992.      * @return success true if the STATICCALL succeeded, false otherwise
  993.      * @return result true if the STATICCALL succeeded and the contract at account
  994.      * indicates support of the interface with identifier interfaceId, false otherwise
  995.      */
  996.     function _callERC165SupportsInterface(address account, bytes4 interfaceId)
  997.         private
  998.         view
  999.         returns (bool, bool)
  1000.     {
  1001.         bytes memory encodedParams = abi.encodeWithSelector(_INTERFACE_ID_ERC165, interfaceId);
  1002.         (bool success, bytes memory result) = account.staticcall{ gas: 30000 }(encodedParams);
  1003.         if (result.length < 32) return (false, false);
  1004.         return (success, abi.decode(result, (bool)));
  1005.     }
  1006. }
  1007.  
  1008. // File: @openzeppelin/contracts/introspection/ERC165.sol
  1009.  
  1010. pragma solidity ^0.6.0;
  1011.  
  1012.  
  1013. /**
  1014.  * @dev Implementation of the {IERC165} interface.
  1015.  *
  1016.  * Contracts may inherit from this and call {_registerInterface} to declare
  1017.  * their support of an interface.
  1018.  */
  1019. contract ERC165 is IERC165 {
  1020.     /*
  1021.      * bytes4(keccak256('supportsInterface(bytes4)')) == 0x01ffc9a7
  1022.      */
  1023.     bytes4 private constant _INTERFACE_ID_ERC165 = 0x01ffc9a7;
  1024.  
  1025.     /**
  1026.      * @dev Mapping of interface ids to whether or not it's supported.
  1027.      */
  1028.     mapping(bytes4 => bool) private _supportedInterfaces;
  1029.  
  1030.     constructor () internal {
  1031.         // Derived contracts need only register support for their own interfaces,
  1032.         // we register support for ERC165 itself here
  1033.         _registerInterface(_INTERFACE_ID_ERC165);
  1034.     }
  1035.  
  1036.     /**
  1037.      * @dev See {IERC165-supportsInterface}.
  1038.      *
  1039.      * Time complexity O(1), guaranteed to always use less than 30 000 gas.
  1040.      */
  1041.     function supportsInterface(bytes4 interfaceId) public view override returns (bool) {
  1042.         return _supportedInterfaces[interfaceId];
  1043.     }
  1044.  
  1045.     /**
  1046.      * @dev Registers the contract as an implementer of the interface defined by
  1047.      * `interfaceId`. Support of the actual ERC165 interface is automatic and
  1048.      * registering its interface id is not required.
  1049.      *
  1050.      * See {IERC165-supportsInterface}.
  1051.      *
  1052.      * Requirements:
  1053.      *
  1054.      * - `interfaceId` cannot be the ERC165 invalid interface (`0xffffffff`).
  1055.      */
  1056.     function _registerInterface(bytes4 interfaceId) internal virtual {
  1057.         require(interfaceId != 0xffffffff, "ERC165: invalid interface id");
  1058.         _supportedInterfaces[interfaceId] = true;
  1059.     }
  1060. }
  1061.  
  1062. // File: erc-payable-token/contracts/token/ERC1363/ERC1363.sol
  1063.  
  1064. pragma solidity ^0.6.0;
  1065.  
  1066.  
  1067.  
  1068.  
  1069.  
  1070.  
  1071.  
  1072.  
  1073. /**
  1074.  * @title ERC1363
  1075.  * @author Vittorio Minacori (https://github.com/vittominacori)
  1076.  * @dev Implementation of an ERC1363 interface
  1077.  */
  1078. contract ERC1363 is ERC20, IERC1363, ERC165 {
  1079.     using Address for address;
  1080.  
  1081.     /*
  1082.      * Note: the ERC-165 identifier for this interface is 0x4bbee2df.
  1083.      * 0x4bbee2df ===
  1084.      *   bytes4(keccak256('transferAndCall(address,uint256)')) ^
  1085.      *   bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^
  1086.      *   bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^
  1087.      *   bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)'))
  1088.      */
  1089.     bytes4 internal constant _INTERFACE_ID_ERC1363_TRANSFER = 0x4bbee2df;
  1090.  
  1091.     /*
  1092.      * Note: the ERC-165 identifier for this interface is 0xfb9ec8ce.
  1093.      * 0xfb9ec8ce ===
  1094.      *   bytes4(keccak256('approveAndCall(address,uint256)')) ^
  1095.      *   bytes4(keccak256('approveAndCall(address,uint256,bytes)'))
  1096.      */
  1097.     bytes4 internal constant _INTERFACE_ID_ERC1363_APPROVE = 0xfb9ec8ce;
  1098.  
  1099.     // Equals to `bytes4(keccak256("onTransferReceived(address,address,uint256,bytes)"))`
  1100.     // which can be also obtained as `IERC1363Receiver(0).onTransferReceived.selector`
  1101.     bytes4 private constant _ERC1363_RECEIVED = 0x88a7ca5c;
  1102.  
  1103.     // Equals to `bytes4(keccak256("onApprovalReceived(address,uint256,bytes)"))`
  1104.     // which can be also obtained as `IERC1363Spender(0).onApprovalReceived.selector`
  1105.     bytes4 private constant _ERC1363_APPROVED = 0x7b04a2d0;
  1106.  
  1107.     /**
  1108.      * @param name Name of the token
  1109.      * @param symbol A symbol to be used as ticker
  1110.      */
  1111.     constructor (
  1112.         string memory name,
  1113.         string memory symbol
  1114.     ) public payable ERC20(name, symbol) {
  1115.         // register the supported interfaces to conform to ERC1363 via ERC165
  1116.         _registerInterface(_INTERFACE_ID_ERC1363_TRANSFER);
  1117.         _registerInterface(_INTERFACE_ID_ERC1363_APPROVE);
  1118.     }
  1119.  
  1120.     /**
  1121.      * @dev Transfer tokens to a specified address and then execute a callback on recipient.
  1122.      * @param to The address to transfer to.
  1123.      * @param value The amount to be transferred.
  1124.      * @return A boolean that indicates if the operation was successful.
  1125.      */
  1126.     function transferAndCall(address to, uint256 value) public override returns (bool) {
  1127.         return transferAndCall(to, value, "");
  1128.     }
  1129.  
  1130.     /**
  1131.      * @dev Transfer tokens to a specified address and then execute a callback on recipient.
  1132.      * @param to The address to transfer to
  1133.      * @param value The amount to be transferred
  1134.      * @param data Additional data with no specified format
  1135.      * @return A boolean that indicates if the operation was successful.
  1136.      */
  1137.     function transferAndCall(address to, uint256 value, bytes memory data) public override returns (bool) {
  1138.         transfer(to, value);
  1139.         require(_checkAndCallTransfer(_msgSender(), to, value, data), "ERC1363: _checkAndCallTransfer reverts");
  1140.         return true;
  1141.     }
  1142.  
  1143.     /**
  1144.      * @dev Transfer tokens from one address to another and then execute a callback on recipient.
  1145.      * @param from The address which you want to send tokens from
  1146.      * @param to The address which you want to transfer to
  1147.      * @param value The amount of tokens to be transferred
  1148.      * @return A boolean that indicates if the operation was successful.
  1149.      */
  1150.     function transferFromAndCall(address from, address to, uint256 value) public override returns (bool) {
  1151.         return transferFromAndCall(from, to, value, "");
  1152.     }
  1153.  
  1154.     /**
  1155.      * @dev Transfer tokens from one address to another and then execute a callback on recipient.
  1156.      * @param from The address which you want to send tokens from
  1157.      * @param to The address which you want to transfer to
  1158.      * @param value The amount of tokens to be transferred
  1159.      * @param data Additional data with no specified format
  1160.      * @return A boolean that indicates if the operation was successful.
  1161.      */
  1162.     function transferFromAndCall(address from, address to, uint256 value, bytes memory data) public override returns (bool) {
  1163.         transferFrom(from, to, value);
  1164.         require(_checkAndCallTransfer(from, to, value, data), "ERC1363: _checkAndCallTransfer reverts");
  1165.         return true;
  1166.     }
  1167.  
  1168.     /**
  1169.      * @dev Approve spender to transfer tokens and then execute a callback on recipient.
  1170.      * @param spender The address allowed to transfer to
  1171.      * @param value The amount allowed to be transferred
  1172.      * @return A boolean that indicates if the operation was successful.
  1173.      */
  1174.     function approveAndCall(address spender, uint256 value) public override returns (bool) {
  1175.         return approveAndCall(spender, value, "");
  1176.     }
  1177.  
  1178.     /**
  1179.      * @dev Approve spender to transfer tokens and then execute a callback on recipient.
  1180.      * @param spender The address allowed to transfer to.
  1181.      * @param value The amount allowed to be transferred.
  1182.      * @param data Additional data with no specified format.
  1183.      * @return A boolean that indicates if the operation was successful.
  1184.      */
  1185.     function approveAndCall(address spender, uint256 value, bytes memory data) public override returns (bool) {
  1186.         approve(spender, value);
  1187.         require(_checkAndCallApprove(spender, value, data), "ERC1363: _checkAndCallApprove reverts");
  1188.         return true;
  1189.     }
  1190.  
  1191.     /**
  1192.      * @dev Internal function to invoke `onTransferReceived` on a target address
  1193.      *  The call is not executed if the target address is not a contract
  1194.      * @param from address Representing the previous owner of the given token value
  1195.      * @param to address Target address that will receive the tokens
  1196.      * @param value uint256 The amount mount of tokens to be transferred
  1197.      * @param data bytes Optional data to send along with the call
  1198.      * @return whether the call correctly returned the expected magic value
  1199.      */
  1200.     function _checkAndCallTransfer(address from, address to, uint256 value, bytes memory data) internal returns (bool) {
  1201.         if (!to.isContract()) {
  1202.             return false;
  1203.         }
  1204.         bytes4 retval = IERC1363Receiver(to).onTransferReceived(
  1205.             _msgSender(), from, value, data
  1206.         );
  1207.         return (retval == _ERC1363_RECEIVED);
  1208.     }
  1209.  
  1210.     /**
  1211.      * @dev Internal function to invoke `onApprovalReceived` on a target address
  1212.      *  The call is not executed if the target address is not a contract
  1213.      * @param spender address The address which will spend the funds
  1214.      * @param value uint256 The amount of tokens to be spent
  1215.      * @param data bytes Optional data to send along with the call
  1216.      * @return whether the call correctly returned the expected magic value
  1217.      */
  1218.     function _checkAndCallApprove(address spender, uint256 value, bytes memory data) internal returns (bool) {
  1219.         if (!spender.isContract()) {
  1220.             return false;
  1221.         }
  1222.         bytes4 retval = IERC1363Spender(spender).onApprovalReceived(
  1223.             _msgSender(), value, data
  1224.         );
  1225.         return (retval == _ERC1363_APPROVED);
  1226.     }
  1227. }
  1228.  
  1229. // File: @openzeppelin/contracts/access/Ownable.sol
  1230.  
  1231. pragma solidity ^0.6.0;
  1232.  
  1233. /**
  1234.  * @dev Contract module which provides a basic access control mechanism, where
  1235.  * there is an account (an owner) that can be granted exclusive access to
  1236.  * specific functions.
  1237.  *
  1238.  * By default, the owner account will be the one that deploys the contract. This
  1239.  * can later be changed with {transferOwnership}.
  1240.  *
  1241.  * This module is used through inheritance. It will make available the modifier
  1242.  * `onlyOwner`, which can be applied to your functions to restrict their use to
  1243.  * the owner.
  1244.  */
  1245. contract Ownable is Context {
  1246.     address private _owner;
  1247.  
  1248.     event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
  1249.  
  1250.     /**
  1251.      * @dev Initializes the contract setting the deployer as the initial owner.
  1252.      */
  1253.     constructor () internal {
  1254.         address msgSender = _msgSender();
  1255.         _owner = msgSender;
  1256.         emit OwnershipTransferred(address(0), msgSender);
  1257.     }
  1258.  
  1259.     /**
  1260.      * @dev Returns the address of the current owner.
  1261.      */
  1262.     function owner() public view returns (address) {
  1263.         return _owner;
  1264.     }
  1265.  
  1266.     /**
  1267.      * @dev Throws if called by any account other than the owner.
  1268.      */
  1269.     modifier onlyOwner() {
  1270.         require(_owner == _msgSender(), "Ownable: caller is not the owner");
  1271.         _;
  1272.     }
  1273.  
  1274.     /**
  1275.      * @dev Leaves the contract without owner. It will not be possible to call
  1276.      * `onlyOwner` functions anymore. Can only be called by the current owner.
  1277.      *
  1278.      * NOTE: Renouncing ownership will leave the contract without an owner,
  1279.      * thereby removing any functionality that is only available to the owner.
  1280.      */
  1281.     function renounceOwnership() public virtual onlyOwner {
  1282.         emit OwnershipTransferred(_owner, address(0));
  1283.         _owner = address(0);
  1284.     }
  1285.  
  1286.     /**
  1287.      * @dev Transfers ownership of the contract to a new account (`newOwner`).
  1288.      * Can only be called by the current owner.
  1289.      */
  1290.     function transferOwnership(address newOwner) public virtual onlyOwner {
  1291.         require(newOwner != address(0), "Ownable: new owner is the zero address");
  1292.         emit OwnershipTransferred(_owner, newOwner);
  1293.         _owner = newOwner;
  1294.     }
  1295. }
  1296.  
  1297. // File: eth-token-recover/contracts/TokenRecover.sol
  1298.  
  1299. pragma solidity ^0.6.0;
  1300.  
  1301.  
  1302.  
  1303. /**
  1304.  * @title TokenRecover
  1305.  * @author Vittorio Minacori (https://github.com/vittominacori)
  1306.  * @dev Allow to recover any ERC20 sent into the contract for error
  1307.  */
  1308. contract TokenRecover is Ownable {
  1309.  
  1310.     /**
  1311.      * @dev Remember that only owner can call so be careful when use on contracts generated from other contracts.
  1312.      * @param tokenAddress The token contract address
  1313.      * @param tokenAmount Number of tokens to be sent
  1314.      */
  1315.     function recoverERC20(address tokenAddress, uint256 tokenAmount) public onlyOwner {
  1316.         IERC20(tokenAddress).transfer(owner(), tokenAmount);
  1317.     }
  1318. }
  1319.  
  1320. // File: @openzeppelin/contracts/utils/EnumerableSet.sol
  1321.  
  1322. pragma solidity ^0.6.0;
  1323.  
  1324. /**
  1325.  * @dev Library for managing
  1326.  * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
  1327.  * types.
  1328.  *
  1329.  * Sets have the following properties:
  1330.  *
  1331.  * - Elements are added, removed, and checked for existence in constant time
  1332.  * (O(1)).
  1333.  * - Elements are enumerated in O(n). No guarantees are made on the ordering.
  1334.  *
  1335.  * ```
  1336.  * contract Example {
  1337.  *     // Add the library methods
  1338.  *     using EnumerableSet for EnumerableSet.AddressSet;
  1339.  *
  1340.  *     // Declare a set state variable
  1341.  *     EnumerableSet.AddressSet private mySet;
  1342.  * }
  1343.  * ```
  1344.  *
  1345.  * As of v3.0.0, only sets of type `address` (`AddressSet`) and `uint256`
  1346.  * (`UintSet`) are supported.
  1347.  */
  1348. library EnumerableSet {
  1349.     // To implement this library for multiple types with as little code
  1350.     // repetition as possible, we write it in terms of a generic Set type with
  1351.     // bytes32 values.
  1352.     // The Set implementation uses private functions, and user-facing
  1353.     // implementations (such as AddressSet) are just wrappers around the
  1354.     // underlying Set.
  1355.     // This means that we can only create new EnumerableSets for types that fit
  1356.     // in bytes32.
  1357.  
  1358.     struct Set {
  1359.         // Storage of set values
  1360.         bytes32[] _values;
  1361.  
  1362.         // Position of the value in the `values` array, plus 1 because index 0
  1363.         // means a value is not in the set.
  1364.         mapping (bytes32 => uint256) _indexes;
  1365.     }
  1366.  
  1367.     /**
  1368.      * @dev Add a value to a set. O(1).
  1369.      *
  1370.      * Returns true if the value was added to the set, that is if it was not
  1371.      * already present.
  1372.      */
  1373.     function _add(Set storage set, bytes32 value) private returns (bool) {
  1374.         if (!_contains(set, value)) {
  1375.             set._values.push(value);
  1376.             // The value is stored at length-1, but we add 1 to all indexes
  1377.             // and use 0 as a sentinel value
  1378.             set._indexes[value] = set._values.length;
  1379.             return true;
  1380.         } else {
  1381.             return false;
  1382.         }
  1383.     }
  1384.  
  1385.     /**
  1386.      * @dev Removes a value from a set. O(1).
  1387.      *
  1388.      * Returns true if the value was removed from the set, that is if it was
  1389.      * present.
  1390.      */
  1391.     function _remove(Set storage set, bytes32 value) private returns (bool) {
  1392.         // We read and store the value's index to prevent multiple reads from the same storage slot
  1393.         uint256 valueIndex = set._indexes[value];
  1394.  
  1395.         if (valueIndex != 0) { // Equivalent to contains(set, value)
  1396.             // To delete an element from the _values array in O(1), we swap the element to delete with the last one in
  1397.             // the array, and then remove the last element (sometimes called as 'swap and pop').
  1398.             // This modifies the order of the array, as noted in {at}.
  1399.  
  1400.             uint256 toDeleteIndex = valueIndex - 1;
  1401.             uint256 lastIndex = set._values.length - 1;
  1402.  
  1403.             // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs
  1404.             // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.
  1405.  
  1406.             bytes32 lastvalue = set._values[lastIndex];
  1407.  
  1408.             // Move the last value to the index where the value to delete is
  1409.             set._values[toDeleteIndex] = lastvalue;
  1410.             // Update the index for the moved value
  1411.             set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based
  1412.  
  1413.             // Delete the slot where the moved value was stored
  1414.             set._values.pop();
  1415.  
  1416.             // Delete the index for the deleted slot
  1417.             delete set._indexes[value];
  1418.  
  1419.             return true;
  1420.         } else {
  1421.             return false;
  1422.         }
  1423.     }
  1424.  
  1425.     /**
  1426.      * @dev Returns true if the value is in the set. O(1).
  1427.      */
  1428.     function _contains(Set storage set, bytes32 value) private view returns (bool) {
  1429.         return set._indexes[value] != 0;
  1430.     }
  1431.  
  1432.     /**
  1433.      * @dev Returns the number of values on the set. O(1).
  1434.      */
  1435.     function _length(Set storage set) private view returns (uint256) {
  1436.         return set._values.length;
  1437.     }
  1438.  
  1439.    /**
  1440.     * @dev Returns the value stored at position `index` in the set. O(1).
  1441.     *
  1442.     * Note that there are no guarantees on the ordering of values inside the
  1443.     * array, and it may change when more values are added or removed.
  1444.     *
  1445.     * Requirements:
  1446.     *
  1447.     * - `index` must be strictly less than {length}.
  1448.     */
  1449.     function _at(Set storage set, uint256 index) private view returns (bytes32) {
  1450.         require(set._values.length > index, "EnumerableSet: index out of bounds");
  1451.         return set._values[index];
  1452.     }
  1453.  
  1454.     // AddressSet
  1455.  
  1456.     struct AddressSet {
  1457.         Set _inner;
  1458.     }
  1459.  
  1460.     /**
  1461.      * @dev Add a value to a set. O(1).
  1462.      *
  1463.      * Returns true if the value was added to the set, that is if it was not
  1464.      * already present.
  1465.      */
  1466.     function add(AddressSet storage set, address value) internal returns (bool) {
  1467.         return _add(set._inner, bytes32(uint256(value)));
  1468.     }
  1469.  
  1470.     /**
  1471.      * @dev Removes a value from a set. O(1).
  1472.      *
  1473.      * Returns true if the value was removed from the set, that is if it was
  1474.      * present.
  1475.      */
  1476.     function remove(AddressSet storage set, address value) internal returns (bool) {
  1477.         return _remove(set._inner, bytes32(uint256(value)));
  1478.     }
  1479.  
  1480.     /**
  1481.      * @dev Returns true if the value is in the set. O(1).
  1482.      */
  1483.     function contains(AddressSet storage set, address value) internal view returns (bool) {
  1484.         return _contains(set._inner, bytes32(uint256(value)));
  1485.     }
  1486.  
  1487.     /**
  1488.      * @dev Returns the number of values in the set. O(1).
  1489.      */
  1490.     function length(AddressSet storage set) internal view returns (uint256) {
  1491.         return _length(set._inner);
  1492.     }
  1493.  
  1494.    /**
  1495.     * @dev Returns the value stored at position `index` in the set. O(1).
  1496.     *
  1497.     * Note that there are no guarantees on the ordering of values inside the
  1498.     * array, and it may change when more values are added or removed.
  1499.     *
  1500.     * Requirements:
  1501.     *
  1502.     * - `index` must be strictly less than {length}.
  1503.     */
  1504.     function at(AddressSet storage set, uint256 index) internal view returns (address) {
  1505.         return address(uint256(_at(set._inner, index)));
  1506.     }
  1507.  
  1508.  
  1509.     // UintSet
  1510.  
  1511.     struct UintSet {
  1512.         Set _inner;
  1513.     }
  1514.  
  1515.     /**
  1516.      * @dev Add a value to a set. O(1).
  1517.      *
  1518.      * Returns true if the value was added to the set, that is if it was not
  1519.      * already present.
  1520.      */
  1521.     function add(UintSet storage set, uint256 value) internal returns (bool) {
  1522.         return _add(set._inner, bytes32(value));
  1523.     }
  1524.  
  1525.     /**
  1526.      * @dev Removes a value from a set. O(1).
  1527.      *
  1528.      * Returns true if the value was removed from the set, that is if it was
  1529.      * present.
  1530.      */
  1531.     function remove(UintSet storage set, uint256 value) internal returns (bool) {
  1532.         return _remove(set._inner, bytes32(value));
  1533.     }
  1534.  
  1535.     /**
  1536.      * @dev Returns true if the value is in the set. O(1).
  1537.      */
  1538.     function contains(UintSet storage set, uint256 value) internal view returns (bool) {
  1539.         return _contains(set._inner, bytes32(value));
  1540.     }
  1541.  
  1542.     /**
  1543.      * @dev Returns the number of values on the set. O(1).
  1544.      */
  1545.     function length(UintSet storage set) internal view returns (uint256) {
  1546.         return _length(set._inner);
  1547.     }
  1548.  
  1549.    /**
  1550.     * @dev Returns the value stored at position `index` in the set. O(1).
  1551.     *
  1552.     * Note that there are no guarantees on the ordering of values inside the
  1553.     * array, and it may change when more values are added or removed.
  1554.     *
  1555.     * Requirements:
  1556.     *
  1557.     * - `index` must be strictly less than {length}.
  1558.     */
  1559.     function at(UintSet storage set, uint256 index) internal view returns (uint256) {
  1560.         return uint256(_at(set._inner, index));
  1561.     }
  1562. }
  1563.  
  1564. // File: @openzeppelin/contracts/access/AccessControl.sol
  1565.  
  1566. pragma solidity ^0.6.0;
  1567.  
  1568.  
  1569.  
  1570.  
  1571. /**
  1572.  * @dev Contract module that allows children to implement role-based access
  1573.  * control mechanisms.
  1574.  *
  1575.  * Roles are referred to by their `bytes32` identifier. These should be exposed
  1576.  * in the external API and be unique. The best way to achieve this is by
  1577.  * using `public constant` hash digests:
  1578.  *
  1579.  * ```
  1580.  * bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
  1581.  * ```
  1582.  *
  1583.  * Roles can be used to represent a set of permissions. To restrict access to a
  1584.  * function call, use {hasRole}:
  1585.  *
  1586.  * ```
  1587.  * function foo() public {
  1588.  *     require(hasRole(MY_ROLE, _msgSender()));
  1589.  *     ...
  1590.  * }
  1591.  * ```
  1592.  *
  1593.  * Roles can be granted and revoked dynamically via the {grantRole} and
  1594.  * {revokeRole} functions. Each role has an associated admin role, and only
  1595.  * accounts that have a role's admin role can call {grantRole} and {revokeRole}.
  1596.  *
  1597.  * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
  1598.  * that only accounts with this role will be able to grant or revoke other
  1599.  * roles. More complex role relationships can be created by using
  1600.  * {_setRoleAdmin}.
  1601.  */
  1602. abstract contract AccessControl is Context {
  1603.     using EnumerableSet for EnumerableSet.AddressSet;
  1604.     using Address for address;
  1605.  
  1606.     struct RoleData {
  1607.         EnumerableSet.AddressSet members;
  1608.         bytes32 adminRole;
  1609.     }
  1610.  
  1611.     mapping (bytes32 => RoleData) private _roles;
  1612.  
  1613.     bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
  1614.  
  1615.     /**
  1616.      * @dev Emitted when `account` is granted `role`.
  1617.      *
  1618.      * `sender` is the account that originated the contract call, an admin role
  1619.      * bearer except when using {_setupRole}.
  1620.      */
  1621.     event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
  1622.  
  1623.     /**
  1624.      * @dev Emitted when `account` is revoked `role`.
  1625.      *
  1626.      * `sender` is the account that originated the contract call:
  1627.      *   - if using `revokeRole`, it is the admin role bearer
  1628.      *   - if using `renounceRole`, it is the role bearer (i.e. `account`)
  1629.      */
  1630.     event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
  1631.  
  1632.     /**
  1633.      * @dev Returns `true` if `account` has been granted `role`.
  1634.      */
  1635.     function hasRole(bytes32 role, address account) public view returns (bool) {
  1636.         return _roles[role].members.contains(account);
  1637.     }
  1638.  
  1639.     /**
  1640.      * @dev Returns the number of accounts that have `role`. Can be used
  1641.      * together with {getRoleMember} to enumerate all bearers of a role.
  1642.      */
  1643.     function getRoleMemberCount(bytes32 role) public view returns (uint256) {
  1644.         return _roles[role].members.length();
  1645.     }
  1646.  
  1647.     /**
  1648.      * @dev Returns one of the accounts that have `role`. `index` must be a
  1649.      * value between 0 and {getRoleMemberCount}, non-inclusive.
  1650.      *
  1651.      * Role bearers are not sorted in any particular way, and their ordering may
  1652.      * change at any point.
  1653.      *
  1654.      * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure
  1655.      * you perform all queries on the same block. See the following
  1656.      * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]
  1657.      * for more information.
  1658.      */
  1659.     function getRoleMember(bytes32 role, uint256 index) public view returns (address) {
  1660.         return _roles[role].members.at(index);
  1661.     }
  1662.  
  1663.     /**
  1664.      * @dev Returns the admin role that controls `role`. See {grantRole} and
  1665.      * {revokeRole}.
  1666.      *
  1667.      * To change a role's admin, use {_setRoleAdmin}.
  1668.      */
  1669.     function getRoleAdmin(bytes32 role) public view returns (bytes32) {
  1670.         return _roles[role].adminRole;
  1671.     }
  1672.  
  1673.     /**
  1674.      * @dev Grants `role` to `account`.
  1675.      *
  1676.      * If `account` had not been already granted `role`, emits a {RoleGranted}
  1677.      * event.
  1678.      *
  1679.      * Requirements:
  1680.      *
  1681.      * - the caller must have ``role``'s admin role.
  1682.      */
  1683.     function grantRole(bytes32 role, address account) public virtual {
  1684.         require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to grant");
  1685.  
  1686.         _grantRole(role, account);
  1687.     }
  1688.  
  1689.     /**
  1690.      * @dev Revokes `role` from `account`.
  1691.      *
  1692.      * If `account` had been granted `role`, emits a {RoleRevoked} event.
  1693.      *
  1694.      * Requirements:
  1695.      *
  1696.      * - the caller must have ``role``'s admin role.
  1697.      */
  1698.     function revokeRole(bytes32 role, address account) public virtual {
  1699.         require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to revoke");
  1700.  
  1701.         _revokeRole(role, account);
  1702.     }
  1703.  
  1704.     /**
  1705.      * @dev Revokes `role` from the calling account.
  1706.      *
  1707.      * Roles are often managed via {grantRole} and {revokeRole}: this function's
  1708.      * purpose is to provide a mechanism for accounts to lose their privileges
  1709.      * if they are compromised (such as when a trusted device is misplaced).
  1710.      *
  1711.      * If the calling account had been granted `role`, emits a {RoleRevoked}
  1712.      * event.
  1713.      *
  1714.      * Requirements:
  1715.      *
  1716.      * - the caller must be `account`.
  1717.      */
  1718.     function renounceRole(bytes32 role, address account) public virtual {
  1719.         require(account == _msgSender(), "AccessControl: can only renounce roles for self");
  1720.  
  1721.         _revokeRole(role, account);
  1722.     }
  1723.  
  1724.     /**
  1725.      * @dev Grants `role` to `account`.
  1726.      *
  1727.      * If `account` had not been already granted `role`, emits a {RoleGranted}
  1728.      * event. Note that unlike {grantRole}, this function doesn't perform any
  1729.      * checks on the calling account.
  1730.      *
  1731.      * [WARNING]
  1732.      * ====
  1733.      * This function should only be called from the constructor when setting
  1734.      * up the initial roles for the system.
  1735.      *
  1736.      * Using this function in any other way is effectively circumventing the admin
  1737.      * system imposed by {AccessControl}.
  1738.      * ====
  1739.      */
  1740.     function _setupRole(bytes32 role, address account) internal virtual {
  1741.         _grantRole(role, account);
  1742.     }
  1743.  
  1744.     /**
  1745.      * @dev Sets `adminRole` as ``role``'s admin role.
  1746.      */
  1747.     function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
  1748.         _roles[role].adminRole = adminRole;
  1749.     }
  1750.  
  1751.     function _grantRole(bytes32 role, address account) private {
  1752.         if (_roles[role].members.add(account)) {
  1753.             emit RoleGranted(role, account, _msgSender());
  1754.         }
  1755.     }
  1756.  
  1757.     function _revokeRole(bytes32 role, address account) private {
  1758.         if (_roles[role].members.remove(account)) {
  1759.             emit RoleRevoked(role, account, _msgSender());
  1760.         }
  1761.     }
  1762. }
  1763.  
  1764. // File: contracts/access/Roles.sol
  1765.  
  1766. pragma solidity ^0.6.0;
  1767.  
  1768.  
  1769. contract Roles is AccessControl {
  1770.  
  1771.     bytes32 public constant MINTER_ROLE = keccak256("MINTER");
  1772.     bytes32 public constant OPERATOR_ROLE = keccak256("OPERATOR");
  1773.  
  1774.     constructor () public {
  1775.         _setupRole(DEFAULT_ADMIN_ROLE, _msgSender());
  1776.         _setupRole(MINTER_ROLE, _msgSender());
  1777.         _setupRole(OPERATOR_ROLE, _msgSender());
  1778.     }
  1779.  
  1780.     modifier onlyMinter() {
  1781.         require(hasRole(MINTER_ROLE, _msgSender()), "Roles: caller does not have the MINTER role");
  1782.         _;
  1783.     }
  1784.  
  1785.     modifier onlyOperator() {
  1786.         require(hasRole(OPERATOR_ROLE, _msgSender()), "Roles: caller does not have the OPERATOR role");
  1787.         _;
  1788.     }
  1789. }
  1790.  
  1791. // File: contracts/BaseToken.sol
  1792.  
  1793. pragma solidity ^0.6.0;
  1794.  
  1795.  
  1796.  
  1797.  
  1798.  
  1799.  
  1800. /**
  1801.  * @title BaseToken
  1802.  * @author Vittorio Minacori (https://github.com/vittominacori)
  1803.  * @dev Implementation of the BaseToken
  1804.  */
  1805. contract BaseToken is ERC20Capped, ERC20Burnable, ERC1363, Roles, TokenRecover {
  1806.  
  1807.     // indicates if minting is finished
  1808.     bool private _mintingFinished = false;
  1809.  
  1810.     // indicates if transfer is enabled
  1811.     bool private _transferEnabled = false;
  1812.  
  1813.     string public constant BUILT_ON = "https://vittominacori.github.io/erc20-generator";
  1814.  
  1815.     /**
  1816.      * @dev Emitted during finish minting
  1817.      */
  1818.     event MintFinished();
  1819.  
  1820.     /**
  1821.      * @dev Emitted during transfer enabling
  1822.      */
  1823.     event TransferEnabled();
  1824.  
  1825.     /**
  1826.      * @dev Tokens can be minted only before minting finished.
  1827.      */
  1828.     modifier canMint() {
  1829.         require(!_mintingFinished, "BaseToken: minting is finished");
  1830.         _;
  1831.     }
  1832.  
  1833.     /**
  1834.      * @dev Tokens can be moved only after if transfer enabled or if you are an approved operator.
  1835.      */
  1836.     modifier canTransfer(address from) {
  1837.         require(
  1838.             _transferEnabled || hasRole(OPERATOR_ROLE, from),
  1839.             "BaseToken: transfer is not enabled or from does not have the OPERATOR role"
  1840.         );
  1841.         _;
  1842.     }
  1843.  
  1844.     /**
  1845.      * @param name Name of the token
  1846.      * @param symbol A symbol to be used as ticker
  1847.      * @param decimals Number of decimals. All the operations are done using the smallest and indivisible token unit
  1848.      * @param cap Maximum number of tokens mintable
  1849.      * @param initialSupply Initial token supply
  1850.      * @param transferEnabled If transfer is enabled on token creation
  1851.      * @param mintingFinished If minting is finished after token creation
  1852.      */
  1853.     constructor(
  1854.         string memory name,
  1855.         string memory symbol,
  1856.         uint8 decimals,
  1857.         uint256 cap,
  1858.         uint256 initialSupply,
  1859.         bool transferEnabled,
  1860.         bool mintingFinished
  1861.     )
  1862.         public
  1863.         ERC20Capped(cap)
  1864.         ERC1363(name, symbol)
  1865.     {
  1866.         require(
  1867.             mintingFinished == false || cap == initialSupply,
  1868.             "BaseToken: if finish minting, cap must be equal to initialSupply"
  1869.         );
  1870.  
  1871.         _setupDecimals(decimals);
  1872.  
  1873.         if (initialSupply > 0) {
  1874.             _mint(owner(), initialSupply);
  1875.         }
  1876.  
  1877.         if (mintingFinished) {
  1878.             finishMinting();
  1879.         }
  1880.  
  1881.         if (transferEnabled) {
  1882.             enableTransfer();
  1883.         }
  1884.     }
  1885.  
  1886.     /**
  1887.      * @return if minting is finished or not.
  1888.      */
  1889.     function mintingFinished() public view returns (bool) {
  1890.         return _mintingFinished;
  1891.     }
  1892.  
  1893.     /**
  1894.      * @return if transfer is enabled or not.
  1895.      */
  1896.     function transferEnabled() public view returns (bool) {
  1897.         return _transferEnabled;
  1898.     }
  1899.  
  1900.     /**
  1901.      * @dev Function to mint tokens.
  1902.      * @param to The address that will receive the minted tokens
  1903.      * @param value The amount of tokens to mint
  1904.      */
  1905.     function mint(address to, uint256 value) public canMint onlyMinter {
  1906.         _mint(to, value);
  1907.     }
  1908.  
  1909.     /**
  1910.      * @dev Transfer tokens to a specified address.
  1911.      * @param to The address to transfer to
  1912.      * @param value The amount to be transferred
  1913.      * @return A boolean that indicates if the operation was successful.
  1914.      */
  1915.     function transfer(address to, uint256 value) public virtual override(ERC20) canTransfer(_msgSender()) returns (bool) {
  1916.         return super.transfer(to, value);
  1917.     }
  1918.  
  1919.     /**
  1920.      * @dev Transfer tokens from one address to another.
  1921.      * @param from The address which you want to send tokens from
  1922.      * @param to The address which you want to transfer to
  1923.      * @param value the amount of tokens to be transferred
  1924.      * @return A boolean that indicates if the operation was successful.
  1925.      */
  1926.     function transferFrom(address from, address to, uint256 value) public virtual override(ERC20) canTransfer(from) returns (bool) {
  1927.         return super.transferFrom(from, to, value);
  1928.     }
  1929.  
  1930.     /**
  1931.      * @dev Function to stop minting new tokens.
  1932.      */
  1933.     function finishMinting() public canMint onlyOwner {
  1934.         _mintingFinished = true;
  1935.  
  1936.         emit MintFinished();
  1937.     }
  1938.  
  1939.     /**
  1940.      * @dev Function to enable transfers.
  1941.      */
  1942.     function enableTransfer() public onlyOwner {
  1943.         _transferEnabled = true;
  1944.  
  1945.         emit TransferEnabled();
  1946.     }
  1947.  
  1948.     /**
  1949.      * @dev See {ERC20-_beforeTokenTransfer}.
  1950.      */
  1951.     function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override(ERC20, ERC20Capped) {
  1952.         super._beforeTokenTransfer(from, to, amount);
  1953.     }
  1954. }
Add Comment
Please, Sign In to add comment