Transaction Hash:
Block:
11867429 at Feb-16-2021 11:01:56 AM +UTC
Transaction Fee:
0.027069 ETH
$111.73
Gas Used:
257,800 Gas / 105 Gwei
Emitted Events:
207 |
0x8c5acf6dbd24c66e6fd44d4a4c3d7a2d955aaad2.0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925( 0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925, 0x00000000000000000000000072eb30d3ca53f5e839325e2eacf535e70a9e6987, 0x0000000000000000000000000000000000000000000000000000000000000000, 0x72eb30d3ca53f5e839325e2eacf535e70a9e6987286156160781530477531896 )
|
208 |
0x8c5acf6dbd24c66e6fd44d4a4c3d7a2d955aaad2.0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef( 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef, 0x00000000000000000000000072eb30d3ca53f5e839325e2eacf535e70a9e6987, 0x0000000000000000000000005ce097139d1a4b5f1ea71142c0e7aadfbff156f5, 0x72eb30d3ca53f5e839325e2eacf535e70a9e6987286156160781530477531896 )
|
209 |
0x974b10a997de02e2c14c439f95eeaa58090a0ca1.0x774facb096e2853303a99ec0d487646131ff041fd1babbea731bd6d8ae981dfe( 0x774facb096e2853303a99ec0d487646131ff041fd1babbea731bd6d8ae981dfe, 0x0000000000000000000000008c5acf6dbd24c66e6fd44d4a4c3d7a2d955aaad2, 0x0000000000000000000000005ce097139d1a4b5f1ea71142c0e7aadfbff156f5, 0x00000000000000000000000072eb30d3ca53f5e839325e2eacf535e70a9e6987, 72eb30d3ca53f5e839325e2eacf535e70a9e6987286156160781530477531896 )
|
Account State Difference:
Address | Before | After | State Difference | ||
---|---|---|---|---|---|
0x02A522D9...32ab880ab | (Mintable: Deployer) | 70.146816773575582644 Eth | 70.147241191075582644 Eth | 0.0004244175 | |
0x5Ce09713...fBff156F5 |
0.0893 Eth
Nonce: 0
|
0.053525 Eth
Nonce: 1
| 0.035775 | ||
0x72eb30D3...70a9e6987 | (Letter to my mother: Deployer) |
0 Eth
Nonce: 0
|
0.0080639325 Eth
Nonce: 0
| 0.0080639325 | |
0x8c5aCF6d...D955AAad2 | |||||
0x974b10a9...8090A0Ca1 | 0.00359215 Eth | 0.0038098 Eth | 0.00021765 | ||
0xEA674fdD...16B898ec8
Miner
| (Ethermine) | 2,439.356919251109320644 Eth | 2,439.383988251109320644 Eth | 0.027069 |
Execution Trace
ETH 0.008706
0x974b10a997de02e2c14c439f95eeaa58090a0ca1.87acbd47( )
-
Null: 0x000...001.d3ec5e48( )
-
0x8c5acf6dbd24c66e6fd44d4a4c3d7a2d955aaad2.081812fc( )
-
0x8c5acf6dbd24c66e6fd44d4a4c3d7a2d955aaad2.e985e9c5( )
-
0x8c5acf6dbd24c66e6fd44d4a4c3d7a2d955aaad2.6352211e( )
-
0x8c5acf6dbd24c66e6fd44d4a4c3d7a2d955aaad2.23b872dd( )
-
0x14b76477739b4eeeab7af197f638d882373b8329.70a08231( )
-
0x8c5acf6dbd24c66e6fd44d4a4c3d7a2d955aaad2.CALL( )
- ETH 0.0004244175
Mintable: Deployer.CALL( )
- ETH 0.0080639325
Letter to my mother: Deployer.CALL( )
GovERC721.earnVotes( _value=8706000000000000, _seller=0x72eb30D3ca53f5e839325E2eACf535E70a9e6987, _buyer=0x5Ce097139d1a4b5F1EA71142c0E7aaDfBff156F5, _contract=0x8c5aCF6dBD24c66e6FD44d4A4C3d7a2D955AAad2 ) => ( False )
-
MintableGovernance.getWashTrader( _account=0x72eb30D3ca53f5e839325E2eACf535E70a9e6987 ) => ( False )
-
MintableGovernance.getWashTrader( _account=0x5Ce097139d1a4b5F1EA71142c0E7aaDfBff156F5 ) => ( False )
-
MintableGovernance.getApprovedContracts( _contract=0x8c5aCF6dBD24c66e6FD44d4A4C3d7a2D955AAad2 ) => ( False )
-
File 1 of 2: GovERC721
File 2 of 2: MintableGovernance
{"AccessControl.sol":{"content":"// SPDX-License-Identifier: MIT\r\n\r\npragma solidity ^0.6.0;\r\n\r\nimport \"./EnumerableSet.sol\";\r\nimport \"./Address.sol\";\r\nimport \"./Context.sol\";\r\n\r\n/**\r\n * @dev Contract module that allows children to implement role-based access\r\n * control mechanisms.\r\n *\r\n * Roles are referred to by their `bytes32` identifier. These should be exposed\r\n * in the external API and be unique. The best way to achieve this is by\r\n * using `public constant` hash digests:\r\n *\r\n * ```\r\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\r\n * ```\r\n *\r\n * Roles can be used to represent a set of permissions. To restrict access to a\r\n * function call, use {hasRole}:\r\n *\r\n * ```\r\n * function foo() public {\r\n * require(hasRole(MY_ROLE, msg.sender));\r\n * ...\r\n * }\r\n * ```\r\n *\r\n * Roles can be granted and revoked dynamically via the {grantRole} and\r\n * {revokeRole} functions. Each role has an associated admin role, and only\r\n * accounts that have a role\u0027s admin role can call {grantRole} and {revokeRole}.\r\n *\r\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\r\n * that only accounts with this role will be able to grant or revoke other\r\n * roles. More complex role relationships can be created by using\r\n * {_setRoleAdmin}.\r\n *\r\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\r\n * grant and revoke this role. Extra precautions should be taken to secure\r\n * accounts that have been granted it.\r\n */\r\nabstract contract AccessControl is Context {\r\n using EnumerableSet for EnumerableSet.AddressSet;\r\n using Address for address;\r\n\r\n struct RoleData {\r\n EnumerableSet.AddressSet members;\r\n bytes32 adminRole;\r\n }\r\n\r\n mapping (bytes32 =\u003e RoleData) private _roles; \r\n \r\n \r\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\r\n\r\n /**\r\n * @dev Emitted when `newAdminRole` is set as ``role``\u0027s admin role, replacing `previousAdminRole`\r\n *\r\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\r\n * {RoleAdminChanged} not being emitted signaling this.\r\n *\r\n * _Available since v3.1._\r\n */\r\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\r\n\r\n /**\r\n * @dev Emitted when `account` is granted `role`.\r\n *\r\n * `sender` is the account that originated the contract call, an admin role\r\n * bearer except when using {_setupRole}.\r\n */\r\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\r\n\r\n /**\r\n * @dev Emitted when `account` is revoked `role`.\r\n *\r\n * `sender` is the account that originated the contract call:\r\n * - if using `revokeRole`, it is the admin role bearer\r\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\r\n */\r\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\r\n\r\n /**\r\n * @dev Returns `true` if `account` has been granted `role`.\r\n */\r\n function hasRole(bytes32 role, address account) public view returns (bool) {\r\n return _roles[role].members.contains(account);\r\n }\r\n\r\n /**\r\n * @dev Returns the number of accounts that have `role`. Can be used\r\n * together with {getRoleMember} to enumerate all bearers of a role.\r\n */\r\n function getRoleMemberCount(bytes32 role) public view returns (uint256) {\r\n return _roles[role].members.length();\r\n }\r\n\r\n /**\r\n * @dev Returns one of the accounts that have `role`. `index` must be a\r\n * value between 0 and {getRoleMemberCount}, non-inclusive.\r\n *\r\n * Role bearers are not sorted in any particular way, and their ordering may\r\n * change at any point.\r\n *\r\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\r\n * you perform all queries on the same block. See the following\r\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\r\n * for more information.\r\n */\r\n function getRoleMember(bytes32 role, uint256 index) public view returns (address) {\r\n return _roles[role].members.at(index);\r\n }\r\n\r\n /**\r\n * @dev Returns the admin role that controls `role`. See {grantRole} and\r\n * {revokeRole}.\r\n *\r\n * To change a role\u0027s admin, use {_setRoleAdmin}.\r\n */\r\n function getRoleAdmin(bytes32 role) public view returns (bytes32) {\r\n return _roles[role].adminRole;\r\n }\r\n\r\n /**\r\n * @dev Grants `role` to `account`.\r\n *\r\n * If `account` had not been already granted `role`, emits a {RoleGranted}\r\n * event.\r\n *\r\n * Requirements:\r\n *\r\n * - the caller must have ``role``\u0027s admin role.\r\n */\r\n function grantRole(bytes32 role, address account) public virtual {\r\n require(hasRole(_roles[role].adminRole, _msgSender()), \"AccessControl: sender must be an admin to grant\");\r\n\r\n _grantRole(role, account);\r\n }\r\n\r\n /**\r\n * @dev Revokes `role` from `account`.\r\n *\r\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\r\n *\r\n * Requirements:\r\n *\r\n * - the caller must have ``role``\u0027s admin role.\r\n */\r\n function revokeRole(bytes32 role, address account) public virtual {\r\n require(hasRole(_roles[role].adminRole, _msgSender()), \"AccessControl: sender must be an admin to revoke\");\r\n\r\n _revokeRole(role, account);\r\n }\r\n\r\n /**\r\n * @dev Revokes `role` from the calling account.\r\n *\r\n * Roles are often managed via {grantRole} and {revokeRole}: this function\u0027s\r\n * purpose is to provide a mechanism for accounts to lose their privileges\r\n * if they are compromised (such as when a trusted device is misplaced).\r\n *\r\n * If the calling account had been granted `role`, emits a {RoleRevoked}\r\n * event.\r\n *\r\n * Requirements:\r\n *\r\n * - the caller must be `account`.\r\n */\r\n function renounceRole(bytes32 role, address account) public virtual {\r\n require(account == _msgSender(), \"AccessControl: can only renounce roles for self\");\r\n\r\n _revokeRole(role, account);\r\n }\r\n\r\n /**\r\n * @dev Grants `role` to `account`.\r\n *\r\n * If `account` had not been already granted `role`, emits a {RoleGranted}\r\n * event. Note that unlike {grantRole}, this function doesn\u0027t perform any\r\n * checks on the calling account.\r\n *\r\n * [WARNING]\r\n * ====\r\n * This function should only be called from the constructor when setting\r\n * up the initial roles for the system.\r\n *\r\n * Using this function in any other way is effectively circumventing the admin\r\n * system imposed by {AccessControl}.\r\n * ====\r\n */\r\n function _setupRole(bytes32 role, address account) internal virtual {\r\n _grantRole(role, account);\r\n }\r\n\r\n /**\r\n * @dev Sets `adminRole` as ``role``\u0027s admin role.\r\n *\r\n * Emits a {RoleAdminChanged} event.\r\n */\r\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\r\n emit RoleAdminChanged(role, _roles[role].adminRole, adminRole);\r\n _roles[role].adminRole = adminRole;\r\n }\r\n\r\n function _grantRole(bytes32 role, address account) private {\r\n if (_roles[role].members.add(account)) {\r\n emit RoleGranted(role, account, _msgSender());\r\n }\r\n }\r\n\r\n function _revokeRole(bytes32 role, address account) private {\r\n if (_roles[role].members.remove(account)) {\r\n emit RoleRevoked(role, account, _msgSender());\r\n }\r\n }\r\n}\r\n"},"Address.sol":{"content":"// SPDX-License-Identifier: MIT\r\n\r\npragma solidity ^0.6.2;\r\n\r\n/**\r\n * @dev Collection of functions related to the address type\r\n */\r\nlibrary Address {\r\n /**\r\n * @dev Returns true if `account` is a contract.\r\n *\r\n * [IMPORTANT]\r\n * ====\r\n * It is unsafe to assume that an address for which this function returns\r\n * false is an externally-owned account (EOA) and not a contract.\r\n *\r\n * Among others, `isContract` will return false for the following\r\n * types of addresses:\r\n *\r\n * - an externally-owned account\r\n * - a contract in construction\r\n * - an address where a contract will be created\r\n * - an address where a contract lived, but was destroyed\r\n * ====\r\n */\r\n function isContract(address account) internal view returns (bool) {\r\n // According to EIP-1052, 0x0 is the value returned for not-yet created accounts\r\n // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned\r\n // for accounts without code, i.e. `keccak256(\u0027\u0027)`\r\n bytes32 codehash;\r\n bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;\r\n // solhint-disable-next-line no-inline-assembly\r\n assembly { codehash := extcodehash(account) }\r\n return (codehash != accountHash \u0026\u0026 codehash != 0x0);\r\n }\r\n\r\n /**\r\n * @dev Replacement for Solidity\u0027s `transfer`: sends `amount` wei to\r\n * `recipient`, forwarding all available gas and reverting on errors.\r\n *\r\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\r\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\r\n * imposed by `transfer`, making them unable to receive funds via\r\n * `transfer`. {sendValue} removes this limitation.\r\n *\r\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\r\n *\r\n * IMPORTANT: because control is transferred to `recipient`, care must be\r\n * taken to not create reentrancy vulnerabilities. Consider using\r\n * {ReentrancyGuard} or the\r\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\r\n */\r\n function sendValue(address payable recipient, uint256 amount) internal {\r\n require(address(this).balance \u003e= amount, \"Address: insufficient balance\");\r\n\r\n // solhint-disable-next-line avoid-low-level-calls, avoid-call-value\r\n (bool success, ) = recipient.call{ value: amount }(\"\");\r\n require(success, \"Address: unable to send value, recipient may have reverted\");\r\n }\r\n\r\n /**\r\n * @dev Performs a Solidity function call using a low level `call`. A\r\n * plain`call` is an unsafe replacement for a function call: use this\r\n * function instead.\r\n *\r\n * If `target` reverts with a revert reason, it is bubbled up by this\r\n * function (like regular Solidity function calls).\r\n *\r\n * Returns the raw returned data. To convert to the expected return value,\r\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\r\n *\r\n * Requirements:\r\n *\r\n * - `target` must be a contract.\r\n * - calling `target` with `data` must not revert.\r\n *\r\n * _Available since v3.1._\r\n */\r\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\r\n return functionCall(target, data, \"Address: low-level call failed\");\r\n }\r\n\r\n /**\r\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\r\n * `errorMessage` as a fallback revert reason when `target` reverts.\r\n *\r\n * _Available since v3.1._\r\n */\r\n function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {\r\n return _functionCallWithValue(target, data, 0, errorMessage);\r\n }\r\n\r\n /**\r\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\r\n * but also transferring `value` wei to `target`.\r\n *\r\n * Requirements:\r\n *\r\n * - the calling contract must have an ETH balance of at least `value`.\r\n * - the called Solidity function must be `payable`.\r\n *\r\n * _Available since v3.1._\r\n */\r\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\r\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\r\n }\r\n\r\n /**\r\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\r\n * with `errorMessage` as a fallback revert reason when `target` reverts.\r\n *\r\n * _Available since v3.1._\r\n */\r\n function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {\r\n require(address(this).balance \u003e= value, \"Address: insufficient balance for call\");\r\n return _functionCallWithValue(target, data, value, errorMessage);\r\n }\r\n\r\n function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {\r\n require(isContract(target), \"Address: call to non-contract\");\r\n\r\n // solhint-disable-next-line avoid-low-level-calls\r\n (bool success, bytes memory returndata) = target.call{ value: weiValue }(data);\r\n if (success) {\r\n return returndata;\r\n } else {\r\n // Look for revert reason and bubble it up if present\r\n if (returndata.length \u003e 0) {\r\n // The easiest way to bubble the revert reason is using memory via assembly\r\n\r\n // solhint-disable-next-line no-inline-assembly\r\n assembly {\r\n let returndata_size := mload(returndata)\r\n revert(add(32, returndata), returndata_size)\r\n }\r\n } else {\r\n revert(errorMessage);\r\n }\r\n }\r\n }\r\n}\r\n"},"Context.sol":{"content":"// SPDX-License-Identifier: MIT\r\n\r\npragma solidity ^0.6.0;\r\n\r\n/*\r\n * @dev Provides information about the current execution context, including the\r\n * sender of the transaction and its data. While these are generally available\r\n * via msg.sender and msg.data, they should not be accessed in such a direct\r\n * manner, since when dealing with GSN meta-transactions the account sending and\r\n * paying for execution may not be the actual sender (as far as an application\r\n * is concerned).\r\n *\r\n * This contract is only required for intermediate, library-like contracts.\r\n */\r\nabstract contract Context {\r\n function _msgSender() internal view virtual returns (address payable) {\r\n return msg.sender;\r\n }\r\n\r\n function _msgData() internal view virtual returns (bytes memory) {\r\n this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691\r\n return msg.data;\r\n }\r\n}\r\n"},"EnumerableMap.sol":{"content":"// SPDX-License-Identifier: MIT\r\n\r\npragma solidity ^0.6.0;\r\n\r\n/**\r\n * @dev Library for managing an enumerable variant of Solidity\u0027s\r\n * https://solidity.readthedocs.io/en/latest/types.html#mapping-types[`mapping`]\r\n * type.\r\n *\r\n * Maps have the following properties:\r\n *\r\n * - Entries are added, removed, and checked for existence in constant time\r\n * (O(1)).\r\n * - Entries are enumerated in O(n). No guarantees are made on the ordering.\r\n *\r\n * ```\r\n * contract Example {\r\n * // Add the library methods\r\n * using EnumerableMap for EnumerableMap.UintToAddressMap;\r\n *\r\n * // Declare a set state variable\r\n * EnumerableMap.UintToAddressMap private myMap;\r\n * }\r\n * ```\r\n *\r\n * As of v3.0.0, only maps of type `uint256 -\u003e address` (`UintToAddressMap`) are\r\n * supported.\r\n */\r\nlibrary EnumerableMap {\r\n // To implement this library for multiple types with as little code\r\n // repetition as possible, we write it in terms of a generic Map type with\r\n // bytes32 keys and values.\r\n // The Map implementation uses private functions, and user-facing\r\n // implementations (such as Uint256ToAddressMap) are just wrappers around\r\n // the underlying Map.\r\n // This means that we can only create new EnumerableMaps for types that fit\r\n // in bytes32.\r\n\r\n struct MapEntry {\r\n bytes32 _key;\r\n bytes32 _value;\r\n }\r\n\r\n struct Map {\r\n // Storage of map keys and values\r\n MapEntry[] _entries;\r\n\r\n // Position of the entry defined by a key in the `entries` array, plus 1\r\n // because index 0 means a key is not in the map.\r\n mapping (bytes32 =\u003e uint256) _indexes;\r\n }\r\n\r\n /**\r\n * @dev Adds a key-value pair to a map, or updates the value for an existing\r\n * key. O(1).\r\n *\r\n * Returns true if the key was added to the map, that is if it was not\r\n * already present.\r\n */\r\n function _set(Map storage map, bytes32 key, bytes32 value) private returns (bool) {\r\n // We read and store the key\u0027s index to prevent multiple reads from the same storage slot\r\n uint256 keyIndex = map._indexes[key];\r\n\r\n if (keyIndex == 0) { // Equivalent to !contains(map, key)\r\n map._entries.push(MapEntry({ _key: key, _value: value }));\r\n // The entry is stored at length-1, but we add 1 to all indexes\r\n // and use 0 as a sentinel value\r\n map._indexes[key] = map._entries.length;\r\n return true;\r\n } else {\r\n map._entries[keyIndex - 1]._value = value;\r\n return false;\r\n }\r\n }\r\n\r\n /**\r\n * @dev Removes a key-value pair from a map. O(1).\r\n *\r\n * Returns true if the key was removed from the map, that is if it was present.\r\n */\r\n function _remove(Map storage map, bytes32 key) private returns (bool) {\r\n // We read and store the key\u0027s index to prevent multiple reads from the same storage slot\r\n uint256 keyIndex = map._indexes[key];\r\n\r\n if (keyIndex != 0) { // Equivalent to contains(map, key)\r\n // To delete a key-value pair from the _entries array in O(1), we swap the entry to delete with the last one\r\n // in the array, and then remove the last entry (sometimes called as \u0027swap and pop\u0027).\r\n // This modifies the order of the array, as noted in {at}.\r\n\r\n uint256 toDeleteIndex = keyIndex - 1;\r\n uint256 lastIndex = map._entries.length - 1;\r\n\r\n // When the entry to delete is the last one, the swap operation is unnecessary. However, since this occurs\r\n // so rarely, we still do the swap anyway to avoid the gas cost of adding an \u0027if\u0027 statement.\r\n\r\n MapEntry storage lastEntry = map._entries[lastIndex];\r\n\r\n // Move the last entry to the index where the entry to delete is\r\n map._entries[toDeleteIndex] = lastEntry;\r\n // Update the index for the moved entry\r\n map._indexes[lastEntry._key] = toDeleteIndex + 1; // All indexes are 1-based\r\n\r\n // Delete the slot where the moved entry was stored\r\n map._entries.pop();\r\n\r\n // Delete the index for the deleted slot\r\n delete map._indexes[key];\r\n\r\n return true;\r\n } else {\r\n return false;\r\n }\r\n }\r\n\r\n /**\r\n * @dev Returns true if the key is in the map. O(1).\r\n */\r\n function _contains(Map storage map, bytes32 key) private view returns (bool) {\r\n return map._indexes[key] != 0;\r\n }\r\n\r\n /**\r\n * @dev Returns the number of key-value pairs in the map. O(1).\r\n */\r\n function _length(Map storage map) private view returns (uint256) {\r\n return map._entries.length;\r\n }\r\n\r\n /**\r\n * @dev Returns the key-value pair stored at position `index` in the map. O(1).\r\n *\r\n * Note that there are no guarantees on the ordering of entries inside the\r\n * array, and it may change when more entries are added or removed.\r\n *\r\n * Requirements:\r\n *\r\n * - `index` must be strictly less than {length}.\r\n */\r\n function _at(Map storage map, uint256 index) private view returns (bytes32, bytes32) {\r\n require(map._entries.length \u003e index, \"EnumerableMap: index out of bounds\");\r\n\r\n MapEntry storage entry = map._entries[index];\r\n return (entry._key, entry._value);\r\n }\r\n\r\n /**\r\n * @dev Returns the value associated with `key`. O(1).\r\n *\r\n * Requirements:\r\n *\r\n * - `key` must be in the map.\r\n */\r\n function _get(Map storage map, bytes32 key) private view returns (bytes32) {\r\n return _get(map, key, \"EnumerableMap: nonexistent key\");\r\n }\r\n\r\n /**\r\n * @dev Same as {_get}, with a custom error message when `key` is not in the map.\r\n */\r\n function _get(Map storage map, bytes32 key, string memory errorMessage) private view returns (bytes32) {\r\n uint256 keyIndex = map._indexes[key];\r\n require(keyIndex != 0, errorMessage); // Equivalent to contains(map, key)\r\n return map._entries[keyIndex - 1]._value; // All indexes are 1-based\r\n }\r\n\r\n // UintToAddressMap\r\n\r\n struct UintToAddressMap {\r\n Map _inner;\r\n }\r\n\r\n /**\r\n * @dev Adds a key-value pair to a map, or updates the value for an existing\r\n * key. O(1).\r\n *\r\n * Returns true if the key was added to the map, that is if it was not\r\n * already present.\r\n */\r\n function set(UintToAddressMap storage map, uint256 key, address value) internal returns (bool) {\r\n return _set(map._inner, bytes32(key), bytes32(uint256(value)));\r\n }\r\n\r\n /**\r\n * @dev Removes a value from a set. O(1).\r\n *\r\n * Returns true if the key was removed from the map, that is if it was present.\r\n */\r\n function remove(UintToAddressMap storage map, uint256 key) internal returns (bool) {\r\n return _remove(map._inner, bytes32(key));\r\n }\r\n\r\n /**\r\n * @dev Returns true if the key is in the map. O(1).\r\n */\r\n function contains(UintToAddressMap storage map, uint256 key) internal view returns (bool) {\r\n return _contains(map._inner, bytes32(key));\r\n }\r\n\r\n /**\r\n * @dev Returns the number of elements in the map. O(1).\r\n */\r\n function length(UintToAddressMap storage map) internal view returns (uint256) {\r\n return _length(map._inner);\r\n }\r\n\r\n /**\r\n * @dev Returns the element stored at position `index` in the set. O(1).\r\n * Note that there are no guarantees on the ordering of values inside the\r\n * array, and it may change when more values are added or removed.\r\n *\r\n * Requirements:\r\n *\r\n * - `index` must be strictly less than {length}.\r\n */\r\n function at(UintToAddressMap storage map, uint256 index) internal view returns (uint256, address) {\r\n (bytes32 key, bytes32 value) = _at(map._inner, index);\r\n return (uint256(key), address(uint256(value)));\r\n }\r\n\r\n /**\r\n * @dev Returns the value associated with `key`. O(1).\r\n *\r\n * Requirements:\r\n *\r\n * - `key` must be in the map.\r\n */\r\n function get(UintToAddressMap storage map, uint256 key) internal view returns (address) {\r\n return address(uint256(_get(map._inner, bytes32(key))));\r\n }\r\n\r\n /**\r\n * @dev Same as {get}, with a custom error message when `key` is not in the map.\r\n */\r\n function get(UintToAddressMap storage map, uint256 key, string memory errorMessage) internal view returns (address) {\r\n return address(uint256(_get(map._inner, bytes32(key), errorMessage)));\r\n }\r\n}\r\n"},"EnumerableSet.sol":{"content":"// SPDX-License-Identifier: MIT\r\n\r\npragma solidity ^0.6.0;\r\n\r\n/**\r\n * @dev Library for managing\r\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\r\n * types.\r\n *\r\n * Sets have the following properties:\r\n *\r\n * - Elements are added, removed, and checked for existence in constant time\r\n * (O(1)).\r\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\r\n *\r\n * ```\r\n * contract Example {\r\n * // Add the library methods\r\n * using EnumerableSet for EnumerableSet.AddressSet;\r\n *\r\n * // Declare a set state variable\r\n * EnumerableSet.AddressSet private mySet;\r\n * }\r\n * ```\r\n *\r\n * As of v3.0.0, only sets of type `address` (`AddressSet`) and `uint256`\r\n * (`UintSet`) are supported.\r\n */\r\nlibrary EnumerableSet {\r\n // To implement this library for multiple types with as little code\r\n // repetition as possible, we write it in terms of a generic Set type with\r\n // bytes32 values.\r\n // The Set implementation uses private functions, and user-facing\r\n // implementations (such as AddressSet) are just wrappers around the\r\n // underlying Set.\r\n // This means that we can only create new EnumerableSets for types that fit\r\n // in bytes32.\r\n\r\n struct Set {\r\n // Storage of set values\r\n bytes32[] _values;\r\n\r\n // Position of the value in the `values` array, plus 1 because index 0\r\n // means a value is not in the set.\r\n mapping (bytes32 =\u003e uint256) _indexes;\r\n }\r\n\r\n /**\r\n * @dev Add a value to a set. O(1).\r\n *\r\n * Returns true if the value was added to the set, that is if it was not\r\n * already present.\r\n */\r\n function _add(Set storage set, bytes32 value) private returns (bool) {\r\n if (!_contains(set, value)) {\r\n set._values.push(value);\r\n // The value is stored at length-1, but we add 1 to all indexes\r\n // and use 0 as a sentinel value\r\n set._indexes[value] = set._values.length;\r\n return true;\r\n } else {\r\n return false;\r\n }\r\n }\r\n\r\n /**\r\n * @dev Removes a value from a set. O(1).\r\n *\r\n * Returns true if the value was removed from the set, that is if it was\r\n * present.\r\n */\r\n function _remove(Set storage set, bytes32 value) private returns (bool) {\r\n // We read and store the value\u0027s index to prevent multiple reads from the same storage slot\r\n uint256 valueIndex = set._indexes[value];\r\n\r\n if (valueIndex != 0) { // Equivalent to contains(set, value)\r\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\r\n // the array, and then remove the last element (sometimes called as \u0027swap and pop\u0027).\r\n // This modifies the order of the array, as noted in {at}.\r\n\r\n uint256 toDeleteIndex = valueIndex - 1;\r\n uint256 lastIndex = set._values.length - 1;\r\n\r\n // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs\r\n // so rarely, we still do the swap anyway to avoid the gas cost of adding an \u0027if\u0027 statement.\r\n\r\n bytes32 lastvalue = set._values[lastIndex];\r\n\r\n // Move the last value to the index where the value to delete is\r\n set._values[toDeleteIndex] = lastvalue;\r\n // Update the index for the moved value\r\n set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based\r\n\r\n // Delete the slot where the moved value was stored\r\n set._values.pop();\r\n\r\n // Delete the index for the deleted slot\r\n delete set._indexes[value];\r\n\r\n return true;\r\n } else {\r\n return false;\r\n }\r\n }\r\n\r\n /**\r\n * @dev Returns true if the value is in the set. O(1).\r\n */\r\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\r\n return set._indexes[value] != 0;\r\n }\r\n\r\n /**\r\n * @dev Returns the number of values on the set. O(1).\r\n */\r\n function _length(Set storage set) private view returns (uint256) {\r\n return set._values.length;\r\n }\r\n\r\n /**\r\n * @dev Returns the value stored at position `index` in the set. O(1).\r\n *\r\n * Note that there are no guarantees on the ordering of values inside the\r\n * array, and it may change when more values are added or removed.\r\n *\r\n * Requirements:\r\n *\r\n * - `index` must be strictly less than {length}.\r\n */\r\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\r\n require(set._values.length \u003e index, \"EnumerableSet: index out of bounds\");\r\n return set._values[index];\r\n }\r\n\r\n // AddressSet\r\n\r\n struct AddressSet {\r\n Set _inner;\r\n }\r\n\r\n /**\r\n * @dev Add a value to a set. O(1).\r\n *\r\n * Returns true if the value was added to the set, that is if it was not\r\n * already present.\r\n */\r\n function add(AddressSet storage set, address value) internal returns (bool) {\r\n return _add(set._inner, bytes32(uint256(value)));\r\n }\r\n\r\n /**\r\n * @dev Removes a value from a set. O(1).\r\n *\r\n * Returns true if the value was removed from the set, that is if it was\r\n * present.\r\n */\r\n function remove(AddressSet storage set, address value) internal returns (bool) {\r\n return _remove(set._inner, bytes32(uint256(value)));\r\n }\r\n\r\n /**\r\n * @dev Returns true if the value is in the set. O(1).\r\n */\r\n function contains(AddressSet storage set, address value) internal view returns (bool) {\r\n return _contains(set._inner, bytes32(uint256(value)));\r\n }\r\n\r\n /**\r\n * @dev Returns the number of values in the set. O(1).\r\n */\r\n function length(AddressSet storage set) internal view returns (uint256) {\r\n return _length(set._inner);\r\n }\r\n\r\n /**\r\n * @dev Returns the value stored at position `index` in the set. O(1).\r\n *\r\n * Note that there are no guarantees on the ordering of values inside the\r\n * array, and it may change when more values are added or removed.\r\n *\r\n * Requirements:\r\n *\r\n * - `index` must be strictly less than {length}.\r\n */\r\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\r\n return address(uint256(_at(set._inner, index)));\r\n }\r\n\r\n\r\n // UintSet\r\n\r\n struct UintSet {\r\n Set _inner;\r\n }\r\n\r\n /**\r\n * @dev Add a value to a set. O(1).\r\n *\r\n * Returns true if the value was added to the set, that is if it was not\r\n * already present.\r\n */\r\n function add(UintSet storage set, uint256 value) internal returns (bool) {\r\n return _add(set._inner, bytes32(value));\r\n }\r\n\r\n /**\r\n * @dev Removes a value from a set. O(1).\r\n *\r\n * Returns true if the value was removed from the set, that is if it was\r\n * present.\r\n */\r\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\r\n return _remove(set._inner, bytes32(value));\r\n }\r\n\r\n /**\r\n * @dev Returns true if the value is in the set. O(1).\r\n */\r\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\r\n return _contains(set._inner, bytes32(value));\r\n }\r\n\r\n /**\r\n * @dev Returns the number of values on the set. O(1).\r\n */\r\n function length(UintSet storage set) internal view returns (uint256) {\r\n return _length(set._inner);\r\n }\r\n\r\n /**\r\n * @dev Returns the value stored at position `index` in the set. O(1).\r\n *\r\n * Note that there are no guarantees on the ordering of values inside the\r\n * array, and it may change when more values are added or removed.\r\n *\r\n * Requirements:\r\n *\r\n * - `index` must be strictly less than {length}.\r\n */\r\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\r\n return uint256(_at(set._inner, index));\r\n }\r\n}\r\n"},"ERC165.sol":{"content":"// SPDX-License-Identifier: MIT\r\n\r\npragma solidity ^0.6.0;\r\n\r\nimport \"./IERC165.sol\";\r\n\r\n/**\r\n * @dev Implementation of the {IERC165} interface.\r\n *\r\n * Contracts may inherit from this and call {_registerInterface} to declare\r\n * their support of an interface.\r\n */\r\ncontract ERC165 is IERC165 {\r\n /*\r\n * bytes4(keccak256(\u0027supportsInterface(bytes4)\u0027)) == 0x01ffc9a7\r\n */\r\n bytes4 private constant _INTERFACE_ID_ERC165 = 0x01ffc9a7;\r\n\r\n /**\r\n * @dev Mapping of interface ids to whether or not it\u0027s supported.\r\n */\r\n mapping(bytes4 =\u003e bool) private _supportedInterfaces;\r\n\r\n constructor () internal {\r\n // Derived contracts need only register support for their own interfaces,\r\n // we register support for ERC165 itself here\r\n _registerInterface(_INTERFACE_ID_ERC165);\r\n }\r\n\r\n /**\r\n * @dev See {IERC165-supportsInterface}.\r\n *\r\n * Time complexity O(1), guaranteed to always use less than 30 000 gas.\r\n */\r\n function supportsInterface(bytes4 interfaceId) public view override returns (bool) {\r\n return _supportedInterfaces[interfaceId];\r\n }\r\n\r\n /**\r\n * @dev Registers the contract as an implementer of the interface defined by\r\n * `interfaceId`. Support of the actual ERC165 interface is automatic and\r\n * registering its interface id is not required.\r\n *\r\n * See {IERC165-supportsInterface}.\r\n *\r\n * Requirements:\r\n *\r\n * - `interfaceId` cannot be the ERC165 invalid interface (`0xffffffff`).\r\n */\r\n function _registerInterface(bytes4 interfaceId) internal virtual {\r\n require(interfaceId != 0xffffffff, \"ERC165: invalid interface id\");\r\n _supportedInterfaces[interfaceId] = true;\r\n }\r\n}\r\n"},"GovernanceNFT.sol":{"content":"// SPDX-License-Identifier: MIT\r\n\r\npragma solidity ^0.6.0;\r\n\r\nimport \"./Context.sol\";\r\nimport \"./IERC721.sol\";\r\nimport \"./IERC721Metadata.sol\";\r\nimport \"./IERC721Enumerable.sol\";\r\nimport \"./IERC721Receiver.sol\";\r\nimport \"./AccessControl.sol\";\r\nimport \"./ERC165.sol\";\r\nimport \"./SafeMath.sol\";\r\nimport \"./Address.sol\";\r\nimport \"./EnumerableSet.sol\";\r\nimport \"./EnumerableMap.sol\";\r\nimport \"./Strings.sol\";\r\n\r\n\r\n/**\r\n * @title ERC721 Non-Fungible Token Standard basic implementation\r\n * @dev see https://eips.ethereum.org/EIPS/eip-721\r\n */\r\ncontract GovERC721 is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable, AccessControl {\r\n using SafeMath for uint256;\r\n using Address for address;\r\n using EnumerableSet for EnumerableSet.UintSet;\r\n using EnumerableMap for EnumerableMap.UintToAddressMap;\r\n using Strings for uint256;\r\n bool public isOnline;\r\n bool public canWithdrawalFees;\r\n DAOInterface public DAO;\r\n ExchangeInterface public Exchange;\r\n uint256 public total_voting_power;\r\n uint256 constant public MAX_VOTES = 10_000_000;\r\n // Equals to `bytes4(keccak256(\"onERC721Received(address,address,uint256,bytes)\"))`\r\n // which can be also obtained as `IERC721Receiver(0).onERC721Received.selector`\r\n bytes4 private constant _ERC721_RECEIVED = 0x150b7a02;\r\n bytes32 public constant GOVERANCE = keccak256(\"GOVERANCE\");\r\n bytes32 public constant EXCHANGE = keccak256(\"EXCHANGE\");\r\n // Mapping from holder address to their (enumerable) set of owned tokens\r\n mapping (address =\u003e EnumerableSet.UintSet) private _holderTokens;\r\n\r\n // Enumerable mapping from token ids to their owners\r\n EnumerableMap.UintToAddressMap private _tokenOwners;\r\n\r\n // Mapping from token ID to approved address\r\n mapping (uint256 =\u003e address) private _tokenApprovals;\r\n\r\n\r\n \r\n // Mapping from owner to operator approvals\r\n mapping (address =\u003e mapping(address =\u003e bool)) private _operatorApprovals;\r\n\r\n // Token name\r\n string private _name;\r\n\r\n // Token symbol\r\n string private _symbol;\r\n \r\n struct Voting {\r\n \r\n uint256 id;\r\n \r\n bool hasVoted;\r\n\r\n }\r\n /// @notice Possible states that a proposal may be in\r\n enum ProposalState {\r\n Pending,\r\n Active,\r\n Canceled,\r\n Defeated,\r\n Succeeded,\r\n Executed\r\n }\r\n // Optional mapping for token URIs\r\n mapping(uint256 =\u003e string) private _tokenURIs;\r\n mapping(address =\u003e uint256) public delegate_voting_power;\r\n mapping(uint256 =\u003e uint256) public NFT_voting_power;\r\n mapping(address =\u003e bool) public vote_in_progress;\r\n mapping (address =\u003e Voting) private currently_voting;\r\n // Base URI\r\n string private _baseURI;\r\n\r\n /*\r\n * bytes4(keccak256(\u0027balanceOf(address)\u0027)) == 0x70a08231\r\n * bytes4(keccak256(\u0027ownerOf(uint256)\u0027)) == 0x6352211e\r\n * bytes4(keccak256(\u0027approve(address,uint256)\u0027)) == 0x095ea7b3\r\n * bytes4(keccak256(\u0027getApproved(uint256)\u0027)) == 0x081812fc\r\n * bytes4(keccak256(\u0027setApprovalForAll(address,bool)\u0027)) == 0xa22cb465\r\n * bytes4(keccak256(\u0027isApprovedForAll(address,address)\u0027)) == 0xe985e9c5\r\n * bytes4(keccak256(\u0027transferFrom(address,address,uint256)\u0027)) == 0x23b872dd\r\n * bytes4(keccak256(\u0027safeTransferFrom(address,address,uint256)\u0027)) == 0x42842e0e\r\n * bytes4(keccak256(\u0027safeTransferFrom(address,address,uint256,bytes)\u0027)) == 0xb88d4fde\r\n *\r\n * =\u003e 0x70a08231 ^ 0x6352211e ^ 0x095ea7b3 ^ 0x081812fc ^\r\n * 0xa22cb465 ^ 0xe985e9c ^ 0x23b872dd ^ 0x42842e0e ^ 0xb88d4fde == 0x80ac58cd\r\n */\r\n bytes4 private constant _INTERFACE_ID_ERC721 = 0x80ac58cd;\r\n\r\n /*\r\n * bytes4(keccak256(\u0027name()\u0027)) == 0x06fdde03\r\n * bytes4(keccak256(\u0027symbol()\u0027)) == 0x95d89b41\r\n * bytes4(keccak256(\u0027tokenURI(uint256)\u0027)) == 0xc87b56dd\r\n *\r\n * =\u003e 0x06fdde03 ^ 0x95d89b41 ^ 0xc87b56dd == 0x5b5e139f\r\n */\r\n bytes4 private constant _INTERFACE_ID_ERC721_METADATA = 0x5b5e139f;\r\n\r\n /*\r\n * bytes4(keccak256(\u0027totalSupply()\u0027)) == 0x18160ddd\r\n * bytes4(keccak256(\u0027tokenOfOwnerByIndex(address,uint256)\u0027)) == 0x2f745c59\r\n * bytes4(keccak256(\u0027tokenByIndex(uint256)\u0027)) == 0x4f6ccce7\r\n *\r\n * =\u003e 0x18160ddd ^ 0x2f745c59 ^ 0x4f6ccce7 == 0x780e9d63\r\n */\r\n bytes4 private constant _INTERFACE_ID_ERC721_ENUMERABLE = 0x780e9d63;\r\n\r\n /**\r\n * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.\r\n */\r\n \r\n // @notice An event emitted when voting power has been changed\r\n event VotingPowerAdded(address indexed voter, uint256 indexed tokenId, uint256 indexed votes);\r\n event VotingPowerRemoved(address indexed voter, uint256 indexed tokenId,uint256 indexed votes);\r\n \r\n \r\n constructor (string memory name, string memory symbol, string memory baseURI_, address _exchange) public {\r\n _name = name;\r\n _symbol = symbol;\r\n _setBaseURI(baseURI_);\r\n // register the supported interfaces to conform to ERC721 via ERC165\r\n _registerInterface(_INTERFACE_ID_ERC721);\r\n _registerInterface(_INTERFACE_ID_ERC721_METADATA);\r\n _registerInterface(_INTERFACE_ID_ERC721_ENUMERABLE);\r\n _setupRole(DEFAULT_ADMIN_ROLE, msg.sender);\r\n _setupRole(EXCHANGE, _exchange);\r\n isOnline = true;\r\n canWithdrawalFees = false;\r\n _mint(msg.sender, 5_000_000);\r\n \r\n }\r\n \r\n modifier isGoverance() {\r\n require(\r\n hasRole(GOVERANCE, _msgSender()) || hasRole(DEFAULT_ADMIN_ROLE, _msgSender()),\r\n \"Only permitted addresses can use this function\"\r\n );\r\n _;\r\n }\r\n modifier isExchange() {\r\n require(\r\n hasRole(EXCHANGE, _msgSender()),\r\n \"Only permitted addresses can use this function\"\r\n );\r\n _;\r\n }\r\n \r\n /**\r\n * @dev See {IERC721-balanceOf}.\r\n */\r\n function balanceOf(address owner) public view override returns (uint256) {\r\n require(owner != address(0), \"ERC721: balance query for the zero address\");\r\n\r\n return _holderTokens[owner].length();\r\n }\r\n\r\n /**\r\n * @dev See {IERC721-ownerOf}.\r\n */\r\n function ownerOf(uint256 tokenId) public view override returns (address) {\r\n return _tokenOwners.get(tokenId, \"ERC721: owner query for nonexistent token\");\r\n }\r\n\r\n /**\r\n * @dev See {IERC721Metadata-name}.\r\n */\r\n function name() public view override returns (string memory) {\r\n return _name;\r\n }\r\n\r\n /**\r\n * @dev See {IERC721Metadata-symbol}.\r\n */\r\n function symbol() public view override returns (string memory) {\r\n return _symbol;\r\n }\r\n\r\n \r\n /**\r\n * @dev See {IERC721Metadata-tokenURI}.\r\n */\r\n function tokenURI(uint256 tokenId) public view override returns (string memory) {\r\n require(_exists(tokenId), \"ERC721Metadata: URI query for nonexistent token\");\r\n\r\n string memory _tokenURI = _tokenURIs[tokenId];\r\n\r\n // If there is no base URI, return the token URI.\r\n if (bytes(_baseURI).length == 0) {\r\n return _tokenURI;\r\n }\r\n // If both are set, concatenate the baseURI and tokenURI (via abi.encodePacked).\r\n if (bytes(_tokenURI).length \u003e 0) {\r\n return string(abi.encodePacked(_baseURI, _tokenURI));\r\n }\r\n // If there is a baseURI but no tokenURI, concatenate the tokenID to the baseURI.\r\n return string(abi.encodePacked(_baseURI, tokenId.toString()));\r\n }\r\n\r\n /**\r\n * @dev Returns the base URI set via {_setBaseURI}. This will be\r\n * automatically added as a prefix in {tokenURI} to each token\u0027s URI, or\r\n * to the token ID if no specific URI is set for that token ID.\r\n */\r\n function baseURI() public view returns (string memory) {\r\n return _baseURI;\r\n }\r\n\r\n /**\r\n * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.\r\n */\r\n function tokenOfOwnerByIndex(address owner, uint256 index) public view override returns (uint256) {\r\n return _holderTokens[owner].at(index);\r\n }\r\n\r\n /**\r\n * @dev See {IERC721Enumerable-totalSupply}.\r\n */\r\n function totalSupply() public view override returns (uint256) {\r\n // _tokenOwners are indexed by tokenIds, so .length() returns the number of tokenIds\r\n return _tokenOwners.length();\r\n }\r\n\r\n /**\r\n * @dev See {IERC721Enumerable-tokenByIndex}.\r\n */\r\n function tokenByIndex(uint256 index) public view override returns (uint256) {\r\n (uint256 tokenId, ) = _tokenOwners.at(index);\r\n return tokenId;\r\n }\r\n\r\n /**\r\n * @dev See {IERC721-approve}.\r\n */\r\n function approve(address to, uint256 tokenId) public virtual override {\r\n address owner = ownerOf(tokenId);\r\n require(to != owner, \"ERC721: approval to current owner\");\r\n\r\n require(_msgSender() == owner || isApprovedForAll(owner, _msgSender()),\r\n \"ERC721: approve caller is not owner nor approved for all\"\r\n );\r\n\r\n _approve(to, tokenId);\r\n }\r\n\r\n /**\r\n * @dev See {IERC721-getApproved}.\r\n */\r\n function getApproved(uint256 tokenId) public view override returns (address) {\r\n require(_exists(tokenId), \"ERC721: approved query for nonexistent token\");\r\n\r\n return _tokenApprovals[tokenId];\r\n }\r\n\r\n /**\r\n * @dev See {IERC721-setApprovalForAll}.\r\n */\r\n function setApprovalForAll(address operator, bool approved) public virtual override {\r\n require(operator != _msgSender(), \"ERC721: approve to caller\");\r\n\r\n _operatorApprovals[_msgSender()][operator] = approved;\r\n emit ApprovalForAll(_msgSender(), operator, approved);\r\n }\r\n\r\n /**\r\n * @dev See {IERC721-isApprovedForAll}.\r\n */\r\n function isApprovedForAll(address owner, address operator) public view override returns (bool) {\r\n return _operatorApprovals[owner][operator];\r\n }\r\n\r\n /**\r\n * @dev See {IERC721-transferFrom}.\r\n */\r\n function transferFrom(address from, address to, uint256 tokenId) public virtual override {\r\n //solhint-disable-next-line max-line-length\r\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: transfer caller is not owner nor approved\");\r\n\r\n _transfer(from, to, tokenId);\r\n }\r\n\r\n /**\r\n * @dev See {IERC721-safeTransferFrom}.\r\n */\r\n function safeTransferFrom(address from, address to, uint256 tokenId) public virtual override {\r\n safeTransferFrom(from, to, tokenId, \"\");\r\n }\r\n\r\n /**\r\n * @dev See {IERC721-safeTransferFrom}.\r\n */\r\n function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory _data) public virtual override {\r\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: transfer caller is not owner nor approved\");\r\n _safeTransfer(from, to, tokenId, _data);\r\n }\r\n\r\n /**\r\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\r\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\r\n *\r\n * `_data` is additional data, it has no specified format and it is sent in call to `to`.\r\n *\r\n * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.\r\n * implement alternative mecanisms to perform token transfer, such as signature-based.\r\n *\r\n * Requirements:\r\n *\r\n * - `from` cannot be the zero address.\r\n * - `to` cannot be the zero address.\r\n * - `tokenId` token must exist and be owned by `from`.\r\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\r\n *\r\n * Emits a {Transfer} event.\r\n */\r\n function _safeTransfer(address from, address to, uint256 tokenId, bytes memory _data) internal virtual {\r\n _transfer(from, to, tokenId);\r\n require(_checkOnERC721Received(from, to, tokenId, _data), \"ERC721: transfer to non ERC721Receiver implementer\");\r\n }\r\n\r\n /**\r\n * @dev Returns whether `tokenId` exists.\r\n *\r\n * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.\r\n *\r\n * Tokens start existing when they are minted (`_mint`),\r\n * and stop existing when they are burned (`_burn`).\r\n */\r\n function _exists(uint256 tokenId) internal view returns (bool) {\r\n return _tokenOwners.contains(tokenId);\r\n }\r\n\r\n /**\r\n * @dev Returns whether `spender` is allowed to manage `tokenId`.\r\n *\r\n * Requirements:\r\n *\r\n * - `tokenId` must exist.\r\n */\r\n function _isApprovedOrOwner(address spender, uint256 tokenId) internal view returns (bool) {\r\n require(_exists(tokenId), \"ERC721: operator query for nonexistent token\");\r\n address owner = ownerOf(tokenId);\r\n return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender));\r\n }\r\n\r\n /**\r\n * @dev Safely mints `tokenId` and transfers it to `to`.\r\n *\r\n * Requirements:\r\n d*\r\n * - `tokenId` must not exist.\r\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\r\n *\r\n * Emits a {Transfer} event.\r\n */\r\n function _safeMint(address to, uint256 tokenId, uint256 voting_power) internal virtual {\r\n _safeMint(to, tokenId, \"\", voting_power);\r\n }\r\n\r\n /**\r\n * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is\r\n * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.\r\n */\r\n function _safeMint(address to, uint256 tokenId, bytes memory _data, uint256 voting_power) internal virtual {\r\n _mint(to, voting_power);\r\n require(_checkOnERC721Received(address(0), to, tokenId, _data), \"ERC721: transfer to non ERC721Receiver implementer\");\r\n }\r\n\r\n /**\r\n * @dev Mints `tokenId` and transfers it to `to`.\r\n *\r\n * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible\r\n *\r\n * Requirements:\r\n *\r\n * - `tokenId` must not exist.\r\n * - `to` cannot be the zero address.\r\n *\r\n * Emits a {Transfer} event.\r\n */\r\n function _mint(address to, uint256 voting_power) internal virtual {\r\n require(isOnline, \"The contract is paused, cannot proceed\");\r\n require(to != address(0), \"ERC721: mint to the zero address\");\r\n uint256 tokenId = totalSupply().add(1); \r\n require(!_exists(tokenId), \"ERC721: token already minted\");\r\n if(total_voting_power.add(voting_power) \u003e= MAX_VOTES){\r\n return;\r\n }\r\n if(balanceOf(to) \u003e= 1){\r\n uint256 current_token = tokenOfOwnerByIndex(to, 0);\r\n NFT_voting_power[current_token] = NFT_voting_power[current_token].add(voting_power);\r\n delegate_voting_power[to] = delegate_voting_power[to].add(voting_power);\r\n total_voting_power = total_voting_power.add(voting_power);\r\n emit VotingPowerAdded(to, current_token, voting_power);\r\n return;\r\n }\r\n _holderTokens[to].add(tokenId);\r\n NFT_voting_power[tokenId] = voting_power;\r\n delegate_voting_power[to] = delegate_voting_power[to].add(voting_power);\r\n _tokenOwners.set(tokenId, to);\r\n total_voting_power = total_voting_power.add(voting_power);\r\n emit VotingPowerAdded(to, tokenId, voting_power);\r\n emit Transfer(address(0), to, tokenId);\r\n }\r\n\r\n /**\r\n * @dev Destroys `tokenId`.\r\n * The approval is cleared when the token is burned.\r\n *\r\n * Requirements:\r\n *\r\n * - `tokenId` must exist.\r\n *\r\n * Emits a {Transfer} event.\r\n */\r\n function _burn(uint256 tokenId) internal virtual {\r\n address owner = ownerOf(tokenId);\r\n\r\n //_beforeTokenTransfer(owner, address(0), tokenId);\r\n\r\n // Clear approvals\r\n _approve(address(0), tokenId);\r\n\r\n // Clear metadata (if any)\r\n if (bytes(_tokenURIs[tokenId]).length != 0) {\r\n delete _tokenURIs[tokenId];\r\n }\r\n\r\n _holderTokens[owner].remove(tokenId);\r\n\r\n _tokenOwners.remove(tokenId);\r\n\r\n emit Transfer(owner, address(0), tokenId);\r\n }\r\n\r\n /**\r\n * @dev Transfers `tokenId` from `from` to `to`.\r\n * As opposed to {transferFrom}, this imposes no restrictions on msg.sender.\r\n *\r\n * Requirements:\r\n *\r\n * - `to` cannot be the zero address.\r\n * - `tokenId` token must be owned by `from`.\r\n *\r\n * Emits a {Transfer} event.\r\n */\r\n function _transfer(address from, address to, uint256 tokenId) internal virtual {\r\n require(ownerOf(tokenId) == from, \"ERC721: transfer of token that is not own\");\r\n require(to != address(0), \"ERC721: transfer to the zero address\");\r\n require(!isLocked(from), \"NFT votes are being used and cannot be transferred\");\r\n _beforeTokenTransfer(from, to, tokenId);\r\n\r\n // Clear approvals from the previous owner\r\n _approve(address(0), tokenId);\r\n\r\n _holderTokens[from].remove(tokenId);\r\n _holderTokens[to].add(tokenId);\r\n\r\n _tokenOwners.set(tokenId, to);\r\n\r\n emit Transfer(from, to, tokenId);\r\n }\r\n\r\n /**\r\n * @dev Sets `_tokenURI` as the tokenURI of `tokenId`.\r\n *\r\n * Requirements:\r\n *\r\n * - `tokenId` must exist.\r\n */\r\n function _setTokenURI(uint256 tokenId, string memory _tokenURI) internal virtual {\r\n require(_exists(tokenId), \"ERC721Metadata: URI set of nonexistent token\");\r\n _tokenURIs[tokenId] = _tokenURI;\r\n }\r\n\r\n /**\r\n * @dev Internal function to set the base URI for all token IDs. It is\r\n * automatically added as a prefix to the value returned in {tokenURI},\r\n * or to the token ID if {tokenURI} is empty.\r\n */\r\n function _setBaseURI(string memory baseURI_) internal virtual {\r\n _baseURI = baseURI_;\r\n }\r\n\r\n /**\r\n * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.\r\n * The call is not executed if the target address is not a contract.\r\n *\r\n * @param from address representing the previous owner of the given token ID\r\n * @param to target address that will receive the tokens\r\n * @param tokenId uint256 ID of the token to be transferred\r\n * @param _data bytes optional data to send along with the call\r\n * @return bool whether the call correctly returned the expected magic value\r\n */\r\n function _checkOnERC721Received(address from, address to, uint256 tokenId, bytes memory _data)\r\n private returns (bool)\r\n {\r\n if (!to.isContract()) {\r\n return true;\r\n }\r\n bytes memory returndata = to.functionCall(abi.encodeWithSelector(\r\n IERC721Receiver(to).onERC721Received.selector,\r\n _msgSender(),\r\n from,\r\n tokenId,\r\n _data\r\n ), \"ERC721: transfer to non ERC721Receiver implementer\");\r\n bytes4 retval = abi.decode(returndata, (bytes4));\r\n return (retval == _ERC721_RECEIVED);\r\n }\r\n\r\n function _approve(address to, uint256 tokenId) private {\r\n _tokenApprovals[tokenId] = to;\r\n emit Approval(ownerOf(tokenId), to, tokenId);\r\n }\r\n\r\n /**\r\n * @dev Hook that is called before any token transfer. This includes minting\r\n * and burning.\r\n *\r\n * Calling conditions:\r\n *\r\n * - When `from` and `to` are both non-zero, ``from``\u0027s `tokenId` will be\r\n * transferred to `to`.\r\n * - When `from` is zero, `tokenId` will be minted for `to`.\r\n * - When `to` is zero, ``from``\u0027s `tokenId` will be burned.\r\n * - `from` cannot be the zero address.\r\n * - `to` cannot be the zero address.\r\n *\r\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\r\n */\r\n function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual {\r\n delegate_voting_power[from] = delegate_voting_power[from].sub(NFT_voting_power[tokenId]);\r\n delegate_voting_power[to] = delegate_voting_power[to].add(NFT_voting_power[tokenId]);\r\n emit VotingPowerAdded(to, tokenId, NFT_voting_power[tokenId]);\r\n emit VotingPowerRemoved(from, tokenId, NFT_voting_power[tokenId]);\r\n }\r\n \r\n \r\n /**\r\n * \r\n * GOVERANCE FUNCTIONS\r\n * \r\n * */\r\n function isLocked(address _account) public returns (bool){\r\n if(vote_in_progress[_account]){\r\n if(DAO.state(currently_voting[_account].id) != ProposalState.Active){\r\n _unlockNFT(_account);\r\n return false;\r\n }else{\r\n return true;\r\n }\r\n }else{\r\n return false;\r\n }\r\n }\r\n \r\n function _lockNFT(address _voter, uint256 _proposal) isGoverance external returns (bool){\r\n vote_in_progress[_voter] = true;\r\n Voting memory newVote = Voting({\r\n id: _proposal,\r\n hasVoted: true\r\n });\r\n currently_voting[_voter] = newVote;\r\n return vote_in_progress[_voter];\r\n } \r\n\r\n function _unlockNFT(address _voter) internal returns (bool){\r\n vote_in_progress[_voter] = false;\r\n return true;\r\n }\r\n\r\n /**\r\n * @dev Returns the total votes in circulation\r\n */\r\n function totalVotingPower() public view returns (uint256) {\r\n return total_voting_power;\r\n }\r\n\r\n\r\n /**\r\n * @dev Returns an account\u0027s total voting power\r\n */\r\n function delegateVotingPower(address _address) public view returns (uint256) {\r\n return delegate_voting_power[_address];\r\n }\r\n \r\n /**\r\n * @dev Returns an NFT\u0027s total voting power\r\n */\r\n function tokenVotingPower(uint256 _tokenId) public view returns (uint256) {\r\n return NFT_voting_power[_tokenId];\r\n }\r\n /** Bonding curve\r\n *\r\n * */\r\n function calculateCurve() public view returns (uint256) {\r\n uint256 p = (\r\n (total_voting_power.div(200) * 10**18).div(MAX_VOTES.sub(total_voting_power))\r\n );\r\n if(p \u003e (1*10**18)){\r\n return 1* 10**18;\r\n }\r\n return p;\r\n }\r\n \r\n function _checkWashTrader(address _account) internal view returns (bool){\r\n return DAO.getWashTrader(_account);\r\n }\r\n \r\n function _checkApprovedContract(address _contract) internal view returns (bool){\r\n return DAO.getApprovedContracts(_contract);\r\n }\r\n function splitNFT(address _to, uint256 _tokenId, uint256 _split_amount)public returns (bool){\r\n require(isOnline, \"The contract is paused, cannot proceed\");\r\n require(ownerOf(_tokenId) == _msgSender(), \"ERC721: transfer of token that is not own\");\r\n require(_to != address(0), \"ERC721: transfer to the zero address\");\r\n require(!isLocked(_msgSender()), \"NFT votes are being used and cannot be transferred\");\r\n require(delegate_voting_power[_msgSender()] \u003e= _split_amount, \"You don\u0027t have enough votes to split\");\r\n require(NFT_voting_power[_tokenId] \u003e= _split_amount, \"Your NFT doesn\u0027t have that many votes to split\");\r\n uint256 tokenId = totalSupply().add(1); \r\n require(!_exists(tokenId), \"ERC721: token already minted\");\r\n \r\n \r\n NFT_voting_power[tokenId] = _split_amount; \r\n NFT_voting_power[_tokenId] = NFT_voting_power[_tokenId].sub(_split_amount);\r\n _tokenOwners.set(tokenId, _to);\r\n _holderTokens[_to].add(tokenId);\r\n delegate_voting_power[_msgSender()] = delegate_voting_power[_msgSender()].sub(_split_amount);\r\n delegate_voting_power[_to] = delegate_voting_power[_to].add(_split_amount);\r\n emit VotingPowerAdded(_to, tokenId, NFT_voting_power[tokenId]);\r\n emit VotingPowerRemoved(_msgSender(), tokenId, NFT_voting_power[tokenId]);\r\n emit Transfer(address(0), _to, tokenId);\r\n \r\n \r\n }\r\n \r\n function buyVotes() public payable returns (bool){\r\n require(isOnline, \"The contract is paused, cannot proceed\");\r\n uint256 p = calculateCurve();\r\n uint256 amount = msg.value.div(p);\r\n require(amount \u003e= 1, \"Not enough for one vote\");\r\n require(total_voting_power.add(amount) \u003c= MAX_VOTES, \"Not enough votes left to be purchased\");\r\n _mint(_msgSender(), amount);\r\n return true;\r\n \r\n }\r\n \r\n function earnVotes(uint256 _value, address _seller, address _buyer, address _contract) isExchange external returns (bool){\r\n require(_buyer != address(0x0) \u0026\u0026 _seller != address(0x0), \"Cannot by the 0x0 address\");\r\n require(_contract != address(0x0), \"Cannot be the 0x0 address\");\r\n require(_value \u003e= 0, \"Must have sent a value\");\r\n if(_buyer == _seller){\r\n return false;\r\n }\r\n if(_checkWashTrader(_seller) || _checkWashTrader(_buyer)){\r\n \r\n return false;\r\n }\r\n uint256 p = calculateCurve();\r\n uint256 multipler = 50;\r\n //p = p.add(p.mul(75).div(100));\r\n if(_checkApprovedContract(_contract)){\r\n multipler = 100;\r\n }\r\n uint256 votes = _value.div(p);\r\n votes = votes.mul(multipler).div(100);\r\n if(votes \u003c 2){\r\n \r\n return false;\r\n }\r\n if(total_voting_power.add(votes) \u003e= MAX_VOTES){\r\n \r\n return false;\r\n }\r\n votes = votes.div(2);\r\n _mint(_seller, votes);\r\n _mint(_buyer, votes);\r\n return true;\r\n }\r\n \r\n function setDAOContract(address _DAO) isGoverance public returns (bool){\r\n DAO = DAOInterface(_DAO);\r\n _setupRole(GOVERANCE, _DAO);\r\n return true;\r\n }\r\n function setExchangeContract(address _exchange) isGoverance public returns (bool){\r\n Exchange = ExchangeInterface(_exchange);\r\n _setupRole(EXCHANGE, _exchange);\r\n return true;\r\n }\r\n function toggleOnline() isGoverance public returns (bool){\r\n isOnline = !isOnline;\r\n return isOnline;\r\n }\r\n function toggleWithdrawFees() isGoverance public returns (bool){\r\n canWithdrawalFees = !canWithdrawalFees;\r\n return canWithdrawalFees;\r\n }\r\n function withdraw (uint256 _amount) public returns (bool){\r\n require(hasRole(DEFAULT_ADMIN_ROLE, _msgSender()), \"Not authorized\");\r\n require(_amount \u003c= address(this).balance, \"Not enough funds to withdrawal\");\r\n msg.sender.transfer(_amount);\r\n return true;\r\n }\r\n \r\n function withdrawFeesByVoter(uint256 _tokenId) public returns (bool){\r\n require(canWithdrawalFees, \"Withdrawals have not been enabled by the DAO\");\r\n require(isOnline, \"The contract is paused, cannot proceed\");\r\n require(balanceOf(msg.sender) \u003e= 1, \"You must have atleast 1 NFT to withdrawal\");\r\n require(ownerOf(_tokenId) == msg.sender, \"You do not own that token\");\r\n require(delegateVotingPower(msg.sender) \u003e= 1, \"You must have atleast 1 vote in order to withdrawal\");\r\n require(tokenVotingPower(_tokenId) \u003e= 1, \"Your NFT must hold atleast 1 vote\");\r\n require(total_voting_power.sub(NFT_voting_power[_tokenId]) \u003e= 0, \"Cannot go negative for voting power\");\r\n require(address(Exchange).balance \u003e 0, \"No fees to withdrawal\");\r\n _withdrawalFees(_tokenId);\r\n \r\n \r\n }\r\n function _withdrawalFees(uint256 _tokenId) internal returns (bool){\r\n require(tokenVotingPower(_tokenId) \u003c= delegateVotingPower(msg.sender), \"NFT has more votes than owner does\");\r\n uint256 percentageOfVotes = (tokenVotingPower(_tokenId).mul(10_000)).div(total_voting_power);\r\n require(percentageOfVotes \u003e 0, \"Percentage of votes is less than minimum to withdrawal\");\r\n uint256 ExchangeBalance = address(Exchange).balance;\r\n uint256 withdrawAmount = (ExchangeBalance.mul(percentageOfVotes)).div(10_000);\r\n require(withdrawAmount \u003e 0, \"Cannot withdrawal 0\");\r\n require(withdrawAmount \u003c= ExchangeBalance, \"Cannot withdrawal more than the balance of the contract\");\r\n \r\n delegate_voting_power[msg.sender] = delegate_voting_power[msg.sender].sub(NFT_voting_power[_tokenId]);\r\n emit VotingPowerRemoved(msg.sender, _tokenId, NFT_voting_power[_tokenId]); \r\n total_voting_power = total_voting_power.sub(NFT_voting_power[_tokenId]);\r\n NFT_voting_power[_tokenId] = 0;\r\n _burn(_tokenId);\r\n require(Exchange.WithdrawalDAO(withdrawAmount, msg.sender), \"Withdrawal failed\");\r\n return true;\r\n }\r\n \r\n}\r\ninterface DAOInterface {\r\n \r\n function state(uint256 proposalId) external view returns (GovERC721.ProposalState);\r\n function getWashTrader(address _account) external view returns (bool);\r\n function getApprovedContracts(address _contract) external view returns (bool);\r\n}\r\ninterface ExchangeInterface {\r\n \r\n function WithdrawalDAO (uint256 _amount, address payable _account) external returns (bool);\r\n}"},"IERC165.sol":{"content":"// SPDX-License-Identifier: MIT\r\n\r\npragma solidity ^0.6.0;\r\n\r\n/**\r\n * @dev Interface of the ERC165 standard, as defined in the\r\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\r\n *\r\n * Implementers can declare support of contract interfaces, which can then be\r\n * queried by others ({ERC165Checker}).\r\n *\r\n * For an implementation, see {ERC165}.\r\n */\r\ninterface IERC165 {\r\n /**\r\n * @dev Returns true if this contract implements the interface defined by\r\n * `interfaceId`. See the corresponding\r\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\r\n * to learn more about how these ids are created.\r\n *\r\n * This function call must use less than 30 000 gas.\r\n */\r\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\r\n}\r\n"},"IERC721.sol":{"content":"// SPDX-License-Identifier: MIT\r\n\r\npragma solidity ^0.6.2;\r\n\r\nimport \"./IERC165.sol\";\r\n\r\n/**\r\n * @dev Required interface of an ERC721 compliant contract.\r\n */\r\ninterface IERC721 is IERC165 {\r\n /**\r\n * @dev Emitted when `tokenId` token is transfered from `from` to `to`.\r\n */\r\n event Transfer(\r\n address indexed from,\r\n address indexed to,\r\n uint256 indexed tokenId\r\n );\r\n\r\n /**\r\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\r\n */\r\n event Approval(\r\n address indexed owner,\r\n address indexed approved,\r\n uint256 indexed tokenId\r\n );\r\n\r\n /**\r\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\r\n */\r\n event ApprovalForAll(\r\n address indexed owner,\r\n address indexed operator,\r\n bool approved\r\n );\r\n\r\n /**\r\n * @dev Returns the number of tokens in ``owner``\u0027s account.\r\n */\r\n function balanceOf(address owner) external view returns (uint256 balance);\r\n\r\n /**\r\n * @dev Returns the owner of the `tokenId` token.\r\n *\r\n * Requirements:\r\n *\r\n * - `tokenId` must exist.\r\n */\r\n function ownerOf(uint256 tokenId) external view returns (address owner);\r\n\r\n /**\r\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\r\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\r\n *\r\n * Requirements:\r\n *\r\n * - `from` cannot be the zero address.\r\n * - `to` cannot be the zero address.\r\n * - `tokenId` token must exist and be owned by `from`.\r\n * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.\r\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\r\n *\r\n * Emits a {Transfer} event.\r\n */\r\n function safeTransferFrom(\r\n address from,\r\n address to,\r\n uint256 tokenId\r\n ) external;\r\n\r\n /**\r\n * @dev Transfers `tokenId` token from `from` to `to`.\r\n *\r\n * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.\r\n *\r\n * Requirements:\r\n *\r\n * - `from` cannot be the zero address.\r\n * - `to` cannot be the zero address.\r\n * - `tokenId` token must be owned by `from`.\r\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\r\n *\r\n * Emits a {Transfer} event.\r\n */\r\n function transferFrom(\r\n address from,\r\n address to,\r\n uint256 tokenId\r\n ) external;\r\n\r\n /**\r\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\r\n * The approval is cleared when the token is transferred.\r\n *\r\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\r\n *\r\n * Requirements:\r\n *\r\n * - The caller must own the token or be an approved operator.\r\n * - `tokenId` must exist.\r\n *\r\n * Emits an {Approval} event.\r\n */\r\n function approve(address to, uint256 tokenId) external;\r\n\r\n /**\r\n * @dev Returns the account approved for `tokenId` token.\r\n *\r\n * Requirements:\r\n *\r\n * - `tokenId` must exist.\r\n */\r\n function getApproved(uint256 tokenId)\r\n external\r\n view\r\n returns (address operator);\r\n\r\n /**\r\n * @dev Approve or remove `operator` as an operator for the caller.\r\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\r\n *\r\n * Requirements:\r\n *\r\n * - The `operator` cannot be the caller.\r\n *\r\n * Emits an {ApprovalForAll} event.\r\n */\r\n function setApprovalForAll(address operator, bool _approved) external;\r\n\r\n /**\r\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\r\n *\r\n * See {setApprovalForAll}\r\n */\r\n function isApprovedForAll(address owner, address operator)\r\n external\r\n view\r\n returns (bool);\r\n\r\n /**\r\n * @dev Safely transfers `tokenId` token from `from` to `to`.\r\n *\r\n * Requirements:\r\n *\r\n * - `from` cannot be the zero address.\r\n * - `to` cannot be the zero address.\r\n * - `tokenId` token must exist and be owned by `from`.\r\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\r\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\r\n *\r\n * Emits a {Transfer} event.\r\n */\r\n function safeTransferFrom(\r\n address from,\r\n address to,\r\n uint256 tokenId,\r\n bytes calldata data\r\n ) external;\r\n}\r\n"},"IERC721Enumerable.sol":{"content":"// SPDX-License-Identifier: MIT\r\n\r\npragma solidity ^0.6.2;\r\n\r\nimport \"./IERC721.sol\";\r\n\r\n/**\r\n * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension\r\n * @dev See https://eips.ethereum.org/EIPS/eip-721\r\n */\r\ninterface IERC721Enumerable is IERC721 {\r\n\r\n /**\r\n * @dev Returns the total amount of tokens stored by the contract.\r\n */\r\n function totalSupply() external view returns (uint256);\r\n\r\n /**\r\n * @dev Returns a token ID owned by `owner` at a given `index` of its token list.\r\n * Use along with {balanceOf} to enumerate all of ``owner``\u0027s tokens.\r\n */\r\n function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId);\r\n\r\n /**\r\n * @dev Returns a token ID at a given `index` of all the tokens stored by the contract.\r\n * Use along with {totalSupply} to enumerate all tokens.\r\n */\r\n function tokenByIndex(uint256 index) external view returns (uint256);\r\n}\r\n"},"IERC721Metadata.sol":{"content":"// SPDX-License-Identifier: MIT\r\n\r\npragma solidity ^0.6.2;\r\n\r\nimport \"./IERC721.sol\";\r\n\r\n/**\r\n * @title ERC-721 Non-Fungible Token Standard, optional metadata extension\r\n * @dev See https://eips.ethereum.org/EIPS/eip-721\r\n */\r\ninterface IERC721Metadata is IERC721 {\r\n\r\n /**\r\n * @dev Returns the token collection name.\r\n */\r\n function name() external view returns (string memory);\r\n\r\n /**\r\n * @dev Returns the token collection symbol.\r\n */\r\n function symbol() external view returns (string memory);\r\n\r\n /**\r\n * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\r\n */\r\n function tokenURI(uint256 tokenId) external view returns (string memory);\r\n}\r\n"},"IERC721Receiver.sol":{"content":"// SPDX-License-Identifier: MIT\r\n\r\npragma solidity ^0.6.0;\r\n\r\n/**\r\n * @title ERC721 token receiver interface\r\n * @dev Interface for any contract that wants to support safeTransfers\r\n * from ERC721 asset contracts.\r\n */\r\ninterface IERC721Receiver {\r\n /**\r\n * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\r\n * by `operator` from `from`, this function is called.\r\n *\r\n * It must return its Solidity selector to confirm the token transfer.\r\n * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\r\n *\r\n * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.\r\n */\r\n function onERC721Received(address operator, address from, uint256 tokenId, bytes calldata data)\r\n external returns (bytes4);\r\n}\r\n"},"SafeMath.sol":{"content":"// SPDX-License-Identifier: MIT\r\n\r\npragma solidity ^0.6.0;\r\n\r\n/**\r\n * @dev Wrappers over Solidity\u0027s arithmetic operations with added overflow\r\n * checks.\r\n *\r\n * Arithmetic operations in Solidity wrap on overflow. This can easily result\r\n * in bugs, because programmers usually assume that an overflow raises an\r\n * error, which is the standard behavior in high level programming languages.\r\n * `SafeMath` restores this intuition by reverting the transaction when an\r\n * operation overflows.\r\n *\r\n * Using this library instead of the unchecked operations eliminates an entire\r\n * class of bugs, so it\u0027s recommended to use it always.\r\n */\r\nlibrary SafeMath {\r\n /**\r\n * @dev Returns the addition of two unsigned integers, reverting on\r\n * overflow.\r\n *\r\n * Counterpart to Solidity\u0027s `+` operator.\r\n *\r\n * Requirements:\r\n *\r\n * - Addition cannot overflow.\r\n */\r\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\r\n uint256 c = a + b;\r\n require(c \u003e= a, \"SafeMath: addition overflow\");\r\n\r\n return c;\r\n }\r\n\r\n /**\r\n * @dev Returns the subtraction of two unsigned integers, reverting on\r\n * overflow (when the result is negative).\r\n *\r\n * Counterpart to Solidity\u0027s `-` operator.\r\n *\r\n * Requirements:\r\n *\r\n * - Subtraction cannot overflow.\r\n */\r\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\r\n return sub(a, b, \"SafeMath: subtraction overflow\");\r\n }\r\n\r\n /**\r\n * @dev Returns the subtraction of two unsigned integers, reverting with custom message on\r\n * overflow (when the result is negative).\r\n *\r\n * Counterpart to Solidity\u0027s `-` operator.\r\n *\r\n * Requirements:\r\n *\r\n * - Subtraction cannot overflow.\r\n */\r\n function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\r\n require(b \u003c= a, errorMessage);\r\n uint256 c = a - b;\r\n\r\n return c;\r\n }\r\n\r\n /**\r\n * @dev Returns the multiplication of two unsigned integers, reverting on\r\n * overflow.\r\n *\r\n * Counterpart to Solidity\u0027s `*` operator.\r\n *\r\n * Requirements:\r\n *\r\n * - Multiplication cannot overflow.\r\n */\r\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\r\n // Gas optimization: this is cheaper than requiring \u0027a\u0027 not being zero, but the\r\n // benefit is lost if \u0027b\u0027 is also tested.\r\n // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\r\n if (a == 0) {\r\n return 0;\r\n }\r\n\r\n uint256 c = a * b;\r\n require(c / a == b, \"SafeMath: multiplication overflow\");\r\n\r\n return c;\r\n }\r\n\r\n /**\r\n * @dev Returns the integer division of two unsigned integers. Reverts on\r\n * division by zero. The result is rounded towards zero.\r\n *\r\n * Counterpart to Solidity\u0027s `/` operator. Note: this function uses a\r\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\r\n * uses an invalid opcode to revert (consuming all remaining gas).\r\n *\r\n * Requirements:\r\n *\r\n * - The divisor cannot be zero.\r\n */\r\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\r\n return div(a, b, \"SafeMath: division by zero\");\r\n }\r\n\r\n /**\r\n * @dev Returns the integer division of two unsigned integers. Reverts with custom message on\r\n * division by zero. The result is rounded towards zero.\r\n *\r\n * Counterpart to Solidity\u0027s `/` operator. Note: this function uses a\r\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\r\n * uses an invalid opcode to revert (consuming all remaining gas).\r\n *\r\n * Requirements:\r\n *\r\n * - The divisor cannot be zero.\r\n */\r\n function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\r\n require(b \u003e 0, errorMessage);\r\n uint256 c = a / b;\r\n // assert(a == b * c + a % b); // There is no case in which this doesn\u0027t hold\r\n\r\n return c;\r\n }\r\n\r\n /**\r\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\r\n * Reverts when dividing by zero.\r\n *\r\n * Counterpart to Solidity\u0027s `%` operator. This function uses a `revert`\r\n * opcode (which leaves remaining gas untouched) while Solidity uses an\r\n * invalid opcode to revert (consuming all remaining gas).\r\n *\r\n * Requirements:\r\n *\r\n * - The divisor cannot be zero.\r\n */\r\n function mod(uint256 a, uint256 b) internal pure returns (uint256) {\r\n return mod(a, b, \"SafeMath: modulo by zero\");\r\n }\r\n\r\n /**\r\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\r\n * Reverts with custom message when dividing by zero.\r\n *\r\n * Counterpart to Solidity\u0027s `%` operator. This function uses a `revert`\r\n * opcode (which leaves remaining gas untouched) while Solidity uses an\r\n * invalid opcode to revert (consuming all remaining gas).\r\n *\r\n * Requirements:\r\n *\r\n * - The divisor cannot be zero.\r\n */\r\n function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\r\n require(b != 0, errorMessage);\r\n return a % b;\r\n }\r\n}\r\n"},"Strings.sol":{"content":"// SPDX-License-Identifier: MIT\r\n\r\npragma solidity ^0.6.0;\r\n\r\n/**\r\n * @dev String operations.\r\n */\r\nlibrary Strings {\r\n /**\r\n * @dev Converts a `uint256` to its ASCII `string` representation.\r\n */\r\n function toString(uint256 value) internal pure returns (string memory) {\r\n // Inspired by OraclizeAPI\u0027s implementation - MIT licence\r\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\r\n\r\n if (value == 0) {\r\n return \"0\";\r\n }\r\n uint256 temp = value;\r\n uint256 digits;\r\n while (temp != 0) {\r\n digits++;\r\n temp /= 10;\r\n }\r\n bytes memory buffer = new bytes(digits);\r\n uint256 index = digits - 1;\r\n temp = value;\r\n while (temp != 0) {\r\n buffer[index--] = byte(uint8(48 + temp % 10));\r\n temp /= 10;\r\n }\r\n return string(buffer);\r\n }\r\n}\r\n"}}
File 2 of 2: MintableGovernance
{"IERC165.sol":{"content":"// SPDX-License-Identifier: MIT\r\n\r\npragma solidity ^0.6.0;\r\n\r\n/**\r\n * @dev Interface of the ERC165 standard, as defined in the\r\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\r\n *\r\n * Implementers can declare support of contract interfaces, which can then be\r\n * queried by others ({ERC165Checker}).\r\n *\r\n * For an implementation, see {ERC165}.\r\n */\r\ninterface IERC165 {\r\n /**\r\n * @dev Returns true if this contract implements the interface defined by\r\n * `interfaceId`. See the corresponding\r\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\r\n * to learn more about how these ids are created.\r\n *\r\n * This function call must use less than 30 000 gas.\r\n */\r\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\r\n}\r\n"},"IERC721.sol":{"content":"// SPDX-License-Identifier: MIT\r\n\r\npragma solidity ^0.6.2;\r\n\r\nimport \"./IERC165.sol\";\r\n\r\n/**\r\n * @dev Required interface of an ERC721 compliant contract.\r\n */\r\ninterface IERC721 is IERC165 {\r\n /**\r\n * @dev Emitted when `tokenId` token is transfered from `from` to `to`.\r\n */\r\n event Transfer(\r\n address indexed from,\r\n address indexed to,\r\n uint256 indexed tokenId\r\n );\r\n\r\n /**\r\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\r\n */\r\n event Approval(\r\n address indexed owner,\r\n address indexed approved,\r\n uint256 indexed tokenId\r\n );\r\n\r\n /**\r\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\r\n */\r\n event ApprovalForAll(\r\n address indexed owner,\r\n address indexed operator,\r\n bool approved\r\n );\r\n\r\n /**\r\n * @dev Returns the number of tokens in ``owner``\u0027s account.\r\n */\r\n function balanceOf(address owner) external view returns (uint256 balance);\r\n\r\n /**\r\n * @dev Returns the owner of the `tokenId` token.\r\n *\r\n * Requirements:\r\n *\r\n * - `tokenId` must exist.\r\n */\r\n function ownerOf(uint256 tokenId) external view returns (address owner);\r\n\r\n /**\r\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\r\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\r\n *\r\n * Requirements:\r\n *\r\n * - `from` cannot be the zero address.\r\n * - `to` cannot be the zero address.\r\n * - `tokenId` token must exist and be owned by `from`.\r\n * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.\r\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\r\n *\r\n * Emits a {Transfer} event.\r\n */\r\n function safeTransferFrom(\r\n address from,\r\n address to,\r\n uint256 tokenId\r\n ) external;\r\n\r\n /**\r\n * @dev Transfers `tokenId` token from `from` to `to`.\r\n *\r\n * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.\r\n *\r\n * Requirements:\r\n *\r\n * - `from` cannot be the zero address.\r\n * - `to` cannot be the zero address.\r\n * - `tokenId` token must be owned by `from`.\r\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\r\n *\r\n * Emits a {Transfer} event.\r\n */\r\n function transferFrom(\r\n address from,\r\n address to,\r\n uint256 tokenId\r\n ) external;\r\n\r\n /**\r\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\r\n * The approval is cleared when the token is transferred.\r\n *\r\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\r\n *\r\n * Requirements:\r\n *\r\n * - The caller must own the token or be an approved operator.\r\n * - `tokenId` must exist.\r\n *\r\n * Emits an {Approval} event.\r\n */\r\n function approve(address to, uint256 tokenId) external;\r\n\r\n /**\r\n * @dev Returns the account approved for `tokenId` token.\r\n *\r\n * Requirements:\r\n *\r\n * - `tokenId` must exist.\r\n */\r\n function getApproved(uint256 tokenId)\r\n external\r\n view\r\n returns (address operator);\r\n\r\n /**\r\n * @dev Approve or remove `operator` as an operator for the caller.\r\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\r\n *\r\n * Requirements:\r\n *\r\n * - The `operator` cannot be the caller.\r\n *\r\n * Emits an {ApprovalForAll} event.\r\n */\r\n function setApprovalForAll(address operator, bool _approved) external;\r\n\r\n /**\r\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\r\n *\r\n * See {setApprovalForAll}\r\n */\r\n function isApprovedForAll(address owner, address operator)\r\n external\r\n view\r\n returns (bool);\r\n\r\n /**\r\n * @dev Safely transfers `tokenId` token from `from` to `to`.\r\n *\r\n * Requirements:\r\n *\r\n * - `from` cannot be the zero address.\r\n * - `to` cannot be the zero address.\r\n * - `tokenId` token must exist and be owned by `from`.\r\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\r\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\r\n *\r\n * Emits a {Transfer} event.\r\n */\r\n function safeTransferFrom(\r\n address from,\r\n address to,\r\n uint256 tokenId,\r\n bytes calldata data\r\n ) external;\r\n}\r\n"},"IERC721Enumerable.sol":{"content":"// SPDX-License-Identifier: MIT\r\n\r\npragma solidity ^0.6.2;\r\n\r\nimport \"./IERC721.sol\";\r\n\r\n/**\r\n * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension\r\n * @dev See https://eips.ethereum.org/EIPS/eip-721\r\n */\r\ninterface IERC721Enumerable is IERC721 {\r\n\r\n /**\r\n * @dev Returns the total amount of tokens stored by the contract.\r\n */\r\n function totalSupply() external view returns (uint256);\r\n\r\n /**\r\n * @dev Returns a token ID owned by `owner` at a given `index` of its token list.\r\n * Use along with {balanceOf} to enumerate all of ``owner``\u0027s tokens.\r\n */\r\n function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId);\r\n\r\n /**\r\n * @dev Returns a token ID at a given `index` of all the tokens stored by the contract.\r\n * Use along with {totalSupply} to enumerate all tokens.\r\n */\r\n function tokenByIndex(uint256 index) external view returns (uint256);\r\n}\r\n"},"IERC721Metadata.sol":{"content":"// SPDX-License-Identifier: MIT\r\n\r\npragma solidity ^0.6.2;\r\n\r\nimport \"./IERC721.sol\";\r\n\r\n/**\r\n * @title ERC-721 Non-Fungible Token Standard, optional metadata extension\r\n * @dev See https://eips.ethereum.org/EIPS/eip-721\r\n */\r\ninterface IERC721Metadata is IERC721 {\r\n\r\n /**\r\n * @dev Returns the token collection name.\r\n */\r\n function name() external view returns (string memory);\r\n\r\n /**\r\n * @dev Returns the token collection symbol.\r\n */\r\n function symbol() external view returns (string memory);\r\n\r\n /**\r\n * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\r\n */\r\n function tokenURI(uint256 tokenId) external view returns (string memory);\r\n}\r\n"},"IERC721Receiver.sol":{"content":"// SPDX-License-Identifier: MIT\r\n\r\npragma solidity ^0.6.0;\r\n\r\n/**\r\n * @title ERC721 token receiver interface\r\n * @dev Interface for any contract that wants to support safeTransfers\r\n * from ERC721 asset contracts.\r\n */\r\ninterface IERC721Receiver {\r\n /**\r\n * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\r\n * by `operator` from `from`, this function is called.\r\n *\r\n * It must return its Solidity selector to confirm the token transfer.\r\n * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\r\n *\r\n * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.\r\n */\r\n function onERC721Received(address operator, address from, uint256 tokenId, bytes calldata data)\r\n external returns (bytes4);\r\n}\r\n"},"IGovERC721.sol":{"content":"// SPDX-License-Identifier: MIT\r\n\r\npragma solidity ^0.6.0;\r\n\r\n\r\nimport \"./IERC721.sol\";\r\nimport \"./IERC721Metadata.sol\";\r\nimport \"./IERC721Enumerable.sol\";\r\nimport \"./IERC721Receiver.sol\";\r\n\r\n/**\r\n * @title ERC721 Non-Fungible Token Standard basic implementation\r\n * @dev see https://eips.ethereum.org/EIPS/eip-721\r\n */\r\ninterface IGovERC721 is IERC721, IERC721Metadata, IERC721Enumerable{\r\n\r\n event VotingPowerAdded(address indexed voter, uint256 indexed tokenId, uint256 indexed votes);\r\n event VotingPowerRemoved(address indexed voter, uint256 indexed tokenId,uint256 indexed votes);\r\n \r\n function totalVotingPower() external view returns (uint256);\r\n\r\n function delegateVotingPower(address _address) external view returns (uint256);\r\n \r\n function tokenVotingPower(uint256 _tokenId) external view returns (uint256);\r\n \r\n function isLocked(address _account) external view returns (bool);\r\n function _lockNFT(address _voter, uint256 _proposal) external returns (bool);\r\n function calculateCurve() external view returns (uint256);\r\n function splitNFT(address _to, uint256 _tokenId, uint256 _split_amount)external returns (bool);\r\n function buyVotes() external payable returns (bool);\r\n function earnVotes(uint256 _value, address _seller, address _buyer, address _contract) external returns (uint256);\r\n function setDAOContract(address _DAO) external returns (bool);\r\n function setExchangeContract(address _exchange) external returns (bool);\r\n function toggleOnline() external returns (bool);\r\n}\r\n"},"MintableDAO.sol":{"content":"\r\npragma solidity ^0.6.0;\r\npragma experimental ABIEncoderV2;\r\nimport \"./ReentrancyGuard.sol\";\r\nimport \"./IGovERC721.sol\";\r\nimport \"./SafeMath.sol\";\r\n\r\ncontract MintableGovernance is ReentrancyGuard {\r\n using SafeMath for uint256;\r\n /// @notice The name of this contract\r\n string public constant name = \"Mintable Governor Alpha\";\r\n \r\n address public Governor;\r\n \r\n IGovERC721 public GovNFT;\r\n\r\n\r\n /// @notice The number of votes required in order for a voter to become a proposer\r\n function proposalThreshold() public pure returns (uint256) { return 10_000; } // 0.1% of voting power\r\n\r\n /// @notice The delay before voting on a proposal may take place, once proposed\r\n function votingDelay() public pure returns (uint256) { return 1 days; } // 1 day\r\n\r\n /// @notice The duration of voting on a proposal, in blocks\r\n function votingPeriod() public pure returns (uint256) { return 14 days; } // ~14 days in blocks (assuming 15s blocks)\r\n\r\n /// @notice The total number of proposals\r\n uint256 public proposalCount;\r\n \r\n\r\n\r\n struct Proposal {\r\n /// @notice Unique id for looking up a proposal\r\n uint256 id;\r\n\r\n /// @notice Creator of the proposal\r\n address proposer;\r\n\r\n /// @notice The block at which voting begins: holders must delegate their votes prior to this block\r\n uint256 startBlock;\r\n\r\n /// @notice The block at which voting ends: votes must be cast prior to this block\r\n uint256 endBlock;\r\n\r\n /// @notice Current number of votes in favor of this proposal\r\n uint256 forVotes;\r\n\r\n /// @notice Current number of votes in opposition to this proposal\r\n uint256 againstVotes;\r\n\r\n /// @notice Flag marking whether the proposal has been canceled\r\n bool canceled;\r\n\r\n /// @notice Flag marking whether the proposal has been executed\r\n bool executed;\r\n\r\n /// @notice Receipts of ballots for the entire set of voters\r\n mapping (address =\u003e Receipt) receipts;\r\n \r\n // @notice URL of the proposal\r\n string proposal_url;\r\n \r\n \r\n }\r\n\r\n /// @notice Ballot receipt record for a voter\r\n struct Receipt {\r\n /// @notice Whether or not a vote has been cast\r\n bool hasVoted;\r\n\r\n /// @notice Whether or not the voter supports the proposal\r\n bool support;\r\n\r\n /// @notice The number of votes the voter had, which were cast\r\n uint256 votes;\r\n }\r\n\r\n /// @notice Possible states that a proposal may be in\r\n enum ProposalState {\r\n Pending,\r\n Active,\r\n Canceled,\r\n Defeated,\r\n Succeeded,\r\n Executed\r\n }\r\n\r\n /// @notice The official record of all proposals ever proposed\r\n mapping (uint256 =\u003e Proposal) public proposals;\r\n\r\n /// @notice The latest proposal for each proposer\r\n mapping (address =\u003e uint256) public latestProposalIds;\r\n\r\n // Mapping of wash traders to prevent them from stealing votes\r\n mapping(address =\u003e bool) private _washTraders;\r\n \r\n // Mapping of community approved contracts \r\n mapping(address =\u003e bool) private _approvedContracts;\r\n\r\n /// @notice An event emitted when a new proposal is created\r\n event ProposalCreated(uint256 id, address proposer, uint256 startBlock, uint256 endBlock, string description);\r\n\r\n /// @notice An event emitted when a vote has been cast on a proposal\r\n event VoteCast(address voter, uint256 proposalId, bool support, uint256 votes);\r\n\r\n /// @notice An event emitted when a proposal has been canceled\r\n event ProposalCanceled(uint256 id);\r\n\r\n\r\n /// @notice An event emitted when a proposal has been executed in the Timelock\r\n event ProposalExecuted(uint256 id);\r\n \r\n modifier isGovernor() {\r\n require(msg.sender == Governor, \"GovernorAlpha::IsGovernor: Not the governor\");\r\n _;\r\n }\r\n \r\n constructor(address _govNFT) public {\r\n Governor = msg.sender;\r\n GovNFT = IGovERC721(_govNFT);\r\n }\r\n \r\n function changeGovNFT(address _contract) isGovernor external {\r\n GovNFT = IGovERC721(_contract);\r\n }\r\n\r\n function propose(string memory _url, string memory description) nonReentrant public returns (uint256) {\r\n require(GovNFT.delegateVotingPower(msg.sender) \u003e= proposalThreshold(), \"GovernorAlpha::propose: proposer votes below proposal threshold\");\r\n require(bytes(_url).length \u003e 0 \u0026\u0026 bytes(description).length \u003e 0, \"GovernorAlpha::propose: URL and description are required\");\r\n\r\n uint256 latestProposalId = latestProposalIds[msg.sender];\r\n if (latestProposalId != 0) {\r\n ProposalState proposersLatestProposalState = state(latestProposalId);\r\n require(proposersLatestProposalState != ProposalState.Active, \"GovernorAlpha::propose: one live proposal per proposer, found an already active proposal\");\r\n require(proposersLatestProposalState != ProposalState.Pending, \"GovernorAlpha::propose: one live proposal per proposer, found an already pending proposal\");\r\n }\r\n uint256 startBlock = block.timestamp.add(votingDelay());\r\n uint256 endBlock = startBlock.add(votingPeriod());\r\n proposalCount++;\r\n Proposal memory newProposal = Proposal({\r\n id: proposalCount,\r\n proposer: msg.sender,\r\n startBlock: startBlock,\r\n endBlock: endBlock,\r\n proposal_url: _url,\r\n forVotes: 0,\r\n againstVotes: 0,\r\n canceled: false,\r\n executed: false\r\n });\r\n\r\n proposals[newProposal.id] = newProposal;\r\n latestProposalIds[newProposal.proposer] = newProposal.id;\r\n\r\n emit ProposalCreated(newProposal.id, msg.sender, startBlock, endBlock, description);\r\n return newProposal.id;\r\n }\r\n\r\n /// @notice The number of votes in support of a proposal required in order for a quorum to be reached and for a vote to succeed\r\n function quorumVotes() public view returns (uint256) { return (GovNFT.totalVotingPower().mul(15)).div(100); } // 15% of voting power\r\n\r\n\r\n function execute(uint256 proposalId) isGovernor() public {\r\n require(state(proposalId) == ProposalState.Succeeded, \"GovernorAlpha::execute: proposal can only be executed if it is queued\");\r\n Proposal storage proposal = proposals[proposalId];\r\n proposal.executed = true;\r\n emit ProposalExecuted(proposalId);\r\n }\r\n\r\n function cancel(uint256 proposalId) public {\r\n ProposalState state = state(proposalId);\r\n require(state != ProposalState.Executed, \"GovernorAlpha::cancel: cannot cancel executed proposal\");\r\n require(state != ProposalState.Defeated, \"GovernorAlpha::cancel: cannot cancel defeated proposal\");\r\n require(state != ProposalState.Succeeded, \"GovernorAlpha::cancel: cannot cancel Succeeded proposal\");\r\n Proposal storage proposal = proposals[proposalId];\r\n require(msg.sender == proposal.proposer, \"GovernorAlpha::cancel: Only the proposer can cancel the vote\");\r\n proposal.canceled = true;\r\n emit ProposalCanceled(proposalId);\r\n }\r\n\r\n \r\n\r\n function getReceipt(uint256 proposalId, address voter) public view returns (Receipt memory) {\r\n return proposals[proposalId].receipts[voter];\r\n }\r\n\r\n function state(uint256 proposalId) public view returns (ProposalState) {\r\n require(proposalCount \u003e= proposalId \u0026\u0026 proposalId \u003e 0, \"GovernorAlpha::state: invalid proposal id\");\r\n Proposal storage proposal = proposals[proposalId];\r\n if (proposal.canceled) {\r\n return ProposalState.Canceled;\r\n } else if (block.timestamp \u003c= proposal.startBlock) {\r\n return ProposalState.Pending;\r\n } else if (block.timestamp \u003c= proposal.endBlock) {\r\n return ProposalState.Active;\r\n } else if (proposal.forVotes \u003c= proposal.againstVotes || proposal.forVotes \u003c quorumVotes()) {\r\n return ProposalState.Defeated;\r\n } else if (proposal.executed) {\r\n return ProposalState.Executed;\r\n } else if (proposal.forVotes \u003e proposal.againstVotes \u0026\u0026 proposal.forVotes \u003e quorumVotes()) {\r\n return ProposalState.Succeeded;\r\n }\r\n }\r\n\r\n function castVote(uint256 proposalId, bool support) public {\r\n return _castVote(msg.sender, proposalId, support);\r\n }\r\n\r\n\r\n function _castVote(address voter, uint256 proposalId, bool support) nonReentrant internal {\r\n require(state(proposalId) == ProposalState.Active, \"GovernorAlpha::_castVote: voting is closed\");\r\n Proposal storage proposal = proposals[proposalId];\r\n Receipt storage receipt = proposal.receipts[voter];\r\n require(receipt.hasVoted == false, \"GovernorAlpha::_castVote: voter already voted\");\r\n uint256 votes = GovNFT.delegateVotingPower(voter);\r\n if (support) {\r\n proposal.forVotes = proposal.forVotes.add(votes);\r\n } else {\r\n proposal.againstVotes = proposal.againstVotes.add(votes);\r\n }\r\n receipt.hasVoted = true;\r\n receipt.support = support;\r\n receipt.votes = votes;\r\n GovNFT._lockNFT(voter, proposalId);\r\n emit VoteCast(voter, proposalId, support, votes);\r\n }\r\n\r\n function getWashTrader(address _account) external view returns (bool){\r\n return _washTraders[_account];\r\n }\r\n function getApprovedContracts(address _contract) external view returns (bool){\r\n return _approvedContracts[_contract];\r\n }\r\n function addWashTrader(address _account, bool _value) external isGovernor returns (bool){\r\n _washTraders[_account] = _value;\r\n return _value;\r\n }\r\n\r\n function addApprovedContracts(address _NFT, bool _value) external isGovernor returns (bool){\r\n _approvedContracts[_NFT] = _value;\r\n return _value;\r\n }\r\n\r\n\r\n}\r\n \r\n \r\n"},"ReentrancyGuard.sol":{"content":"// SPDX-License-Identifier: MIT\r\n\r\npragma solidity ^0.6.0;\r\n\r\n/**\r\n * @dev Contract module that helps prevent reentrant calls to a function.\r\n *\r\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\r\n * available, which can be applied to functions to make sure there are no nested\r\n * (reentrant) calls to them.\r\n *\r\n * Note that because there is a single `nonReentrant` guard, functions marked as\r\n * `nonReentrant` may not call one another. This can be worked around by making\r\n * those functions `private`, and then adding `external` `nonReentrant` entry\r\n * points to them.\r\n *\r\n * TIP: If you would like to learn more about reentrancy and alternative ways\r\n * to protect against it, check out our blog post\r\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\r\n */\r\ncontract ReentrancyGuard {\r\n // Booleans are more expensive than uint256 or any type that takes up a full\r\n // word because each write operation emits an extra SLOAD to first read the\r\n // slot\u0027s contents, replace the bits taken up by the boolean, and then write\r\n // back. This is the compiler\u0027s defense against contract upgrades and\r\n // pointer aliasing, and it cannot be disabled.\r\n\r\n // The values being non-zero value makes deployment a bit more expensive,\r\n // but in exchange the refund on every call to nonReentrant will be lower in\r\n // amount. Since refunds are capped to a percentage of the total\r\n // transaction\u0027s gas, it is best to keep them low in cases like this one, to\r\n // increase the likelihood of the full refund coming into effect.\r\n uint256 private constant _NOT_ENTERED = 1;\r\n uint256 private constant _ENTERED = 2;\r\n\r\n uint256 private _status;\r\n\r\n constructor () internal {\r\n _status = _NOT_ENTERED;\r\n }\r\n\r\n /**\r\n * @dev Prevents a contract from calling itself, directly or indirectly.\r\n * Calling a `nonReentrant` function from another `nonReentrant`\r\n * function is not supported. It is possible to prevent this from happening\r\n * by making the `nonReentrant` function external, and make it call a\r\n * `private` function that does the actual work.\r\n */\r\n modifier nonReentrant() {\r\n // On the first call to nonReentrant, _notEntered will be true\r\n require(_status != _ENTERED, \"ReentrancyGuard: reentrant call\");\r\n\r\n // Any calls to nonReentrant after this point will fail\r\n _status = _ENTERED;\r\n\r\n _;\r\n\r\n // By storing the original value once again, a refund is triggered (see\r\n // https://eips.ethereum.org/EIPS/eip-2200)\r\n _status = _NOT_ENTERED;\r\n }\r\n}"},"SafeMath.sol":{"content":"// SPDX-License-Identifier: MIT\r\n\r\npragma solidity ^0.6.0;\r\n\r\n/**\r\n * @dev Wrappers over Solidity\u0027s arithmetic operations with added overflow\r\n * checks.\r\n *\r\n * Arithmetic operations in Solidity wrap on overflow. This can easily result\r\n * in bugs, because programmers usually assume that an overflow raises an\r\n * error, which is the standard behavior in high level programming languages.\r\n * `SafeMath` restores this intuition by reverting the transaction when an\r\n * operation overflows.\r\n *\r\n * Using this library instead of the unchecked operations eliminates an entire\r\n * class of bugs, so it\u0027s recommended to use it always.\r\n */\r\nlibrary SafeMath {\r\n /**\r\n * @dev Returns the addition of two unsigned integers, reverting on\r\n * overflow.\r\n *\r\n * Counterpart to Solidity\u0027s `+` operator.\r\n *\r\n * Requirements:\r\n *\r\n * - Addition cannot overflow.\r\n */\r\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\r\n uint256 c = a + b;\r\n require(c \u003e= a, \"SafeMath: addition overflow\");\r\n\r\n return c;\r\n }\r\n\r\n /**\r\n * @dev Returns the subtraction of two unsigned integers, reverting on\r\n * overflow (when the result is negative).\r\n *\r\n * Counterpart to Solidity\u0027s `-` operator.\r\n *\r\n * Requirements:\r\n *\r\n * - Subtraction cannot overflow.\r\n */\r\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\r\n return sub(a, b, \"SafeMath: subtraction overflow\");\r\n }\r\n\r\n /**\r\n * @dev Returns the subtraction of two unsigned integers, reverting with custom message on\r\n * overflow (when the result is negative).\r\n *\r\n * Counterpart to Solidity\u0027s `-` operator.\r\n *\r\n * Requirements:\r\n *\r\n * - Subtraction cannot overflow.\r\n */\r\n function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\r\n require(b \u003c= a, errorMessage);\r\n uint256 c = a - b;\r\n\r\n return c;\r\n }\r\n\r\n /**\r\n * @dev Returns the multiplication of two unsigned integers, reverting on\r\n * overflow.\r\n *\r\n * Counterpart to Solidity\u0027s `*` operator.\r\n *\r\n * Requirements:\r\n *\r\n * - Multiplication cannot overflow.\r\n */\r\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\r\n // Gas optimization: this is cheaper than requiring \u0027a\u0027 not being zero, but the\r\n // benefit is lost if \u0027b\u0027 is also tested.\r\n // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\r\n if (a == 0) {\r\n return 0;\r\n }\r\n\r\n uint256 c = a * b;\r\n require(c / a == b, \"SafeMath: multiplication overflow\");\r\n\r\n return c;\r\n }\r\n\r\n /**\r\n * @dev Returns the integer division of two unsigned integers. Reverts on\r\n * division by zero. The result is rounded towards zero.\r\n *\r\n * Counterpart to Solidity\u0027s `/` operator. Note: this function uses a\r\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\r\n * uses an invalid opcode to revert (consuming all remaining gas).\r\n *\r\n * Requirements:\r\n *\r\n * - The divisor cannot be zero.\r\n */\r\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\r\n return div(a, b, \"SafeMath: division by zero\");\r\n }\r\n\r\n /**\r\n * @dev Returns the integer division of two unsigned integers. Reverts with custom message on\r\n * division by zero. The result is rounded towards zero.\r\n *\r\n * Counterpart to Solidity\u0027s `/` operator. Note: this function uses a\r\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\r\n * uses an invalid opcode to revert (consuming all remaining gas).\r\n *\r\n * Requirements:\r\n *\r\n * - The divisor cannot be zero.\r\n */\r\n function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\r\n require(b \u003e 0, errorMessage);\r\n uint256 c = a / b;\r\n // assert(a == b * c + a % b); // There is no case in which this doesn\u0027t hold\r\n\r\n return c;\r\n }\r\n\r\n /**\r\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\r\n * Reverts when dividing by zero.\r\n *\r\n * Counterpart to Solidity\u0027s `%` operator. This function uses a `revert`\r\n * opcode (which leaves remaining gas untouched) while Solidity uses an\r\n * invalid opcode to revert (consuming all remaining gas).\r\n *\r\n * Requirements:\r\n *\r\n * - The divisor cannot be zero.\r\n */\r\n function mod(uint256 a, uint256 b) internal pure returns (uint256) {\r\n return mod(a, b, \"SafeMath: modulo by zero\");\r\n }\r\n\r\n /**\r\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\r\n * Reverts with custom message when dividing by zero.\r\n *\r\n * Counterpart to Solidity\u0027s `%` operator. This function uses a `revert`\r\n * opcode (which leaves remaining gas untouched) while Solidity uses an\r\n * invalid opcode to revert (consuming all remaining gas).\r\n *\r\n * Requirements:\r\n *\r\n * - The divisor cannot be zero.\r\n */\r\n function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\r\n require(b != 0, errorMessage);\r\n return a % b;\r\n }\r\n}\r\n"}}