Address Contract Verified
Address
0xF184a6Cd470Cac2CF5cD4fBa34e20D482D6A6062
Balance
0 ETH
Nonce
1
Code Size
3995 bytes
Creator
0xeC42Db8A...4042 at tx 0xe9c7fdc1...3605ea
Indexed Transactions
0
Contract Bytecode
3995 bytes
0x608060405234801561000f575f5ffd5b5060043610610111575f3560e01c8063a217fddf1161009e578063caa6fea41161006e578063caa6fea414610237578063d4b839921461024b578063d547741f1461025e578063dcf7bb5c14610271578063f82ec70b14610284575f5ffd5b8063a217fddf14610202578063b9f3163b14610209578063be62b15514610211578063ca15c87314610224575f5ffd5b80636833f60d116100e45780636833f60d146101955780637a9ad0191461019d5780637d4f7fc9146101b15780639010d07c146101c457806391d14854146101ef575f5ffd5b806301ffc9a714610115578063248a9ca31461013d5780632f2ff15d1461016d57806336568abe14610182575b5f5ffd5b610128610123366004610ce0565b610297565b60405190151581526020015b60405180910390f35b61015f61014b366004610cf9565b5f9081526020819052604090206001015490565b604051908152602001610134565b61018061017b366004610d24565b6102c1565b005b610180610190366004610d24565b6102ea565b61018061036d565b61015f5f516020610f465f395f51905f5281565b6101806101bf366004610d52565b6104bb565b6101d76101d2366004610d6d565b6104dc565b6040516001600160a01b039091168152602001610134565b6101286101fd366004610d24565b6104fa565b61015f5f81565b610180610522565b61018061021f366004610d8d565b61068c565b61015f610232366004610cf9565b610713565b60025461012890600160a01b900460ff1681565b6002546101d7906001600160a01b031681565b61018061026c366004610d24565b610729565b61018061027f366004610d52565b61074d565b610180610292366004610d52565b610760565b5f6001600160e01b03198216635a05180f60e01b14806102bb57506102bb82610781565b92915050565b5f828152602081905260409020600101546102db816107b5565b6102e583836107c2565b505050565b6001600160a01b038116331461035f5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084015b60405180910390fd5b61036982826107e3565b5050565b5f516020610f465f395f51905f52610384816107b5565b60025f9054906101000a90046001600160a01b03166001600160a01b0316635c975abb6040518163ffffffff1660e01b81526004016020604051808303815f875af11580156103d5573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906103f99190610dbc565b15610417576040516310067f7560e11b815260040160405180910390fd5b6002805460ff60a01b198116600160a01b1790915560408051638456cb5960e01b815290516001600160a01b0390921691638456cb59916004808201925f9290919082900301818387803b15801561046d575f5ffd5b505af115801561047f573d5f5f3e3d5ffd5b50506040513381527fb8fad2fa0ed7a383e747c309ef2c4391d7b65592a48893e57ccc1fab70791456925060200190505b60405180910390a150565b5f6104c5816107b5565b6103695f516020610f465f395f51905f52836107c2565b5f8281526001602052604081206104f39083610804565b9392505050565b5f918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b5f516020610f465f395f51905f52610539816107b5565b600254600160a01b900460ff1661056357604051631b2fd53f60e31b815260040160405180910390fd5b60025f9054906101000a90046001600160a01b03166001600160a01b0316635c975abb6040518163ffffffff1660e01b81526004016020604051808303815f875af11580156105b4573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906105d89190610dbc565b6105f557604051631e87b57b60e31b815260040160405180910390fd5b6002805460ff60a01b19811690915560408051631fa5d41d60e11b815290516001600160a01b0390921691633f4ba83a916004808201925f9290919082900301818387803b158015610645575f5ffd5b505af1158015610657573d5f5f3e3d5ffd5b50506040513381527ff5cbf596165cc457b2cd92e8d8450827ee314968160a5696402d75766fc52caf925060200190506104b0565b5f516020610f465f395f51905f526106a3816107b5565b600254604051630e89851160e01b81526001600160e01b03198516600482015260ff841660248201526001600160a01b0390911690630e898511906044015f604051808303815f87803b1580156106f8575f5ffd5b505af115801561070a573d5f5f3e3d5ffd5b50505050505050565b5f8181526001602052604081206102bb9061080f565b5f82815260208190526040902060010154610743816107b5565b6102e583836107e3565b5f610757816107b5565b61036982610818565b5f61076a816107b5565b6103695f516020610f465f395f51905f52836107e3565b5f6001600160e01b03198216637965db0b60e01b14806102bb57506301ffc9a760e01b6001600160e01b03198316146102bb565b6107bf8133610866565b50565b6107cc82826108ca565b5f8281526001602052604090206102e5908261094d565b6107ed8282610961565b5f8281526001602052604090206102e590826109c5565b5f6104f383836109d9565b5f6102bb825490565b600280546001600160a01b0319166001600160a01b0383169081179091556040519081527f7f8cffd58ac96898bdd25ab64868bd933141d15ad1cd4a0df228fd3fcba2a26d906020016104b0565b61087082826104fa565b61036957610888816001600160a01b031660146109ff565b6108938360206109ff565b6040516020016108a4929190610dfd565b60408051601f198184030181529082905262461bcd60e51b825261035691600401610e71565b6108d482826104fa565b610369575f828152602081815260408083206001600160a01b03851684529091529020805460ff191660011790556109093390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b5f6104f3836001600160a01b038416610b95565b61096b82826104fa565b15610369575f828152602081815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b5f6104f3836001600160a01b038416610be1565b5f825f0182815481106109ee576109ee610ea3565b905f5260205f200154905092915050565b60605f610a0d836002610ecb565b610a18906002610ee2565b67ffffffffffffffff811115610a3057610a30610ef5565b6040519080825280601f01601f191660200182016040528015610a5a576020820181803683370190505b509050600360fc1b815f81518110610a7457610a74610ea3565b60200101906001600160f81b03191690815f1a905350600f60fb1b81600181518110610aa257610aa2610ea3565b60200101906001600160f81b03191690815f1a9053505f610ac4846002610ecb565b610acf906001610ee2565b90505b6001811115610b46576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110610b0357610b03610ea3565b1a60f81b828281518110610b1957610b19610ea3565b60200101906001600160f81b03191690815f1a90535060049490941c93610b3f81610f09565b9050610ad2565b5083156104f35760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610356565b5f818152600183016020526040812054610bda57508154600181810184555f8481526020808220909301849055845484825282860190935260409020919091556102bb565b505f6102bb565b5f8181526001830160205260408120548015610cbb575f610c03600183610f1e565b85549091505f90610c1690600190610f1e565b9050818114610c75575f865f018281548110610c3457610c34610ea3565b905f5260205f200154905080875f018481548110610c5457610c54610ea3565b5f918252602080832090910192909255918252600188019052604090208390555b8554869080610c8657610c86610f31565b600190038181905f5260205f20015f90559055856001015f8681526020019081526020015f205f9055600193505050506102bb565b5f9150506102bb565b80356001600160e01b031981168114610cdb575f5ffd5b919050565b5f60208284031215610cf0575f5ffd5b6104f382610cc4565b5f60208284031215610d09575f5ffd5b5035919050565b6001600160a01b03811681146107bf575f5ffd5b5f5f60408385031215610d35575f5ffd5b823591506020830135610d4781610d10565b809150509250929050565b5f60208284031215610d62575f5ffd5b81356104f381610d10565b5f5f60408385031215610d7e575f5ffd5b50508035926020909101359150565b5f5f60408385031215610d9e575f5ffd5b610da783610cc4565b9150602083013560ff81168114610d47575f5ffd5b5f60208284031215610dcc575f5ffd5b815180151581146104f3575f5ffd5b5f5b83811015610df5578181015183820152602001610ddd565b50505f910152565b7f416363657373436f6e74726f6c3a206163636f756e742000000000000000000081525f8351610e34816017850160208801610ddb565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351610e65816028840160208801610ddb565b01602801949350505050565b602081525f8251806020840152610e8f816040850160208701610ddb565b601f01601f19169190910160400192915050565b634e487b7160e01b5f52603260045260245ffd5b634e487b7160e01b5f52601160045260245ffd5b80820281158282048414176102bb576102bb610eb7565b808201808211156102bb576102bb610eb7565b634e487b7160e01b5f52604160045260245ffd5b5f81610f1757610f17610eb7565b505f190190565b818103818111156102bb576102bb610eb7565b634e487b7160e01b5f52603160045260245ffdfe5bea60102f2a7acc9e82b1af0e3bd4069661102bb5dd143a6051cd1980dded1ca26469706673582212200a10a09c63ca148a8f48e86e1610526d2da1603544853928afc2dca64647de3d64736f6c634300081b0033
Verified Source Code Full Match
Compiler: v0.8.27+commit.40a35a09
EVM: shanghai
Optimization: Yes (200 runs)
AccessControl.sol 247 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/AccessControl.sol)
pragma solidity ^0.8.0;
import "./IAccessControl.sol";
import "../utils/Context.sol";
import "../utils/Strings.sol";
import "../utils/introspection/ERC165.sol";
/**
* @dev Contract module that allows children to implement role-based access
* control mechanisms. This is a lightweight version that doesn't allow enumerating role
* members except through off-chain means by accessing the contract event logs. Some
* applications may benefit from on-chain enumerability, for those cases see
* {AccessControlEnumerable}.
*
* Roles are referred to by their `bytes32` identifier. These should be exposed
* in the external API and be unique. The best way to achieve this is by
* using `public constant` hash digests:
*
* ```
* bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
* ```
*
* Roles can be used to represent a set of permissions. To restrict access to a
* function call, use {hasRole}:
*
* ```
* function foo() public {
* require(hasRole(MY_ROLE, msg.sender));
* ...
* }
* ```
*
* Roles can be granted and revoked dynamically via the {grantRole} and
* {revokeRole} functions. Each role has an associated admin role, and only
* accounts that have a role's admin role can call {grantRole} and {revokeRole}.
*
* By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
* that only accounts with this role will be able to grant or revoke other
* roles. More complex role relationships can be created by using
* {_setRoleAdmin}.
*
* WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
* grant and revoke this role. Extra precautions should be taken to secure
* accounts that have been granted it.
*/
abstract contract AccessControl is Context, IAccessControl, ERC165 {
struct RoleData {
mapping(address => bool) members;
bytes32 adminRole;
}
mapping(bytes32 => RoleData) private _roles;
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
/**
* @dev Modifier that checks that an account has a specific role. Reverts
* with a standardized message including the required role.
*
* The format of the revert reason is given by the following regular expression:
*
* /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
*
* _Available since v4.1._
*/
modifier onlyRole(bytes32 role) {
_checkRole(role);
_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) public view virtual override returns (bool) {
return _roles[role].members[account];
}
/**
* @dev Revert with a standard message if `_msgSender()` is missing `role`.
* Overriding this function changes the behavior of the {onlyRole} modifier.
*
* Format of the revert message is described in {_checkRole}.
*
* _Available since v4.6._
*/
function _checkRole(bytes32 role) internal view virtual {
_checkRole(role, _msgSender());
}
/**
* @dev Revert with a standard message if `account` is missing `role`.
*
* The format of the revert reason is given by the following regular expression:
*
* /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
*/
function _checkRole(bytes32 role, address account) internal view virtual {
if (!hasRole(role, account)) {
revert(
string(
abi.encodePacked(
"AccessControl: account ",
Strings.toHexString(uint160(account), 20),
" is missing role ",
Strings.toHexString(uint256(role), 32)
)
)
);
}
}
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {
return _roles[role].adminRole;
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleGranted} event.
*/
function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
_grantRole(role, account);
}
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleRevoked} event.
*/
function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
_revokeRole(role, account);
}
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been revoked `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `account`.
*
* May emit a {RoleRevoked} event.
*/
function renounceRole(bytes32 role, address account) public virtual override {
require(account == _msgSender(), "AccessControl: can only renounce roles for self");
_revokeRole(role, account);
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event. Note that unlike {grantRole}, this function doesn't perform any
* checks on the calling account.
*
* May emit a {RoleGranted} event.
*
* [WARNING]
* ====
* This function should only be called from the constructor when setting
* up the initial roles for the system.
*
* Using this function in any other way is effectively circumventing the admin
* system imposed by {AccessControl}.
* ====
*
* NOTE: This function is deprecated in favor of {_grantRole}.
*/
function _setupRole(bytes32 role, address account) internal virtual {
_grantRole(role, account);
}
/**
* @dev Sets `adminRole` as ``role``'s admin role.
*
* Emits a {RoleAdminChanged} event.
*/
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
bytes32 previousAdminRole = getRoleAdmin(role);
_roles[role].adminRole = adminRole;
emit RoleAdminChanged(role, previousAdminRole, adminRole);
}
/**
* @dev Grants `role` to `account`.
*
* Internal function without access restriction.
*
* May emit a {RoleGranted} event.
*/
function _grantRole(bytes32 role, address account) internal virtual {
if (!hasRole(role, account)) {
_roles[role].members[account] = true;
emit RoleGranted(role, account, _msgSender());
}
}
/**
* @dev Revokes `role` from `account`.
*
* Internal function without access restriction.
*
* May emit a {RoleRevoked} event.
*/
function _revokeRole(bytes32 role, address account) internal virtual {
if (hasRole(role, account)) {
_roles[role].members[account] = false;
emit RoleRevoked(role, account, _msgSender());
}
}
}
AccessControlEnumerable.sol 64 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (access/AccessControlEnumerable.sol)
pragma solidity ^0.8.0;
import "./IAccessControlEnumerable.sol";
import "./AccessControl.sol";
import "../utils/structs/EnumerableSet.sol";
/**
* @dev Extension of {AccessControl} that allows enumerating the members of each role.
*/
abstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {
using EnumerableSet for EnumerableSet.AddressSet;
mapping(bytes32 => EnumerableSet.AddressSet) private _roleMembers;
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev Returns one of the accounts that have `role`. `index` must be a
* value between 0 and {getRoleMemberCount}, non-inclusive.
*
* Role bearers are not sorted in any particular way, and their ordering may
* change at any point.
*
* WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure
* you perform all queries on the same block. See the following
* https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]
* for more information.
*/
function getRoleMember(bytes32 role, uint256 index) public view virtual override returns (address) {
return _roleMembers[role].at(index);
}
/**
* @dev Returns the number of accounts that have `role`. Can be used
* together with {getRoleMember} to enumerate all bearers of a role.
*/
function getRoleMemberCount(bytes32 role) public view virtual override returns (uint256) {
return _roleMembers[role].length();
}
/**
* @dev Overload {_grantRole} to track enumerable memberships
*/
function _grantRole(bytes32 role, address account) internal virtual override {
super._grantRole(role, account);
_roleMembers[role].add(account);
}
/**
* @dev Overload {_revokeRole} to track enumerable memberships
*/
function _revokeRole(bytes32 role, address account) internal virtual override {
super._revokeRole(role, account);
_roleMembers[role].remove(account);
}
}
IAccessControl.sol 88 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)
pragma solidity ^0.8.0;
/**
* @dev External interface of AccessControl declared to support ERC165 detection.
*/
interface IAccessControl {
/**
* @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
*
* `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
* {RoleAdminChanged} not being emitted signaling this.
*
* _Available since v3.1._
*/
event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);
/**
* @dev Emitted when `account` is granted `role`.
*
* `sender` is the account that originated the contract call, an admin role
* bearer except when using {AccessControl-_setupRole}.
*/
event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Emitted when `account` is revoked `role`.
*
* `sender` is the account that originated the contract call:
* - if using `revokeRole`, it is the admin role bearer
* - if using `renounceRole`, it is the role bearer (i.e. `account`)
*/
event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) external view returns (bool);
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {AccessControl-_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) external view returns (bytes32);
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function grantRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function revokeRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been granted `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `account`.
*/
function renounceRole(bytes32 role, address account) external;
}
IAccessControlEnumerable.sol 31 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControlEnumerable.sol)
pragma solidity ^0.8.0;
import "./IAccessControl.sol";
/**
* @dev External interface of AccessControlEnumerable declared to support ERC165 detection.
*/
interface IAccessControlEnumerable is IAccessControl {
/**
* @dev Returns one of the accounts that have `role`. `index` must be a
* value between 0 and {getRoleMemberCount}, non-inclusive.
*
* Role bearers are not sorted in any particular way, and their ordering may
* change at any point.
*
* WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure
* you perform all queries on the same block. See the following
* https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]
* for more information.
*/
function getRoleMember(bytes32 role, uint256 index) external view returns (address);
/**
* @dev Returns the number of accounts that have `role`. Can be used
* together with {getRoleMember} to enumerate all bearers of a role.
*/
function getRoleMemberCount(bytes32 role) external view returns (uint256);
}
Context.sol 24 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
Strings.sol 75 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)
pragma solidity ^0.8.0;
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
uint8 private constant _ADDRESS_LENGTH = 20;
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0x00";
}
uint256 temp = value;
uint256 length = 0;
while (temp != 0) {
length++;
temp >>= 8;
}
return toHexString(value, length);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _HEX_SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
/**
* @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
*/
function toHexString(address addr) internal pure returns (string memory) {
return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
}
}
ERC165.sol 29 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)
pragma solidity ^0.8.0;
import "./IERC165.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*
* Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
*/
abstract contract ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}
IERC165.sol 25 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
EnumerableSet.sol 367 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/structs/EnumerableSet.sol)
pragma solidity ^0.8.0;
/**
* @dev Library for managing
* https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
* types.
*
* Sets have the following properties:
*
* - Elements are added, removed, and checked for existence in constant time
* (O(1)).
* - Elements are enumerated in O(n). No guarantees are made on the ordering.
*
* ```
* contract Example {
* // Add the library methods
* using EnumerableSet for EnumerableSet.AddressSet;
*
* // Declare a set state variable
* EnumerableSet.AddressSet private mySet;
* }
* ```
*
* As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
* and `uint256` (`UintSet`) are supported.
*
* [WARNING]
* ====
* Trying to delete such a structure from storage will likely result in data corruption, rendering the structure unusable.
* See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.
*
* In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an array of EnumerableSet.
* ====
*/
library EnumerableSet {
// To implement this library for multiple types with as little code
// repetition as possible, we write it in terms of a generic Set type with
// bytes32 values.
// The Set implementation uses private functions, and user-facing
// implementations (such as AddressSet) are just wrappers around the
// underlying Set.
// This means that we can only create new EnumerableSets for types that fit
// in bytes32.
struct Set {
// Storage of set values
bytes32[] _values;
// Position of the value in the `values` array, plus 1 because index 0
// means a value is not in the set.
mapping(bytes32 => uint256) _indexes;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function _add(Set storage set, bytes32 value) private returns (bool) {
if (!_contains(set, value)) {
set._values.push(value);
// The value is stored at length-1, but we add 1 to all indexes
// and use 0 as a sentinel value
set._indexes[value] = set._values.length;
return true;
} else {
return false;
}
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function _remove(Set storage set, bytes32 value) private returns (bool) {
// We read and store the value's index to prevent multiple reads from the same storage slot
uint256 valueIndex = set._indexes[value];
if (valueIndex != 0) {
// Equivalent to contains(set, value)
// To delete an element from the _values array in O(1), we swap the element to delete with the last one in
// the array, and then remove the last element (sometimes called as 'swap and pop').
// This modifies the order of the array, as noted in {at}.
uint256 toDeleteIndex = valueIndex - 1;
uint256 lastIndex = set._values.length - 1;
if (lastIndex != toDeleteIndex) {
bytes32 lastValue = set._values[lastIndex];
// Move the last value to the index where the value to delete is
set._values[toDeleteIndex] = lastValue;
// Update the index for the moved value
set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex
}
// Delete the slot where the moved value was stored
set._values.pop();
// Delete the index for the deleted slot
delete set._indexes[value];
return true;
} else {
return false;
}
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function _contains(Set storage set, bytes32 value) private view returns (bool) {
return set._indexes[value] != 0;
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function _length(Set storage set) private view returns (uint256) {
return set._values.length;
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function _at(Set storage set, uint256 index) private view returns (bytes32) {
return set._values[index];
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function _values(Set storage set) private view returns (bytes32[] memory) {
return set._values;
}
// Bytes32Set
struct Bytes32Set {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _add(set._inner, value);
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _remove(set._inner, value);
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
return _contains(set._inner, value);
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(Bytes32Set storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
return _at(set._inner, index);
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {
return _values(set._inner);
}
// AddressSet
struct AddressSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(AddressSet storage set, address value) internal returns (bool) {
return _add(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(AddressSet storage set, address value) internal returns (bool) {
return _remove(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(AddressSet storage set, address value) internal view returns (bool) {
return _contains(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(AddressSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(AddressSet storage set, uint256 index) internal view returns (address) {
return address(uint160(uint256(_at(set._inner, index))));
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(AddressSet storage set) internal view returns (address[] memory) {
bytes32[] memory store = _values(set._inner);
address[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
// UintSet
struct UintSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(UintSet storage set, uint256 value) internal returns (bool) {
return _add(set._inner, bytes32(value));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(UintSet storage set, uint256 value) internal returns (bool) {
return _remove(set._inner, bytes32(value));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(UintSet storage set, uint256 value) internal view returns (bool) {
return _contains(set._inner, bytes32(value));
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function length(UintSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(UintSet storage set, uint256 index) internal view returns (uint256) {
return uint256(_at(set._inner, index));
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(UintSet storage set) internal view returns (uint256[] memory) {
bytes32[] memory store = _values(set._inner);
uint256[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
}
IPauseTarget.sol 12 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface IPauseTarget {
function pause() external;
function unpause() external;
function paused() external returns (bool);
function restrict(bytes4 fnSig, uint8 enumBitmap) external;
}
PauseEnforcer.sol 146 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/access/AccessControlEnumerable.sol";
import "../../interfaces/IPauseTarget.sol";
contract PauseEnforcer is AccessControlEnumerable {
/**
* @dev Error thrown when the target is already on paused state.
*/
error ErrTargetIsOnPaused();
/**
* @dev Error thrown when the target is not on paused state.
*/
error ErrTargetIsNotOnPaused();
/**
* @dev Error thrown when the contract is not on emergency pause.
*/
error ErrNotOnEmergencyPause();
bytes32 public constant SENTRY_ROLE = keccak256("SENTRY_ROLE");
/// @dev The contract that can be paused or unpaused by the SENTRY_ROLE.
IPauseTarget public target;
/// @dev Indicating whether or not the target contract is paused in emergency mode.
bool public emergency;
/// @dev Emitted when the emergency pause is triggered by `account`.
event EmergencyPaused(address account);
/// @dev Emitted when the emergency unpause is triggered by `account`.
event EmergencyUnpaused(address account);
/// @dev Emitted when the target is changed.
event TargetChanged(IPauseTarget target);
modifier onEmergency() {
if (!emergency) revert ErrNotOnEmergencyPause();
_;
}
modifier targetPaused() {
if (!target.paused()) revert ErrTargetIsOnPaused();
_;
}
modifier targetNotPaused() {
if (target.paused()) revert ErrTargetIsNotOnPaused();
_;
}
constructor(IPauseTarget target_, address[] memory admins, address[] memory sentries) {
_changeTarget(target_);
for (uint256 i; i < sentries.length; ++i) {
_grantRole(SENTRY_ROLE, sentries[i]);
}
for (uint256 i; i < admins.length; ++i) {
_grantRole(DEFAULT_ADMIN_ROLE, admins[i]);
}
}
/**
* @dev Grants the SENTRY_ROLE to the specified address.
*/
function grantSentry(
address _sentry
) external onlyRole(DEFAULT_ADMIN_ROLE) {
_grantRole(SENTRY_ROLE, _sentry);
}
/**
* @dev Revokes the SENTRY_ROLE from the specified address.
*/
function revokeSentry(
address _sentry
) external onlyRole(DEFAULT_ADMIN_ROLE) {
_revokeRole(SENTRY_ROLE, _sentry);
}
/**
* @dev Triggers a pause on the target contract.
*
* Requirements:
* - Only be called by accounts with the SENTRY_ROLE,
* - The target contract is not already paused.
*/
function triggerPause() external onlyRole(SENTRY_ROLE) targetNotPaused {
emergency = true;
target.pause();
emit EmergencyPaused(msg.sender);
}
/**
* @dev Triggers an unpause on the target contract.
*
* Requirements:
* - Only be called by accounts with the SENTRY_ROLE,
* - The target contract is already paused.
* - The target contract is paused in emergency mode.
*/
function triggerUnpause() external onlyRole(SENTRY_ROLE) onEmergency targetPaused {
emergency = false;
target.unpause();
emit EmergencyUnpaused(msg.sender);
}
/**
* @dev Triggers a restrict a function with one or more standards represented by the bitmap.
*
* Requirements:
* - Only be called by accounts with the SENTRY_ROLE.
*
* @param fnSig The function signature to restrict.
* @param enumBitmap The bitmap of the standard to restrict.
*/
function triggerRestrict(bytes4 fnSig, uint8 enumBitmap) external onlyRole(SENTRY_ROLE) {
target.restrict(fnSig, enumBitmap);
}
/**
* @dev Setter for `target`.
*
* Requirements:
* - Only admin can call this method.
*/
function changeTarget(
IPauseTarget _target
) external onlyRole(DEFAULT_ADMIN_ROLE) {
_changeTarget(_target);
}
/**
* @dev Internal helper for setting value to `target`.
*/
function _changeTarget(
IPauseTarget _target
) internal {
target = _target;
emit TargetChanged(_target);
}
}
Read Contract
DEFAULT_ADMIN_ROLE 0xa217fddf → bytes32
SENTRY_ROLE 0x7a9ad019 → bytes32
emergency 0xcaa6fea4 → bool
getRoleAdmin 0x248a9ca3 → bytes32
getRoleMember 0x9010d07c → address
getRoleMemberCount 0xca15c873 → uint256
hasRole 0x91d14854 → bool
supportsInterface 0x01ffc9a7 → bool
target 0xd4b83992 → address
Write Contract 9 functions
These functions modify contract state and require a wallet transaction to execute.
changeTarget 0xdcf7bb5c
address _target
grantRole 0x2f2ff15d
bytes32 role
address account
grantSentry 0x7d4f7fc9
address _sentry
renounceRole 0x36568abe
bytes32 role
address account
revokeRole 0xd547741f
bytes32 role
address account
revokeSentry 0xf82ec70b
address _sentry
triggerPause 0x6833f60d
No parameters
triggerRestrict 0xbe62b155
bytes4 fnSig
uint8 enumBitmap
triggerUnpause 0xb9f3163b
No parameters
Recent Transactions
No transactions found for this address