creation_sourcecode: // SPDX-License-Identifier: MIT
  // File: StableCoin_flat.sol
  
  
  // File: @openzeppelin/contracts/utils/math/SafeMath.sol
  
  
  // OpenZeppelin Contracts v4.4.1 (utils/math/SafeMath.sol)
  
  pragma solidity ^0.8.0;
  
  // CAUTION
  // This version of SafeMath should only be used with Solidity 0.8 or later,
  // because it relies on the compiler's built in overflow checks.
  
  /**
   * @dev Wrappers over Solidity's arithmetic operations.
   *
   * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler
   * now has built in overflow checking.
   */
  library SafeMath {
      /**
       * @dev Returns the addition of two unsigned integers, with an overflow flag.
       *
       * _Available since v3.4._
       */
      function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
          unchecked {
              uint256 c = a + b;
              if (c < a) return (false, 0);
              return (true, c);
          }
      }
  
      /**
       * @dev Returns the substraction of two unsigned integers, with an overflow flag.
       *
       * _Available since v3.4._
       */
      function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
          unchecked {
              if (b > a) return (false, 0);
              return (true, a - b);
          }
      }
  
      /**
       * @dev Returns the multiplication of two unsigned integers, with an overflow flag.
       *
       * _Available since v3.4._
       */
      function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
          unchecked {
              // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
              // benefit is lost if 'b' is also tested.
              // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
              if (a == 0) return (true, 0);
              uint256 c = a * b;
              if (c / a != b) return (false, 0);
              return (true, c);
          }
      }
  
      /**
       * @dev Returns the division of two unsigned integers, with a division by zero flag.
       *
       * _Available since v3.4._
       */
      function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
          unchecked {
              if (b == 0) return (false, 0);
              return (true, a / b);
          }
      }
  
      /**
       * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
       *
       * _Available since v3.4._
       */
      function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
          unchecked {
              if (b == 0) return (false, 0);
              return (true, a % b);
          }
      }
  
      /**
       * @dev Returns the addition of two unsigned integers, reverting on
       * overflow.
       *
       * Counterpart to Solidity's `+` operator.
       *
       * Requirements:
       *
       * - Addition cannot overflow.
       */
      function add(uint256 a, uint256 b) internal pure returns (uint256) {
          return a + b;
      }
  
      /**
       * @dev Returns the subtraction of two unsigned integers, reverting on
       * overflow (when the result is negative).
       *
       * Counterpart to Solidity's `-` operator.
       *
       * Requirements:
       *
       * - Subtraction cannot overflow.
       */
      function sub(uint256 a, uint256 b) internal pure returns (uint256) {
          return a - b;
      }
  
      /**
       * @dev Returns the multiplication of two unsigned integers, reverting on
       * overflow.
       *
       * Counterpart to Solidity's `*` operator.
       *
       * Requirements:
       *
       * - Multiplication cannot overflow.
       */
      function mul(uint256 a, uint256 b) internal pure returns (uint256) {
          return a * b;
      }
  
      /**
       * @dev Returns the integer division of two unsigned integers, reverting on
       * division by zero. The result is rounded towards zero.
       *
       * Counterpart to Solidity's `/` operator.
       *
       * Requirements:
       *
       * - The divisor cannot be zero.
       */
      function div(uint256 a, uint256 b) internal pure returns (uint256) {
          return a / b;
      }
  
      /**
       * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
       * reverting when dividing by zero.
       *
       * Counterpart to Solidity's `%` operator. This function uses a `revert`
       * opcode (which leaves remaining gas untouched) while Solidity uses an
       * invalid opcode to revert (consuming all remaining gas).
       *
       * Requirements:
       *
       * - The divisor cannot be zero.
       */
      function mod(uint256 a, uint256 b) internal pure returns (uint256) {
          return a % b;
      }
  
      /**
       * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
       * overflow (when the result is negative).
       *
       * CAUTION: This function is deprecated because it requires allocating memory for the error
       * message unnecessarily. For custom revert reasons use {trySub}.
       *
       * Counterpart to Solidity's `-` operator.
       *
       * Requirements:
       *
       * - Subtraction cannot overflow.
       */
      function sub(
          uint256 a,
          uint256 b,
          string memory errorMessage
      ) internal pure returns (uint256) {
          unchecked {
              require(b <= a, errorMessage);
              return a - b;
          }
      }
  
      /**
       * @dev Returns the integer division of two unsigned integers, reverting with custom message on
       * division by zero. The result is rounded towards zero.
       *
       * Counterpart to Solidity's `/` operator. Note: this function uses a
       * `revert` opcode (which leaves remaining gas untouched) while Solidity
       * uses an invalid opcode to revert (consuming all remaining gas).
       *
       * Requirements:
       *
       * - The divisor cannot be zero.
       */
      function div(
          uint256 a,
          uint256 b,
          string memory errorMessage
      ) internal pure returns (uint256) {
          unchecked {
              require(b > 0, errorMessage);
              return a / b;
          }
      }
  
      /**
       * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
       * reverting with custom message when dividing by zero.
       *
       * CAUTION: This function is deprecated because it requires allocating memory for the error
       * message unnecessarily. For custom revert reasons use {tryMod}.
       *
       * Counterpart to Solidity's `%` operator. This function uses a `revert`
       * opcode (which leaves remaining gas untouched) while Solidity uses an
       * invalid opcode to revert (consuming all remaining gas).
       *
       * Requirements:
       *
       * - The divisor cannot be zero.
       */
      function mod(
          uint256 a,
          uint256 b,
          string memory errorMessage
      ) internal pure returns (uint256) {
          unchecked {
              require(b > 0, errorMessage);
              return a % b;
          }
      }
  }
  
  // File: @openzeppelin/contracts/token/ERC20/IERC20.sol
  
  
  // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/IERC20.sol)
  
  pragma solidity ^0.8.0;
  
  /**
   * @dev Interface of the ERC20 standard as defined in the EIP.
   */
  interface IERC20 {
      /**
       * @dev Returns the amount of tokens in existence.
       */
      function totalSupply() external view returns (uint256);
  
      /**
       * @dev Returns the amount of tokens owned by `account`.
       */
      function balanceOf(address account) external view returns (uint256);
  
      /**
       * @dev Moves `amount` tokens from the caller's account to `to`.
       *
       * Returns a boolean value indicating whether the operation succeeded.
       *
       * Emits a {Transfer} event.
       */
      function transfer(address to, uint256 amount) external returns (bool);
  
      /**
       * @dev Returns the remaining number of tokens that `spender` will be
       * allowed to spend on behalf of `owner` through {transferFrom}. This is
       * zero by default.
       *
       * This value changes when {approve} or {transferFrom} are called.
       */
      function allowance(address owner, address spender) external view returns (uint256);
  
      /**
       * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
       *
       * Returns a boolean value indicating whether the operation succeeded.
       *
       * IMPORTANT: Beware that changing an allowance with this method brings the risk
       * that someone may use both the old and the new allowance by unfortunate
       * transaction ordering. One possible solution to mitigate this race
       * condition is to first reduce the spender's allowance to 0 and set the
       * desired value afterwards:
       * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
       *
       * Emits an {Approval} event.
       */
      function approve(address spender, uint256 amount) external returns (bool);
  
      /**
       * @dev Moves `amount` tokens from `from` to `to` using the
       * allowance mechanism. `amount` is then deducted from the caller's
       * allowance.
       *
       * Returns a boolean value indicating whether the operation succeeded.
       *
       * Emits a {Transfer} event.
       */
      function transferFrom(
          address from,
          address to,
          uint256 amount
      ) external returns (bool);
  
      /**
       * @dev Emitted when `value` tokens are moved from one account (`from`) to
       * another (`to`).
       *
       * Note that `value` may be zero.
       */
      event Transfer(address indexed from, address indexed to, uint256 value);
  
      /**
       * @dev Emitted when the allowance of a `spender` for an `owner` is set by
       * a call to {approve}. `value` is the new allowance.
       */
      event Approval(address indexed owner, address indexed spender, uint256 value);
  }
  
  // File: @openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol
  
  
  // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)
  
  pragma solidity ^0.8.0;
  
  
  /**
   * @dev Interface for the optional metadata functions from the ERC20 standard.
   *
   * _Available since v4.1._
   */
  interface IERC20Metadata is IERC20 {
      /**
       * @dev Returns the name of the token.
       */
      function name() external view returns (string memory);
  
      /**
       * @dev Returns the symbol of the token.
       */
      function symbol() external view returns (string memory);
  
      /**
       * @dev Returns the decimals places of the token.
       */
      function decimals() external view returns (uint8);
  }
  
  // File: @openzeppelin/contracts/utils/introspection/IERC165.sol
  
  
  // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)
  
  pragma solidity ^0.8.0;
  
  /**
   * @dev Interface of the ERC165 standard, as defined in the
   * https://eips.ethereum.org/EIPS/eip-165[EIP].
   *
   * Implementers can declare support of contract interfaces, which can then be
   * queried by others ({ERC165Checker}).
   *
   * For an implementation, see {ERC165}.
   */
  interface IERC165 {
      /**
       * @dev Returns true if this contract implements the interface defined by
       * `interfaceId`. See the corresponding
       * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
       * to learn more about how these ids are created.
       *
       * This function call must use less than 30 000 gas.
       */
      function supportsInterface(bytes4 interfaceId) external view returns (bool);
  }
  
  // File: @openzeppelin/contracts/utils/introspection/ERC165.sol
  
  
  // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)
  
  pragma solidity ^0.8.0;
  
  
  /**
   * @dev Implementation of the {IERC165} interface.
   *
   * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
   * for the additional interface id that will be supported. For example:
   *
   * ```solidity
   * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
   *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
   * }
   * ```
   *
   * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
   */
  abstract contract ERC165 is IERC165 {
      /**
       * @dev See {IERC165-supportsInterface}.
       */
      function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
          return interfaceId == type(IERC165).interfaceId;
      }
  }
  
  // File: @openzeppelin/contracts/utils/Strings.sol
  
  
  // OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)
  
  pragma solidity ^0.8.0;
  
  /**
   * @dev String operations.
   */
  library Strings {
      bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
  
      /**
       * @dev Converts a `uint256` to its ASCII `string` decimal representation.
       */
      function toString(uint256 value) internal pure returns (string memory) {
          // Inspired by OraclizeAPI's implementation - MIT licence
          // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
  
          if (value == 0) {
              return "0";
          }
          uint256 temp = value;
          uint256 digits;
          while (temp != 0) {
              digits++;
              temp /= 10;
          }
          bytes memory buffer = new bytes(digits);
          while (value != 0) {
              digits -= 1;
              buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
              value /= 10;
          }
          return string(buffer);
      }
  
      /**
       * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
       */
      function toHexString(uint256 value) internal pure returns (string memory) {
          if (value == 0) {
              return "0x00";
          }
          uint256 temp = value;
          uint256 length = 0;
          while (temp != 0) {
              length++;
              temp >>= 8;
          }
          return toHexString(value, length);
      }
  
      /**
       * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
       */
      function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
          bytes memory buffer = new bytes(2 * length + 2);
          buffer[0] = "0";
          buffer[1] = "x";
          for (uint256 i = 2 * length + 1; i > 1; --i) {
              buffer[i] = _HEX_SYMBOLS[value & 0xf];
              value >>= 4;
          }
          require(value == 0, "Strings: hex length insufficient");
          return string(buffer);
      }
  }
  
  // File: @openzeppelin/contracts/access/IAccessControl.sol
  
  
  // OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)
  
  pragma solidity ^0.8.0;
  
  /**
   * @dev External interface of AccessControl declared to support ERC165 detection.
   */
  interface IAccessControl {
      /**
       * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
       *
       * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
       * {RoleAdminChanged} not being emitted signaling this.
       *
       * _Available since v3.1._
       */
      event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);
  
      /**
       * @dev Emitted when `account` is granted `role`.
       *
       * `sender` is the account that originated the contract call, an admin role
       * bearer except when using {AccessControl-_setupRole}.
       */
      event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
  
      /**
       * @dev Emitted when `account` is revoked `role`.
       *
       * `sender` is the account that originated the contract call:
       *   - if using `revokeRole`, it is the admin role bearer
       *   - if using `renounceRole`, it is the role bearer (i.e. `account`)
       */
      event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
  
      /**
       * @dev Returns `true` if `account` has been granted `role`.
       */
      function hasRole(bytes32 role, address account) external view returns (bool);
  
      /**
       * @dev Returns the admin role that controls `role`. See {grantRole} and
       * {revokeRole}.
       *
       * To change a role's admin, use {AccessControl-_setRoleAdmin}.
       */
      function getRoleAdmin(bytes32 role) external view returns (bytes32);
  
      /**
       * @dev Grants `role` to `account`.
       *
       * If `account` had not been already granted `role`, emits a {RoleGranted}
       * event.
       *
       * Requirements:
       *
       * - the caller must have ``role``'s admin role.
       */
      function grantRole(bytes32 role, address account) external;
  
      /**
       * @dev Revokes `role` from `account`.
       *
       * If `account` had been granted `role`, emits a {RoleRevoked} event.
       *
       * Requirements:
       *
       * - the caller must have ``role``'s admin role.
       */
      function revokeRole(bytes32 role, address account) external;
  
      /**
       * @dev Revokes `role` from the calling account.
       *
       * Roles are often managed via {grantRole} and {revokeRole}: this function's
       * purpose is to provide a mechanism for accounts to lose their privileges
       * if they are compromised (such as when a trusted device is misplaced).
       *
       * If the calling account had been granted `role`, emits a {RoleRevoked}
       * event.
       *
       * Requirements:
       *
       * - the caller must be `account`.
       */
      function renounceRole(bytes32 role, address account) external;
  }
  
  // File: @openzeppelin/contracts/utils/Context.sol
  
  
  // OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
  
  pragma solidity ^0.8.0;
  
  /**
   * @dev Provides information about the current execution context, including the
   * sender of the transaction and its data. While these are generally available
   * via msg.sender and msg.data, they should not be accessed in such a direct
   * manner, since when dealing with meta-transactions the account sending and
   * paying for execution may not be the actual sender (as far as an application
   * is concerned).
   *
   * This contract is only required for intermediate, library-like contracts.
   */
  abstract contract Context {
      function _msgSender() internal view virtual returns (address) {
          return msg.sender;
      }
  
      function _msgData() internal view virtual returns (bytes calldata) {
          return msg.data;
      }
  }
  
  // File: contracts/Ownable.sol
  
  
  pragma solidity ^0.8.0;
  
  
  contract Ownable is Context {
      address private _owner;
      address private _proposedOwner;
  
      event ProposeOwner(address indexed proposedOwner);
      event ClaimOwnership(address newOwner);
  
      constructor() {
          address msgSender = _msgSender();
          _owner = msgSender;
          emit ClaimOwnership(msgSender);
      }
  
      function owner() public view returns (address) {
          return _owner;
      }
  
      function proposedOwner() public view returns (address) {
          return _proposedOwner;
      }
  
      modifier onlyOwner() {
          require(
              _owner == _msgSender(),
              "Only the owner can call this function."
          );
          _;
      }
  
      modifier onlyProposedOwner() {
          require(
              _msgSender() == _proposedOwner,
              "Only the proposed owner can call this function."
          );
          _;
      }
  
      function disregardProposedOwner() private onlyOwner {
          _proposedOwner = address(0);
      }
  
      function proposeOwner(address newOwner) public onlyOwner {
          require(newOwner != address(0), "Cannot propose 0x0 as new owner.");
          _proposedOwner = newOwner;
          emit ProposeOwner(_proposedOwner);
      }
  
      function claimOwnership() public virtual onlyProposedOwner {
          _owner = _proposedOwner;
          _proposedOwner = address(0);
          emit ClaimOwnership(_owner);
      }
  
      uint256[49] private __gap;
  }
  // File: contracts/ExternallyTransferable.sol
  
  
  pragma solidity ^0.8.0;
  
  
  
  abstract contract ExternallyTransferable is Context {
      using SafeMath for uint256;
  
      // address => string (network URI) => bytes (external address) => amount
      mapping(address => mapping(string => mapping(bytes => uint256)))
          private _externalAllowances;
  
      function externalAllowanceOf(
          address owner,
          string memory networkURI,
          bytes memory externalAddress
      ) public view returns (uint256) {
          return _externalAllowances[owner][networkURI][externalAddress];
      }
  
      // User calls to allocate external transfer
      function approveExternalTransfer(
          string memory networkURI,
          bytes memory externalAddress,
          uint256 amount
      ) public virtual {
          _approveExternalAllowance(_msgSender(), networkURI, externalAddress, amount);
      }
  
      // Bridge calls after externalTransfer
      function _approveExternalAllowance(
          address from,
          string memory networkURI,
          bytes memory to,
          uint256 amount
      ) internal virtual {
          require(_msgSender() != address(0), "Approve from the zero address");
          require(from != address(0), "Approve for the zero address");
          _externalAllowances[from][networkURI][to] = amount;
      }
  
      // Bridge calls to burn coins on this network (sending external transfer)
      function externalTransfer(
          address from,
          string memory networkURI,
          bytes memory to, // external address
          uint256 amount
      ) public virtual {}
  
      // Bridge calls to mint coins on this network (receiving external transfer)
      function externalTransferFrom(
          bytes memory from, // external address
          string memory networkURI,
          address to,
          uint256 amount
      ) public virtual {}
  }
  // File: @openzeppelin/contracts/token/ERC20/ERC20.sol
  
  
  // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/ERC20.sol)
  
  pragma solidity ^0.8.0;
  
  
  
  
  /**
   * @dev Implementation of the {IERC20} interface.
   *
   * This implementation is agnostic to the way tokens are created. This means
   * that a supply mechanism has to be added in a derived contract using {_mint}.
   * For a generic mechanism see {ERC20PresetMinterPauser}.
   *
   * TIP: For a detailed writeup see our guide
   * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
   * to implement supply mechanisms].
   *
   * We have followed general OpenZeppelin Contracts guidelines: functions revert
   * instead returning `false` on failure. This behavior is nonetheless
   * conventional and does not conflict with the expectations of ERC20
   * applications.
   *
   * Additionally, an {Approval} event is emitted on calls to {transferFrom}.
   * This allows applications to reconstruct the allowance for all accounts just
   * by listening to said events. Other implementations of the EIP may not emit
   * these events, as it isn't required by the specification.
   *
   * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
   * functions have been added to mitigate the well-known issues around setting
   * allowances. See {IERC20-approve}.
   */
  contract ERC20 is Context, IERC20, IERC20Metadata {
      mapping(address => uint256) private _balances;
  
      mapping(address => mapping(address => uint256)) private _allowances;
  
      uint256 private _totalSupply;
  
      string private _name;
      string private _symbol;
  
      /**
       * @dev Sets the values for {name} and {symbol}.
       *
       * The default value of {decimals} is 18. To select a different value for
       * {decimals} you should overload it.
       *
       * All two of these values are immutable: they can only be set once during
       * construction.
       */
      constructor(string memory name_, string memory symbol_) {
          _name = name_;
          _symbol = symbol_;
      }
  
      /**
       * @dev Returns the name of the token.
       */
      function name() public view virtual override returns (string memory) {
          return _name;
      }
  
      /**
       * @dev Returns the symbol of the token, usually a shorter version of the
       * name.
       */
      function symbol() public view virtual override returns (string memory) {
          return _symbol;
      }
  
      /**
       * @dev Returns the number of decimals used to get its user representation.
       * For example, if `decimals` equals `2`, a balance of `505` tokens should
       * be displayed to a user as `5.05` (`505 / 10 ** 2`).
       *
       * Tokens usually opt for a value of 18, imitating the relationship between
       * Ether and Wei. This is the value {ERC20} uses, unless this function is
       * overridden;
       *
       * NOTE: This information is only used for _display_ purposes: it in
       * no way affects any of the arithmetic of the contract, including
       * {IERC20-balanceOf} and {IERC20-transfer}.
       */
      function decimals() public view virtual override returns (uint8) {
          return 18;
      }
  
      /**
       * @dev See {IERC20-totalSupply}.
       */
      function totalSupply() public view virtual override returns (uint256) {
          return _totalSupply;
      }
  
      /**
       * @dev See {IERC20-balanceOf}.
       */
      function balanceOf(address account) public view virtual override returns (uint256) {
          return _balances[account];
      }
  
      /**
       * @dev See {IERC20-transfer}.
       *
       * Requirements:
       *
       * - `to` cannot be the zero address.
       * - the caller must have a balance of at least `amount`.
       */
      function transfer(address to, uint256 amount) public virtual override returns (bool) {
          address owner = _msgSender();
          _transfer(owner, to, amount);
          return true;
      }
  
      /**
       * @dev See {IERC20-allowance}.
       */
      function allowance(address owner, address spender) public view virtual override returns (uint256) {
          return _allowances[owner][spender];
      }
  
      /**
       * @dev See {IERC20-approve}.
       *
       * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on
       * `transferFrom`. This is semantically equivalent to an infinite approval.
       *
       * Requirements:
       *
       * - `spender` cannot be the zero address.
       */
      function approve(address spender, uint256 amount) public virtual override returns (bool) {
          address owner = _msgSender();
          _approve(owner, spender, amount);
          return true;
      }
  
      /**
       * @dev See {IERC20-transferFrom}.
       *
       * Emits an {Approval} event indicating the updated allowance. This is not
       * required by the EIP. See the note at the beginning of {ERC20}.
       *
       * NOTE: Does not update the allowance if the current allowance
       * is the maximum `uint256`.
       *
       * Requirements:
       *
       * - `from` and `to` cannot be the zero address.
       * - `from` must have a balance of at least `amount`.
       * - the caller must have allowance for ``from``'s tokens of at least
       * `amount`.
       */
      function transferFrom(
          address from,
          address to,
          uint256 amount
      ) public virtual override returns (bool) {
          address spender = _msgSender();
          _spendAllowance(from, spender, amount);
          _transfer(from, to, amount);
          return true;
      }
  
      /**
       * @dev Atomically increases the allowance granted to `spender` by the caller.
       *
       * This is an alternative to {approve} that can be used as a mitigation for
       * problems described in {IERC20-approve}.
       *
       * Emits an {Approval} event indicating the updated allowance.
       *
       * Requirements:
       *
       * - `spender` cannot be the zero address.
       */
      function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
          address owner = _msgSender();
          _approve(owner, spender, _allowances[owner][spender] + addedValue);
          return true;
      }
  
      /**
       * @dev Atomically decreases the allowance granted to `spender` by the caller.
       *
       * This is an alternative to {approve} that can be used as a mitigation for
       * problems described in {IERC20-approve}.
       *
       * Emits an {Approval} event indicating the updated allowance.
       *
       * Requirements:
       *
       * - `spender` cannot be the zero address.
       * - `spender` must have allowance for the caller of at least
       * `subtractedValue`.
       */
      function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
          address owner = _msgSender();
          uint256 currentAllowance = _allowances[owner][spender];
          require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
          unchecked {
              _approve(owner, spender, currentAllowance - subtractedValue);
          }
  
          return true;
      }
  
      /**
       * @dev Moves `amount` of tokens from `sender` to `recipient`.
       *
       * This internal function is equivalent to {transfer}, and can be used to
       * e.g. implement automatic token fees, slashing mechanisms, etc.
       *
       * Emits a {Transfer} event.
       *
       * Requirements:
       *
       * - `from` cannot be the zero address.
       * - `to` cannot be the zero address.
       * - `from` must have a balance of at least `amount`.
       */
      function _transfer(
          address from,
          address to,
          uint256 amount
      ) internal virtual {
          require(from != address(0), "ERC20: transfer from the zero address");
          require(to != address(0), "ERC20: transfer to the zero address");
  
          _beforeTokenTransfer(from, to, amount);
  
          uint256 fromBalance = _balances[from];
          require(fromBalance >= amount, "ERC20: transfer amount exceeds balance");
          unchecked {
              _balances[from] = fromBalance - amount;
          }
          _balances[to] += amount;
  
          _afterTokenTransfer(from, to, amount);
      }
  
      /** @dev Creates `amount` tokens and assigns them to `account`, increasing
       * the total supply.
       *
       * Emits a {Transfer} event with `from` set to the zero address.
       *
       * Requirements:
       *
       * - `account` cannot be the zero address.
       */
      function _mint(address account, uint256 amount) internal virtual {
          require(account != address(0), "ERC20: mint to the zero address");
  
          _beforeTokenTransfer(address(0), account, amount);
  
          _totalSupply += amount;
          _balances[account] += amount;
          emit Transfer(address(0), account, amount);
  
          _afterTokenTransfer(address(0), account, amount);
      }
  
      /**
       * @dev Destroys `amount` tokens from `account`, reducing the
       * total supply.
       *
       * Emits a {Transfer} event with `to` set to the zero address.
       *
       * Requirements:
       *
       * - `account` cannot be the zero address.
       * - `account` must have at least `amount` tokens.
       */
      function _burn(address account, uint256 amount) internal virtual {
          require(account != address(0), "ERC20: burn from the zero address");
  
          _beforeTokenTransfer(account, address(0), amount);
  
          uint256 accountBalance = _balances[account];
          require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
          unchecked {
              _balances[account] = accountBalance - amount;
          }
          _totalSupply -= amount;
  
          emit Transfer(account, address(0), amount);
  
          _afterTokenTransfer(account, address(0), amount);
      }
  
      /**
       * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
       *
       * This internal function is equivalent to `approve`, and can be used to
       * e.g. set automatic allowances for certain subsystems, etc.
       *
       * Emits an {Approval} event.
       *
       * Requirements:
       *
       * - `owner` cannot be the zero address.
       * - `spender` cannot be the zero address.
       */
      function _approve(
          address owner,
          address spender,
          uint256 amount
      ) internal virtual {
          require(owner != address(0), "ERC20: approve from the zero address");
          require(spender != address(0), "ERC20: approve to the zero address");
  
          _allowances[owner][spender] = amount;
          emit Approval(owner, spender, amount);
      }
  
      /**
       * @dev Spend `amount` form the allowance of `owner` toward `spender`.
       *
       * Does not update the allowance amount in case of infinite allowance.
       * Revert if not enough allowance is available.
       *
       * Might emit an {Approval} event.
       */
      function _spendAllowance(
          address owner,
          address spender,
          uint256 amount
      ) internal virtual {
          uint256 currentAllowance = allowance(owner, spender);
          if (currentAllowance != type(uint256).max) {
              require(currentAllowance >= amount, "ERC20: insufficient allowance");
              unchecked {
                  _approve(owner, spender, currentAllowance - amount);
              }
          }
      }
  
      /**
       * @dev Hook that is called before any transfer of tokens. This includes
       * minting and burning.
       *
       * Calling conditions:
       *
       * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
       * will be transferred to `to`.
       * - when `from` is zero, `amount` tokens will be minted for `to`.
       * - when `to` is zero, `amount` of ``from``'s tokens will be burned.
       * - `from` and `to` are never both zero.
       *
       * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
       */
      function _beforeTokenTransfer(
          address from,
          address to,
          uint256 amount
      ) internal virtual {}
  
      /**
       * @dev Hook that is called after any transfer of tokens. This includes
       * minting and burning.
       *
       * Calling conditions:
       *
       * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
       * has been transferred to `to`.
       * - when `from` is zero, `amount` tokens have been minted for `to`.
       * - when `to` is zero, `amount` of ``from``'s tokens have been burned.
       * - `from` and `to` are never both zero.
       *
       * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
       */
      function _afterTokenTransfer(
          address from,
          address to,
          uint256 amount
      ) internal virtual {}
  }
  
  // File: @openzeppelin/contracts/access/AccessControl.sol
  
  
  // OpenZeppelin Contracts (last updated v4.5.0) (access/AccessControl.sol)
  
  pragma solidity ^0.8.0;
  
  
  
  
  
  /**
   * @dev Contract module that allows children to implement role-based access
   * control mechanisms. This is a lightweight version that doesn't allow enumerating role
   * members except through off-chain means by accessing the contract event logs. Some
   * applications may benefit from on-chain enumerability, for those cases see
   * {AccessControlEnumerable}.
   *
   * Roles are referred to by their `bytes32` identifier. These should be exposed
   * in the external API and be unique. The best way to achieve this is by
   * using `public constant` hash digests:
   *
   * ```
   * bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
   * ```
   *
   * Roles can be used to represent a set of permissions. To restrict access to a
   * function call, use {hasRole}:
   *
   * ```
   * function foo() public {
   *     require(hasRole(MY_ROLE, msg.sender));
   *     ...
   * }
   * ```
   *
   * Roles can be granted and revoked dynamically via the {grantRole} and
   * {revokeRole} functions. Each role has an associated admin role, and only
   * accounts that have a role's admin role can call {grantRole} and {revokeRole}.
   *
   * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
   * that only accounts with this role will be able to grant or revoke other
   * roles. More complex role relationships can be created by using
   * {_setRoleAdmin}.
   *
   * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
   * grant and revoke this role. Extra precautions should be taken to secure
   * accounts that have been granted it.
   */
  abstract contract AccessControl is Context, IAccessControl, ERC165 {
      struct RoleData {
          mapping(address => bool) members;
          bytes32 adminRole;
      }
  
      mapping(bytes32 => RoleData) private _roles;
  
      bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
  
      /**
       * @dev Modifier that checks that an account has a specific role. Reverts
       * with a standardized message including the required role.
       *
       * The format of the revert reason is given by the following regular expression:
       *
       *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
       *
       * _Available since v4.1._
       */
      modifier onlyRole(bytes32 role) {
          _checkRole(role, _msgSender());
          _;
      }
  
      /**
       * @dev See {IERC165-supportsInterface}.
       */
      function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
          return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);
      }
  
      /**
       * @dev Returns `true` if `account` has been granted `role`.
       */
      function hasRole(bytes32 role, address account) public view virtual override returns (bool) {
          return _roles[role].members[account];
      }
  
      /**
       * @dev Revert with a standard message if `account` is missing `role`.
       *
       * The format of the revert reason is given by the following regular expression:
       *
       *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
       */
      function _checkRole(bytes32 role, address account) internal view virtual {
          if (!hasRole(role, account)) {
              revert(
                  string(
                      abi.encodePacked(
                          "AccessControl: account ",
                          Strings.toHexString(uint160(account), 20),
                          " is missing role ",
                          Strings.toHexString(uint256(role), 32)
                      )
                  )
              );
          }
      }
  
      /**
       * @dev Returns the admin role that controls `role`. See {grantRole} and
       * {revokeRole}.
       *
       * To change a role's admin, use {_setRoleAdmin}.
       */
      function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {
          return _roles[role].adminRole;
      }
  
      /**
       * @dev Grants `role` to `account`.
       *
       * If `account` had not been already granted `role`, emits a {RoleGranted}
       * event.
       *
       * Requirements:
       *
       * - the caller must have ``role``'s admin role.
       */
      function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
          _grantRole(role, account);
      }
  
      /**
       * @dev Revokes `role` from `account`.
       *
       * If `account` had been granted `role`, emits a {RoleRevoked} event.
       *
       * Requirements:
       *
       * - the caller must have ``role``'s admin role.
       */
      function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
          _revokeRole(role, account);
      }
  
      /**
       * @dev Revokes `role` from the calling account.
       *
       * Roles are often managed via {grantRole} and {revokeRole}: this function's
       * purpose is to provide a mechanism for accounts to lose their privileges
       * if they are compromised (such as when a trusted device is misplaced).
       *
       * If the calling account had been revoked `role`, emits a {RoleRevoked}
       * event.
       *
       * Requirements:
       *
       * - the caller must be `account`.
       */
      function renounceRole(bytes32 role, address account) public virtual override {
          require(account == _msgSender(), "AccessControl: can only renounce roles for self");
  
          _revokeRole(role, account);
      }
  
      /**
       * @dev Grants `role` to `account`.
       *
       * If `account` had not been already granted `role`, emits a {RoleGranted}
       * event. Note that unlike {grantRole}, this function doesn't perform any
       * checks on the calling account.
       *
       * [WARNING]
       * ====
       * This function should only be called from the constructor when setting
       * up the initial roles for the system.
       *
       * Using this function in any other way is effectively circumventing the admin
       * system imposed by {AccessControl}.
       * ====
       *
       * NOTE: This function is deprecated in favor of {_grantRole}.
       */
      function _setupRole(bytes32 role, address account) internal virtual {
          _grantRole(role, account);
      }
  
      /**
       * @dev Sets `adminRole` as ``role``'s admin role.
       *
       * Emits a {RoleAdminChanged} event.
       */
      function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
          bytes32 previousAdminRole = getRoleAdmin(role);
          _roles[role].adminRole = adminRole;
          emit RoleAdminChanged(role, previousAdminRole, adminRole);
      }
  
      /**
       * @dev Grants `role` to `account`.
       *
       * Internal function without access restriction.
       */
      function _grantRole(bytes32 role, address account) internal virtual {
          if (!hasRole(role, account)) {
              _roles[role].members[account] = true;
              emit RoleGranted(role, account, _msgSender());
          }
      }
  
      /**
       * @dev Revokes `role` from `account`.
       *
       * Internal function without access restriction.
       */
      function _revokeRole(bytes32 role, address account) internal virtual {
          if (hasRole(role, account)) {
              _roles[role].members[account] = false;
              emit RoleRevoked(role, account, _msgSender());
          }
      }
  }
  
  // File: @openzeppelin/contracts/security/Pausable.sol
  
  
  // OpenZeppelin Contracts v4.4.1 (security/Pausable.sol)
  
  pragma solidity ^0.8.0;
  
  
  /**
   * @dev Contract module which allows children to implement an emergency stop
   * mechanism that can be triggered by an authorized account.
   *
   * This module is used through inheritance. It will make available the
   * modifiers `whenNotPaused` and `whenPaused`, which can be applied to
   * the functions of your contract. Note that they will not be pausable by
   * simply including this module, only once the modifiers are put in place.
   */
  abstract contract Pausable is Context {
      /**
       * @dev Emitted when the pause is triggered by `account`.
       */
      event Paused(address account);
  
      /**
       * @dev Emitted when the pause is lifted by `account`.
       */
      event Unpaused(address account);
  
      bool private _paused;
  
      /**
       * @dev Initializes the contract in unpaused state.
       */
      constructor() {
          _paused = false;
      }
  
      /**
       * @dev Returns true if the contract is paused, and false otherwise.
       */
      function paused() public view virtual returns (bool) {
          return _paused;
      }
  
      /**
       * @dev Modifier to make a function callable only when the contract is not paused.
       *
       * Requirements:
       *
       * - The contract must not be paused.
       */
      modifier whenNotPaused() {
          require(!paused(), "Pausable: paused");
          _;
      }
  
      /**
       * @dev Modifier to make a function callable only when the contract is paused.
       *
       * Requirements:
       *
       * - The contract must be paused.
       */
      modifier whenPaused() {
          require(paused(), "Pausable: not paused");
          _;
      }
  
      /**
       * @dev Triggers stopped state.
       *
       * Requirements:
       *
       * - The contract must not be paused.
       */
      function _pause() internal virtual whenNotPaused {
          _paused = true;
          emit Paused(_msgSender());
      }
  
      /**
       * @dev Returns to normal state.
       *
       * Requirements:
       *
       * - The contract must be paused.
       */
      function _unpause() internal virtual whenPaused {
          _paused = false;
          emit Unpaused(_msgSender());
      }
  }
  
  // File: contracts/StableCoin.sol
  
  
  pragma solidity ^0.8.0;
  
  contract StableCoin is
      Context, // provides _msgSender(), _msgData()
      Pausable, // provides _pause(), _unpause()
      Ownable, // Ownable, Claimable
      AccessControl, // RBAC for KYC, Frozen
      ERC20, // ERC20 Functions (transfer, balance, allowance, mint, burn)
      ExternallyTransferable // Supports External Transfers
  {
      using SafeMath for uint256;
      //using SafeERC20 for IERC20;
  
      // Defined Roles
      bytes32 private constant KYC_PASSED = keccak256("KYC_PASSED");
      bytes32 private constant FROZEN = keccak256("FROZEN");
  
      // Special People
      address private _supplyManager;
      address private _complianceManager;
      address private _enforcementManager;
  
      // Events Emitted
      event Constructed(
          string tokenName,
          string tokenSymbol,
          uint256 totalSupply
      );
  
      // Privileged Roles
      event ChangeSupplyManager(address newSupplyManager);
      event ChangeComplianceManager(address newComplianceManager);
      event ChangeEnforcementManager(address newEnforcementManager);
  
      // ERC20+
      event Wipe(address account, uint256 amount);
      event Mint(address account, uint256 amount);
      event Burn(address account, uint256 amount);
      //event Transfer(address sender, address recipient, uint256 amount);
      event Approve(address sender, address spender, uint256 amount);
      event IncreaseAllowance(address sender, address spender, uint256 amount);
      event DecreaseAllowance(address sender, address spender, uint256 amount);
  
      // KYC
      event Freeze(address account); // Freeze: Freeze this account
      event Unfreeze(address account);
      event SetKycPassed(address account);
      event UnsetKycPassed(address account);
  
      // Halt
      event Pause(address sender); // Pause: Pause entire contract
      event Unpause(address sender);
  
      // "External Transfer"
      // Signify to the coin bridge to perform external transfer
      event ApproveExternalTransfer(address from,string networkURI,bytes to,uint256 amount);
      event ExternalTransfer(address from,string networkURI,bytes to,uint256 amount);
      event ExternalTransferFrom(bytes from,string networkURI,address to,uint256 amount);
  
      constructor() ERC20("Gram Platinum", "GRAMP") {
          _supplyManager = _msgSender();
          _complianceManager = _msgSender();
          _enforcementManager = _msgSender();
  
          // Owner has Admin Privileges on all roles
          _setupRole(DEFAULT_ADMIN_ROLE, _msgSender()); // sudo role
  
          // Give CM ability to grant/revoke roles (but not admin of this role)
          grantRole(DEFAULT_ADMIN_ROLE, _msgSender());
  
          // KYC accounts
          grantRole(KYC_PASSED, _msgSender());
          grantRole(KYC_PASSED, _msgSender());
          grantRole(KYC_PASSED, _msgSender());
          grantRole(KYC_PASSED, _msgSender());
  
          // Give supply manager all tokens
          mint(0); // Emits Mint
  
          
          // Did it
          emit Constructed(
              name(),
              symbol(),
              0
          );
      }
  
      /*
       * RBAC
       */
  
      function supplyManager() public view returns (address) {
          return _supplyManager;
      }
  
      modifier onlySupplyManager() {
          require(
              _msgSender() == supplyManager() || _msgSender() == owner(),
              "Only the supply manager can call this function."
          );
          _;
      }
  
      function changeSupplyManager(address newSupplyManager) public onlyOwner {
          require(
              newSupplyManager != address(0),
              "Cannot change supply manager to 0x0."
          );
          revokeRole(KYC_PASSED, _supplyManager);
          _supplyManager = newSupplyManager;
          grantRole(KYC_PASSED, _supplyManager);
          revokeRole(FROZEN, _supplyManager);
          emit ChangeSupplyManager(newSupplyManager);
      }
  
      function complianceManager() public view returns (address) {
          return _complianceManager;
      }
  
      modifier onlyComplianceManager() {
          require(
              _msgSender() == complianceManager() || _msgSender() == owner(),
              "Only the Compliance Manager can call this function."
          );
          _;
      }
  
      function changeComplianceManager(address newComplianceManager)
          public
          onlyOwner
      {
          require(
              newComplianceManager != address(0),
              "Cannot change compliance manager to 0x0."
          );
          revokeRole(KYC_PASSED, _complianceManager);
          _complianceManager = newComplianceManager;
          grantRole(KYC_PASSED, _complianceManager);
          revokeRole(FROZEN, _complianceManager);
          emit ChangeComplianceManager(newComplianceManager);
      }
  
      function enforcementManager() public view returns (address) {
          return _enforcementManager;
      }
  
      modifier onlyEnforcementManager() {
          require(
              _msgSender() == enforcementManager() || _msgSender() == owner(),
              "Only the Enforcement Manager can call this function."
          );
          _;
      }
  
      function changeEnforcementManager(address newEnforcementManager)
          public
          onlyOwner
      {
          require(
              newEnforcementManager != address(0),
              "Cannot change enforcement manager to 0x0"
          );
          revokeRole(KYC_PASSED, _enforcementManager);
          _enforcementManager = newEnforcementManager;
          grantRole(KYC_PASSED, _enforcementManager);
          revokeRole(FROZEN, _enforcementManager);
          emit ChangeEnforcementManager(newEnforcementManager);
      }
  
      function isPrivilegedRole(address account) public view returns (bool) {
          return
              account == supplyManager() ||
              account == complianceManager() ||
              account == enforcementManager() ||
              account == owner();
      }
  
      modifier requiresKYC() {
          require(
              hasRole(KYC_PASSED, _msgSender()),
              "Calling this function requires KYC approval."
          );
          _;
      }
  
      function isKycPassed(address account) public view returns (bool) {
          return hasRole(KYC_PASSED, account);
      }
  
      // KYC: only CM
      function setKycPassed(address account) public onlyComplianceManager {
          grantRole(KYC_PASSED, account);
          emit SetKycPassed(account);
      }
  
      // Un-KYC: only CM, only non-privileged accounts
      function unsetKycPassed(address account) public onlyComplianceManager {
          require(
              !isPrivilegedRole(account),
              "Cannot unset KYC for administrator account."
          );
          require(account != address(0), "Cannot unset KYC for address 0x0.");
          revokeRole(KYC_PASSED, account);
          emit UnsetKycPassed(account);
      }
  
      modifier requiresNotFrozen() {
          require(
              !hasRole(FROZEN, _msgSender()),
              "Your account has been frozen, cannot call function."
          );
          _;
      }
  
      function isFrozen(address account) public view returns (bool) {
          return hasRole(FROZEN, account);
      }
  
      // Freeze an account: only CM, only non-privileged accounts
      function freeze(address account) public onlyComplianceManager {
          require(
              !isPrivilegedRole(account),
              "Cannot freeze administrator account."
          );
          require(account != address(0), "Cannot freeze address 0x0.");
          grantRole(FROZEN, account);
          emit Freeze(account);
      }
  
      // Unfreeze an account: only CM
      function unfreeze(address account) public onlyComplianceManager {
          revokeRole(FROZEN, account);
          emit Unfreeze(account);
      }
  
      // Check Transfer Allowed (user facing)
      function checkTransferAllowed(address account) public view returns (bool) {
          return isKycPassed(account) && !isFrozen(account);
      }
  
      // Pause: Only CM
      function pause() public onlyComplianceManager {
          _pause();
          emit Pause(_msgSender());
      }
  
      // Unpause: Only CM
      function unpause() public onlyComplianceManager {
          _unpause();
          emit Unpause(_msgSender());
      }
  
      // Claim Ownership
      function claimOwnership() public override(Ownable) onlyProposedOwner {
          address prevOwner = owner();
          super.claimOwnership(); // emits ClaimOwnership
          _setupRole(DEFAULT_ADMIN_ROLE, _msgSender());
          grantRole(KYC_PASSED, _msgSender());
          revokeRole(FROZEN, _msgSender());
          revokeRole(KYC_PASSED, prevOwner);
      }
  
      // Wipe
      function wipe(address account, uint256 amount) public onlyEnforcementManager {
          uint256 balance = balanceOf(account);
          require(
              amount <= balance,
              "Amount cannot be greater than balance"
          );
          super._transfer(account, _supplyManager, amount);
          _burn(_supplyManager, amount);
          emit Wipe(account, amount);
      }
  
      /*
       * Transfers
       */
  
      // Mint
      function mint(uint256 amount) public onlySupplyManager {
          _mint(supplyManager(), amount * 10 ** decimals());
          emit Mint(_msgSender(), amount );
      }
  
      // Burn
      function burn(uint256 amount) public onlySupplyManager {
          _burn(_supplyManager, amount * 10 ** decimals());
          emit Burn(_msgSender(), amount);
      }
  
      // Check Transfer Allowed (internal)
      function _beforeTokenTransfer(
          address from,
          address to,
          uint256 amount
      ) internal override(ERC20) requiresNotFrozen whenNotPaused {
          if (from == supplyManager() && to == address(0)) {
              // allowed (burn)
              super._beforeTokenTransfer(from, to, amount);
              return;
          }
  
          if (to == supplyManager() && from == address(0)) {
              // allowed (mint)
              super._beforeTokenTransfer(from, to, amount);
              return;
          }
  
          if (
              to == supplyManager() &&
              hasRole(FROZEN, from) &&
              amount == balanceOf(from)
          ) {
              // allowed (wipe account)
              super._beforeTokenTransfer(from, to, amount);
              return;
          }
  
          // All other transfers
          //require(isKycPassed(from), "Sender account requires KYC to continue.");
          //require(isKycPassed(to), "Receiver account requires KYC to continue.");
          require(!isFrozen(from), "Sender account is frozen.");
          require(!isFrozen(to), "Receiver account is frozen.");
          super._beforeTokenTransfer(from, to, amount); // callbacks from above (if any)
      }
  
      function transfer(address to, uint256 amount) public override(ERC20) returns (bool) {
          super._transfer(_msgSender(), to, amount);
          emit Transfer(_msgSender(), to, amount);
          return  true;
      }
  
      /*
       * External Transfers
       */
  
      // approve an allowance for transfer to an external network
      function approveExternalTransfer(
          string memory networkURI,
          bytes memory externalAddress,
          uint256 amount
      )
          public
          override(ExternallyTransferable)
          requiresKYC
          requiresNotFrozen
          whenNotPaused
      {
          require(
              amount <= balanceOf(_msgSender()),
              "Cannot approve more than balance."
          );
          super.approveExternalTransfer(networkURI, externalAddress, amount);
          emit ApproveExternalTransfer(
              _msgSender(),
              networkURI,
              externalAddress,
              amount
          );
      }
  
      function externalTransfer(
          address from,
          string memory networkURI,
          bytes memory to,
          uint256 amount
      ) public override(ExternallyTransferable) onlySupplyManager whenNotPaused {
          require(isKycPassed(from), "Spender account requires KYC to continue.");
          require(!isFrozen(from), "Spender account is frozen.");
          uint256 exAllowance = externalAllowanceOf(from, networkURI, to);
          require(amount <= exAllowance, "Amount greater than allowance.");
          super._transfer(from, _supplyManager, amount);
          _burn(_supplyManager, amount);
          _approveExternalAllowance(
              from,
              networkURI,
              to,
              exAllowance.sub(amount)
          );
          emit ExternalTransfer(from, networkURI, to, amount);
      }
  
      function externalTransferFrom(
          bytes memory from,
          string memory networkURI,
          address to,
          uint256 amount
      ) public override(ExternallyTransferable) onlySupplyManager whenNotPaused {
          require(isKycPassed(to), "Recipient account requires KYC to continue.");
          require(!isFrozen(to), "Recipient account is frozen.");
          _mint(_supplyManager, amount);
          super._transfer(_supplyManager, to, amount);
          emit ExternalTransferFrom(from, networkURI, to, amount);
      }
  
      /*
       * Allowances
       */
  
      // Check Allowance Allowed (internal)
      function _beforeTokenAllowance(
          address sender,
          address spender,
          uint256 amount
      ) internal requiresKYC requiresNotFrozen whenNotPaused view {
          require(isKycPassed(spender), "Spender account requires KYC to continue.");
          require(isKycPassed(sender), "Sender account requires KYC to continue.");
          require(!isFrozen(spender), "Spender account is frozen.");
          require(!isFrozen(sender), "Sender account is frozen.");
          require(amount >= 0, "Allowance must be greater than 0.");
      }
  
      // Transfer From (allowance --> user)
      function transferFrom(
          address from,
          address to,
          uint256 amount
      ) public override requiresKYC requiresNotFrozen returns (bool){
          bool returnValue = super.transferFrom(from, to, amount);
          emit Transfer(from, to, amount);
          emit Approve(from, _msgSender(), allowance(from, _msgSender()));
          return returnValue;
      }
  
      // Approve Allowance
      function approveAllowance(address spender, uint256 amount)
          public
          requiresKYC
          requiresNotFrozen
      {
          _beforeTokenAllowance(_msgSender(), spender, amount);
          super._approve(_msgSender(), spender, amount);
          emit Approve(_msgSender(), spender, amount);
      }
  
      // Increase Allowance
      function increaseAllowance(address spender, uint256 amount)
          public
          override(ERC20)
          requiresKYC
          requiresNotFrozen
          returns (bool)
      {
          uint256 newAllowance = allowance(_msgSender(), spender).add(amount);
          _approve(_msgSender(), spender, newAllowance);
          emit IncreaseAllowance(_msgSender(), spender, newAllowance);
          return true;
      }
  
      // Decrease Allowance
      function decreaseAllowance(address spender, uint256 amount)
          public
          override(ERC20)
          requiresKYC
          requiresNotFrozen
          returns (bool)
      {
          uint256 newAllowance = allowance(_msgSender(), spender).sub(
              amount,
              "Amount greater than allowance."
          );
          _approve(_msgSender(), spender, newAllowance);
          emit DecreaseAllowance(_msgSender(), spender, newAllowance);
          return true;
      }
  }