Address Contract Verified
Address
0x82F1806AEab5Ecb9a485eb041d5Ed4940b123995
Balance
0 ETH
Nonce
1
Code Size
2330 bytes
Creator
0x6C15B25E...7649 at tx 0xdb697ac0...0b0a4f
Indexed Transactions
0
Contract Bytecode
2330 bytes
0x608060408181526004918236101561001657600080fd5b600092833560e01c91826301ffc9a7146105455750816302d7fd921461050a5781630ae5fb501461047e5781630e27324d146103ec578163248a9ca3146103c25781632f2ff15d1461039857816336568abe1461035257816339ba645b146102c25781634a7497081461022857816391d14854146101e2578163a217fddf146101c7578163d547741f1461018457508063d9e1063d1461015c578063e73d0e501461010a5763e77db232146100ca57600080fd5b346101065760203660031901126101065760209160ff9082906001600160a01b036100f3610598565b1681526001855220541690519015158152f35b5080fd5b50346101065760203660031901126101065760ff8160209361012a610598565b6000805160206108a583398151915282528186528282206001600160a01b039091168252855220549151911615158152f35b5034610106578160031936011261010657602090516000805160206108a58339815191528152f35b919050346101c357806003193601126101c3576101bf91356101ba60016101a96105b3565b93838752866020528620015461067b565b61082f565b5080f35b8280fd5b50503461010657816003193601126101065751908152602090f35b9050346101c357816003193601126101c3578160209360ff926102036105b3565b903582528186528282206001600160a01b039091168252855220549151911615158152f35b919050346101c35760203660031901126101c357610244610598565b9061024d6105c9565b6001600160a01b0382169283156102b4575090610287600161028c936000805160206108a58339815191528752866020528620015461067b565b6106a1565b507fef18e156bdaf775d2d2c270718ae1518c77a629d7b379aa2e092595e9dd2de128280a280f35b905163e6c4247b60e01b8152fd5b919050346101c35760203660031901126101c3576102de610598565b6102e6610643565b6001600160a01b03169182156102b457828452600160205260ff828520541615610344575081835260016020528220805460ff191690557ffb4ca6a2470de95e9f648557fae63380f22c4b760bd27b0571caf5977a30278a8280a280f35b905163c19f17a960e01b8152fd5b83833461010657806003193601126101065761036c6105b3565b90336001600160a01b0383160361038957506101bf91923561082f565b5163334bd91960e11b81528390fd5b919050346101c357806003193601126101c3576101bf91356103bd60016101a96105b3565b61072f565b9050346101c35760203660031901126101c357816020936001923581528085522001549051908152f35b919050346101c35760203660031901126101c357610408610598565b610410610643565b6001600160a01b03169182156102b457828452600160205260ff8285205416610470575081835260016020528220600160ff198254161790557f333bb19eeef0621b32888db778cc7a481a89fc1d59adb2cecb59b40ef048941e8280a280f35b905163080fc0bd60e11b8152fd5b919050346101c35760203660031901126101c35761049a610598565b906104a36105c9565b6001600160a01b0382169283156102b45750906104dd60016104e2936000805160206108a58339815191528752866020528620015461067b565b6107a8565b507fd0460be336159fd5a7b316308e85398a2351fd4798cfefa2a968778042359cf78280a280f35b505034610106578160031936011261010657602090517f811427a0fa4932aef534bba16bc34e9b7b2d7d2a79c475fca1765f6cc1faebea8152f35b8491346101c35760203660031901126101c3573563ffffffff60e01b81168091036101c35760209250637965db0b60e01b8114908115610587575b5015158152f35b6301ffc9a760e01b14905083610580565b600435906001600160a01b03821682036105ae57565b600080fd5b602435906001600160a01b03821682036105ae57565b3360009081527f26736404b38760f405429bd2430fb148ec256b69885d5bd06d7ecb8547daeec960205260409020547f811427a0fa4932aef534bba16bc34e9b7b2d7d2a79c475fca1765f6cc1faebea9060ff16156106255750565b6044906040519063e2517d3f60e01b82523360048301526024820152fd5b3360009081526000805160206108c583398151915260205260409020546000805160206108a58339815191529060ff16156106255750565b80600052600060205260406000203360005260205260ff60406000205416156106255750565b6001600160a01b031660008181526000805160206108c583398151915260205260408120549091906000805160206108a58339815191529060ff1661072a57808352826020526040832082845260205260408320600160ff198254161790557f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d339380a4600190565b505090565b9060009180835282602052604083209160018060a01b03169182845260205260ff6040842054161560001461072a57808352826020526040832082845260205260408320600160ff198254161790557f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d339380a4600190565b6001600160a01b031660008181526000805160206108c583398151915260205260408120549091906000805160206108a58339815191529060ff161561072a5780835282602052604083208284526020526040832060ff1981541690557ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b339380a4600190565b9060009180835282602052604083209160018060a01b03169182845260205260ff60408420541660001461072a5780835282602052604083208284526020526040832060ff1981541690557ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b339380a460019056fe6c4079fcac94e7142d8c209744c998efe53a188aadb7e55958f7ad3ea8a1d6521cc1b714a06a87312844cc068c3d4b37d3e95f55dbc93d124629a4fd3f5c1d60a2646970667358221220367c2ea6f21351d01052f784dd389f07a0e1f347c46c052d190aa6d663de7ec864736f6c63430008140033
Verified Source Code Full Match
Compiler: v0.8.20+commit.a1b79de6
EVM: paris
Optimization: Yes (100 runs)
AccessControl.sol 209 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)
pragma solidity ^0.8.20;
import {IAccessControl} from "./IAccessControl.sol";
import {Context} from "../utils/Context.sol";
import {ERC165} from "../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:
*
* ```solidity
* 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}:
*
* ```solidity
* 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. We recommend using {AccessControlDefaultAdminRules}
* to enforce additional security measures for this role.
*/
abstract contract AccessControl is Context, IAccessControl, ERC165 {
struct RoleData {
mapping(address account => bool) hasRole;
bytes32 adminRole;
}
mapping(bytes32 role => RoleData) private _roles;
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
/**
* @dev Modifier that checks that an account has a specific role. Reverts
* with an {AccessControlUnauthorizedAccount} error including the required role.
*/
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 returns (bool) {
return _roles[role].hasRole[account];
}
/**
* @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`
* is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.
*/
function _checkRole(bytes32 role) internal view virtual {
_checkRole(role, _msgSender());
}
/**
* @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`
* is missing `role`.
*/
function _checkRole(bytes32 role, address account) internal view virtual {
if (!hasRole(role, account)) {
revert AccessControlUnauthorizedAccount(account, role);
}
}
/**
* @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 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 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 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 `callerConfirmation`.
*
* May emit a {RoleRevoked} event.
*/
function renounceRole(bytes32 role, address callerConfirmation) public virtual {
if (callerConfirmation != _msgSender()) {
revert AccessControlBadConfirmation();
}
_revokeRole(role, callerConfirmation);
}
/**
* @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 Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.
*
* Internal function without access restriction.
*
* May emit a {RoleGranted} event.
*/
function _grantRole(bytes32 role, address account) internal virtual returns (bool) {
if (!hasRole(role, account)) {
_roles[role].hasRole[account] = true;
emit RoleGranted(role, account, _msgSender());
return true;
} else {
return false;
}
}
/**
* @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.
*
* Internal function without access restriction.
*
* May emit a {RoleRevoked} event.
*/
function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {
if (hasRole(role, account)) {
_roles[role].hasRole[account] = false;
emit RoleRevoked(role, account, _msgSender());
return true;
} else {
return false;
}
}
}
IAccessControl.sol 98 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)
pragma solidity ^0.8.20;
/**
* @dev External interface of AccessControl declared to support ERC165 detection.
*/
interface IAccessControl {
/**
* @dev The `account` is missing a role.
*/
error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);
/**
* @dev The caller of a function is not the expected one.
*
* NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.
*/
error AccessControlBadConfirmation();
/**
* @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.
*/
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 `callerConfirmation`.
*/
function renounceRole(bytes32 role, address callerConfirmation) external;
}
Context.sol 28 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
pragma solidity ^0.8.20;
/**
* @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;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}
ERC165.sol 27 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)
pragma solidity ^0.8.20;
import {IERC165} from "./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);
* }
* ```
*/
abstract contract ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}
IERC165.sol 25 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)
pragma solidity ^0.8.20;
/**
* @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);
}
IKYCRegistry.sol 11 lines
//SPDX-License-Identifier: ISC
pragma solidity 0.8.20;
interface IKYCRegistry {
// function isKYCUser(
// bytes32[] calldata proof,
// bytes32 leaf
// ) external view returns (bool);
function isKYCApproved(address user) external view returns (bool);
}
KYCRegistry.sol 110 lines
//SPDX-License-Identifier: MIT
pragma solidity 0.8.20;
import {AccessControl} from "@openzeppelin/contracts/access/AccessControl.sol";
import {IKYCRegistry} from "./interfaces/IKYCRegistry.sol";
/// @title KYC Registry Contract
/// @notice Manages KYC (Know Your Customer) approvals and providers
/// @dev Implements role-based access control for KYC management
contract KYCRegistry is AccessControl, IKYCRegistry {
/// @notice Role identifier for KYC providers
bytes32 public constant KYC_PROVIDER_ROLE = keccak256("KYC_PROVIDER_ROLE");
/// @notice Role identifier for KYC administrators
bytes32 public constant KYC_ADMIN_ROLE = keccak256("KYC_ADMIN_ROLE");
/// @notice Mapping to track KYC approval status for each address
mapping(address => bool) private _kycApproved;
/// @notice Initializes the contract with the deployer as the default admin and KYC admin
/// @dev Sets up role hierarchy where KYC_ADMIN_ROLE manages KYC_PROVIDER_ROLE
constructor(address initialAdmin_, address kycAdmin_) {
_grantRole(DEFAULT_ADMIN_ROLE, initialAdmin_);
_grantRole(KYC_ADMIN_ROLE, kycAdmin_);
_setRoleAdmin(KYC_PROVIDER_ROLE, KYC_ADMIN_ROLE);
}
/// @notice Emitted when a user's KYC status is approved
/// @param user Address of the approved user
event KYCApproved(address indexed user);
/// @notice Emitted when a user's KYC status is revoked
/// @param user Address of the user whose KYC was revoked
event KYCRevoked(address indexed user);
/// @notice Emitted when a new KYC provider is added
/// @param provider Address of the new KYC provider
event KYCProviderAdded(address indexed provider);
/// @notice Emitted when a KYC provider is removed
/// @param provider Address of the removed KYC provider
event KYCProviderRemoved(address indexed provider);
/// @notice Adds a new KYC provider
/// @dev Only callable by addresses with KYC_ADMIN_ROLE
/// @param provider Address of the new KYC provider
/// @custom:throws InvalidAddress if provider address is zero
function addKYCProvider(address provider) external onlyRole(KYC_ADMIN_ROLE) {
if (provider == address(0)) revert InvalidAddress();
grantRole(KYC_PROVIDER_ROLE, provider);
emit KYCProviderAdded(provider);
}
/// @notice Removes a KYC provider
/// @dev Only callable by addresses with KYC_ADMIN_ROLE
/// @param provider Address of the KYC provider to remove
/// @custom:throws InvalidAddress if provider address is zero
function removeKYCProvider(
address provider
) external onlyRole(KYC_ADMIN_ROLE) {
if (provider == address(0)) revert InvalidAddress();
revokeRole(KYC_PROVIDER_ROLE, provider);
emit KYCProviderRemoved(provider);
}
/// @notice Approves KYC status for a user
/// @dev Only callable by addresses with KYC_PROVIDER_ROLE
/// @param user Address of the user to approve
/// @custom:throws InvalidAddress if user address is zero
/// @custom:throws AlreadyApproved if user is already KYC approved
function approveKYC(address user) external onlyRole(KYC_PROVIDER_ROLE) {
if (user == address(0)) revert InvalidAddress();
if (_kycApproved[user]) revert AlreadyApproved();
_kycApproved[user] = true;
emit KYCApproved(user);
}
/// @notice Revokes KYC status for a user
/// @dev Only callable by addresses with KYC_PROVIDER_ROLE
/// @param user Address of the user to revoke KYC from
/// @custom:throws InvalidAddress if user address is zero
/// @custom:throws NotApproved if user is not KYC approved
function revokeKYC(address user) external onlyRole(KYC_PROVIDER_ROLE) {
if (user == address(0)) revert InvalidAddress();
if (!_kycApproved[user]) revert NotApproved();
_kycApproved[user] = false;
emit KYCRevoked(user);
}
/// @notice Checks if a user is KYC approved
/// @param user Address of the user to check
/// @return bool True if user is KYC approved, false otherwise
function isKYCApproved(address user) external view returns (bool) {
return _kycApproved[user];
}
/// @notice Checks if an address has KYC provider role
/// @param provider Address to check
/// @return bool True if address is a KYC provider, false otherwise
function isKYCProvider(address provider) external view returns (bool) {
return hasRole(KYC_PROVIDER_ROLE, provider);
}
/// @notice Thrown when an invalid (zero) address is provided
error InvalidAddress();
/// @notice Thrown when attempting to approve KYC for an already approved user
error AlreadyApproved();
/// @notice Thrown when attempting to revoke KYC from a non-approved user
error NotApproved();
}
Read Contract
DEFAULT_ADMIN_ROLE 0xa217fddf → bytes32
KYC_ADMIN_ROLE 0x02d7fd92 → bytes32
KYC_PROVIDER_ROLE 0xd9e1063d → bytes32
getRoleAdmin 0x248a9ca3 → bytes32
hasRole 0x91d14854 → bool
isKYCApproved 0xe77db232 → bool
isKYCProvider 0xe73d0e50 → bool
supportsInterface 0x01ffc9a7 → bool
Write Contract 7 functions
These functions modify contract state and require a wallet transaction to execute.
addKYCProvider 0x4a749708
address provider
approveKYC 0x0e27324d
address user
grantRole 0x2f2ff15d
bytes32 role
address account
removeKYCProvider 0x0ae5fb50
address provider
renounceRole 0x36568abe
bytes32 role
address callerConfirmation
revokeKYC 0x39ba645b
address user
revokeRole 0xd547741f
bytes32 role
address account
Recent Transactions
No transactions found for this address