Address Contract Verified
Address
0x4C9142C4dC9E4023b585a567467Efcf5Cbc2C1CE
Balance
0 ETH
Nonce
1
Code Size
4221 bytes
Creator
0x37Fb248A...dD1B at tx 0x34759f91...573bfd
Indexed Transactions
0
Contract Bytecode
4221 bytes
0x608060405234801561001057600080fd5b50600436106100f55760003560e01c80638456cb5911610097578063c69073e411610066578063c69073e41461025e578063d547741f14610284578063e072068b14610297578063fd5861a6146102e357600080fd5b80638456cb59146101f757806391d14854146101ff578063a217fddf14610243578063b80f55c91461024b57600080fd5b80632f2ff15d116100d35780632f2ff15d146101bc57806336568abe146101d15780633f4ba83a146101e45780635c975abb146101ec57600080fd5b806301ffc9a7146100fa578063150b7a0214610122578063248a9ca31461018b575b600080fd5b61010d610108366004610d08565b610303565b60405190151581526020015b60405180910390f35b61015a610130366004610d73565b7f150b7a020000000000000000000000000000000000000000000000000000000095945050505050565b6040517fffffffff000000000000000000000000000000000000000000000000000000009091168152602001610119565b6101ae610199366004610e14565b60009081526020819052604090206001015490565b604051908152602001610119565b6101cf6101ca366004610e2d565b61039c565b005b6101cf6101df366004610e2d565b6103c7565b6101cf610425565b60015460ff1661010d565b6101cf61043b565b61010d61020d366004610e2d565b60009182526020828152604080842073ffffffffffffffffffffffffffffffffffffffff93909316845291905290205460ff1690565b6101ae600081565b6101cf610259366004610e5d565b61044e565b61027161026c366004610ed4565b610716565b60405161ffff9091168152602001610119565b6101cf610292366004610e2d565b610724565b6102be7f000000000000000000000000b44adddbf9b19bcdd12f978df8b36723488b9b8b81565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610119565b6102f66102f1366004610ed4565b610749565b6040516101199190610ef1565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b00000000000000000000000000000000000000000000000000000000148061039657507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316145b92915050565b6000828152602081905260409020600101546103b781610805565b6103c1838361080f565b50505050565b73ffffffffffffffffffffffffffffffffffffffff81163314610416576040517f6697b23200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610420828261090b565b505050565b600061043081610805565b6104386109c6565b50565b600061044681610805565b610438610a43565b610456610a9c565b806104c2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f4e6f20746f6b656e204944732070726f7669646564000000000000000000000060448201526064015b60405180910390fd5b60006104cd33610716565b90506104df6002336000858501610adb565b60005b61ffff81168311156103c157600084848361ffff1681811061050657610506610f38565b9050602002013590503373ffffffffffffffffffffffffffffffffffffffff167f000000000000000000000000b44adddbf9b19bcdd12f978df8b36723488b9b8b73ffffffffffffffffffffffffffffffffffffffff16636352211e836040518263ffffffff1660e01b815260040161058191815260200190565b602060405180830381865afa15801561059e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105c29190610f67565b73ffffffffffffffffffffffffffffffffffffffff161461060f576040517f30cd747100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61062160023360018587010184610adb565b6040517f42842e0e000000000000000000000000000000000000000000000000000000008152336004820152306024820152604481018290527f000000000000000000000000b44adddbf9b19bcdd12f978df8b36723488b9b8b73ffffffffffffffffffffffffffffffffffffffff16906342842e0e90606401600060405180830381600087803b1580156106b557600080fd5b505af11580156106c9573d6000803e3d6000fd5b50506040805133815260208101859052438183015290517f23ff0e75edf108e3d0392d92e13e8c8a868ef19001bd49f9e94876dc46dff87f9350908190036060019150a1506001016104e2565b600061039660028383610b6e565b60008281526020819052604090206001015461073f81610805565b6103c1838361090b565b606061075482610716565b61ffff1667ffffffffffffffff81111561077057610770610f84565b604051908082528060200260200182016040528015610799578160200160208202803683370190505b50905060005b81518161ffff1610156107ff576107c4836107bb836001610fe2565b60029190610b6e565b828261ffff16815181106107da576107da610f38565b61ffff90921660209283029190910190910152806107f781610ffc565b91505061079f565b50919050565b6104388133610bc6565b60008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915281205460ff166109035760008381526020818152604080832073ffffffffffffffffffffffffffffffffffffffff86168452909152902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790556108a13390565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16847f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a4506001610396565b506000610396565b60008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915281205460ff16156109035760008381526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8616808552925280832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905551339286917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a4506001610396565b6109ce610c50565b600180547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390a1565b610a4b610a9c565b600180547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016811790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25833610a19565b60015460ff1615610ad9576040517fd93c066500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b565b73ffffffffffffffffffffffffffffffffffffffff8316600090815260208581526040808320601361ffff8781168281048083168852939095529290942054909390920691610b2f91838116908616610c8c565b73ffffffffffffffffffffffffffffffffffffffff90951660009081526020968752604080822061ffff90941682529290965250909320919091555050565b73ffffffffffffffffffffffffffffffffffffffff8216600090815260208481526040808320601361ffff8681168281048083168852939095529285205491930691610bbc91908316610cd5565b9695505050505050565b60008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff16610c4c576040517fe2517d3f00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff82166004820152602481018390526044016104b9565b5050565b60015460ff16610ad9576040517f8dfc202b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600061200082108015610c9f5750601383105b610ca857600080fd5b610cb3600d8461101d565b925081831b83610cc66001612000611034565b901b1985161790509392505050565b600060138210610ce457600080fd5b610cf16001612000611034565b610cfc83600d61101d565b84901c16905092915050565b600060208284031215610d1a57600080fd5b81357fffffffff0000000000000000000000000000000000000000000000000000000081168114610d4a57600080fd5b9392505050565b73ffffffffffffffffffffffffffffffffffffffff8116811461043857600080fd5b600080600080600060808688031215610d8b57600080fd5b8535610d9681610d51565b94506020860135610da681610d51565b935060408601359250606086013567ffffffffffffffff811115610dc957600080fd5b8601601f81018813610dda57600080fd5b803567ffffffffffffffff811115610df157600080fd5b886020828401011115610e0357600080fd5b959894975092955050506020019190565b600060208284031215610e2657600080fd5b5035919050565b60008060408385031215610e4057600080fd5b823591506020830135610e5281610d51565b809150509250929050565b60008060208385031215610e7057600080fd5b823567ffffffffffffffff811115610e8757600080fd5b8301601f81018513610e9857600080fd5b803567ffffffffffffffff811115610eaf57600080fd5b8560208260051b8401011115610ec457600080fd5b6020919091019590945092505050565b600060208284031215610ee657600080fd5b8135610d4a81610d51565b602080825282518282018190526000918401906040840190835b81811015610f2d57835161ffff16835260209384019390920191600101610f0b565b509095945050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600060208284031215610f7957600080fd5b8151610d4a81610d51565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b61ffff818116838216019081111561039657610396610fb3565b600061ffff821661ffff810361101457611014610fb3565b60010192915050565b808202811582820484141761039657610396610fb3565b8181038181111561039657610396610fb356fea2646970667358221220af82b224680f2ffbb7953b6e57fe142b1f91809e5861bdcd8e0123f42f50e37064736f6c634300081b0033
Verified Source Code Full Match
Compiler: v0.8.27+commit.40a35a09
EVM: paris
Optimization: Yes (10000 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.1.0) (access/IAccessControl.sol)
pragma solidity ^0.8.20;
/**
* @dev External interface of AccessControl declared to support ERC-165 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. This account bears the admin role (for the granted role).
* Expected in cases where the role was granted using the internal {AccessControl-_grantRole}.
*/
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;
}
IERC721Receiver.sol 28 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC721/IERC721Receiver.sol)
pragma solidity ^0.8.20;
/**
* @title ERC-721 token receiver interface
* @dev Interface for any contract that wants to support safeTransfers
* from ERC-721 asset contracts.
*/
interface IERC721Receiver {
/**
* @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
* by `operator` from `from`, this function is called.
*
* It must return its Solidity selector to confirm the token transfer.
* If any other value is returned or the interface is not implemented by the recipient, the transfer will be
* reverted.
*
* The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.
*/
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}
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.1.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 ERC-165 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.1.0) (utils/introspection/IERC165.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC-165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[ERC].
*
* 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[ERC 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);
}
Pausable.sol 119 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Pausable.sol)
pragma solidity ^0.8.20;
import {Context} from "../utils/Context.sol";
/**
* @dev Contract module which allows children to implement an emergency stop
* mechanism that can be triggered by an authorized account.
*
* This module is used through inheritance. It will make available the
* modifiers `whenNotPaused` and `whenPaused`, which can be applied to
* the functions of your contract. Note that they will not be pausable by
* simply including this module, only once the modifiers are put in place.
*/
abstract contract Pausable is Context {
bool private _paused;
/**
* @dev Emitted when the pause is triggered by `account`.
*/
event Paused(address account);
/**
* @dev Emitted when the pause is lifted by `account`.
*/
event Unpaused(address account);
/**
* @dev The operation failed because the contract is paused.
*/
error EnforcedPause();
/**
* @dev The operation failed because the contract is not paused.
*/
error ExpectedPause();
/**
* @dev Initializes the contract in unpaused state.
*/
constructor() {
_paused = false;
}
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*
* Requirements:
*
* - The contract must not be paused.
*/
modifier whenNotPaused() {
_requireNotPaused();
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*
* Requirements:
*
* - The contract must be paused.
*/
modifier whenPaused() {
_requirePaused();
_;
}
/**
* @dev Returns true if the contract is paused, and false otherwise.
*/
function paused() public view virtual returns (bool) {
return _paused;
}
/**
* @dev Throws if the contract is paused.
*/
function _requireNotPaused() internal view virtual {
if (paused()) {
revert EnforcedPause();
}
}
/**
* @dev Throws if the contract is not paused.
*/
function _requirePaused() internal view virtual {
if (!paused()) {
revert ExpectedPause();
}
}
/**
* @dev Triggers stopped state.
*
* Requirements:
*
* - The contract must not be paused.
*/
function _pause() internal virtual whenNotPaused {
_paused = true;
emit Paused(_msgSender());
}
/**
* @dev Returns to normal state.
*
* Requirements:
*
* - The contract must be paused.
*/
function _unpause() internal virtual whenPaused {
_paused = false;
emit Unpaused(_msgSender());
}
}
IERC721A.sol 307 lines
// SPDX-License-Identifier: MIT
// ERC721A Contracts v4.3.0
// Creator: Chiru Labs
pragma solidity ^0.8.4;
/**
* @dev Interface of ERC721A.
*/
interface IERC721A {
/**
* The caller must own the token or be an approved operator.
*/
error ApprovalCallerNotOwnerNorApproved();
/**
* The token does not exist.
*/
error ApprovalQueryForNonexistentToken();
/**
* Cannot query the balance for the zero address.
*/
error BalanceQueryForZeroAddress();
/**
* Cannot mint to the zero address.
*/
error MintToZeroAddress();
/**
* The quantity of tokens minted must be more than zero.
*/
error MintZeroQuantity();
/**
* The token does not exist.
*/
error OwnerQueryForNonexistentToken();
/**
* The caller must own the token or be an approved operator.
*/
error TransferCallerNotOwnerNorApproved();
/**
* The token must be owned by `from`.
*/
error TransferFromIncorrectOwner();
/**
* Cannot safely transfer to a contract that does not implement the
* ERC721Receiver interface.
*/
error TransferToNonERC721ReceiverImplementer();
/**
* Cannot transfer to the zero address.
*/
error TransferToZeroAddress();
/**
* The token does not exist.
*/
error URIQueryForNonexistentToken();
/**
* The `quantity` minted with ERC2309 exceeds the safety limit.
*/
error MintERC2309QuantityExceedsLimit();
/**
* The `extraData` cannot be set on an unintialized ownership slot.
*/
error OwnershipNotInitializedForExtraData();
/**
* `_sequentialUpTo()` must be greater than `_startTokenId()`.
*/
error SequentialUpToTooSmall();
/**
* The `tokenId` of a sequential mint exceeds `_sequentialUpTo()`.
*/
error SequentialMintExceedsLimit();
/**
* Spot minting requires a `tokenId` greater than `_sequentialUpTo()`.
*/
error SpotMintTokenIdTooSmall();
/**
* Cannot mint over a token that already exists.
*/
error TokenAlreadyExists();
/**
* The feature is not compatible with spot mints.
*/
error NotCompatibleWithSpotMints();
// =============================================================
// STRUCTS
// =============================================================
struct TokenOwnership {
// The address of the owner.
address addr;
// Stores the start time of ownership with minimal overhead for tokenomics.
uint64 startTimestamp;
// Whether the token has been burned.
bool burned;
// Arbitrary data similar to `startTimestamp` that can be set via {_extraData}.
uint24 extraData;
}
// =============================================================
// TOKEN COUNTERS
// =============================================================
/**
* @dev Returns the total number of tokens in existence.
* Burned tokens will reduce the count.
* To get the total number of tokens minted, please see {_totalMinted}.
*/
function totalSupply() external view returns (uint256);
// =============================================================
// IERC165
// =============================================================
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* [EIP section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified)
* to learn more about how these ids are created.
*
* This function call must use less than 30000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
// =============================================================
// IERC721
// =============================================================
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables
* (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in `owner`'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`,
* checking first that contract recipients are aware of the ERC721 protocol
* to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be have been allowed to move
* this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement
* {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes calldata data
) external payable;
/**
* @dev Equivalent to `safeTransferFrom(from, to, tokenId, '')`.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external payable;
/**
* @dev Transfers `tokenId` from `from` to `to`.
*
* WARNING: Usage of this method is discouraged, use {safeTransferFrom}
* whenever possible.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token
* by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) external payable;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the
* zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external payable;
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom}
* for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the caller.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool _approved) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}.
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
// =============================================================
// IERC721Metadata
// =============================================================
/**
* @dev Returns the token collection name.
*/
function name() external view returns (string memory);
/**
* @dev Returns the token collection symbol.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
*/
function tokenURI(uint256 tokenId) external view returns (string memory);
// =============================================================
// IERC2309
// =============================================================
/**
* @dev Emitted when tokens in `fromTokenId` to `toTokenId`
* (inclusive) is transferred from `from` to `to`, as defined in the
* [ERC2309](https://eips.ethereum.org/EIPS/eip-2309) standard.
*
* See {_mintERC2309} for more details.
*/
event ConsecutiveTransfer(uint256 indexed fromTokenId, uint256 toTokenId, address indexed from, address indexed to);
}
BeramoniumPortal.sol 87 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {AccessControl} from "@openzeppelin/contracts/access/AccessControl.sol";
import {Pausable} from "@openzeppelin/contracts/utils/Pausable.sol";
import {IERC721Receiver} from "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
import {IERC721A} from "erc721a/contracts/IERC721A.sol";
import {IBeramoniumPortal} from "./IBeramoniumPortal.sol";
import {Uint13List} from "../utils/Uint13List.sol";
using Uint13List for Uint13List.Storage;
contract BeramoniumPortal is AccessControl, Pausable, IERC721Receiver, IBeramoniumPortal {
IERC721A public immutable _beramonium;
Uint13List.Storage _flexBurnedList;
constructor(IERC721A beramonium) {
_grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
_beramonium = beramonium;
}
/**
* @notice Returns the number of burned beras for the given owner.
*/
function burnedBeraCount(address owner) public view returns (uint16) {
return _flexBurnedList.getAt(owner, 0);
}
/**
* @notice Returns the list of burned Bera IDs for the given owner.
*/
function burnedBeras(address owner) public view returns (uint16[] memory ret) {
ret = new uint16[](burnedBeraCount(owner));
for (uint16 i = 0; i < ret.length; i++) {
// We prefix the array with length (taking 1 slot), so we need to add 1
ret[i] = _flexBurnedList.getAt(owner, i + 1);
}
}
/**
* @notice Burns the given NFT IDs by transferring them to this contract address and storing the token IDs.
* @param tokenIds Array of NFT token IDs to be burned.
*/
function burn(uint256[] calldata tokenIds) public override whenNotPaused {
require(tokenIds.length > 0, "No token IDs provided");
unchecked {
uint16 burnCount = burnedBeraCount(msg.sender);
// Increment the burn count
_flexBurnedList.setAt(msg.sender, 0, burnCount + uint16(tokenIds.length));
for (uint16 i = 0; i < tokenIds.length; i++) {
uint256 tokenId = tokenIds[i];
require(_beramonium.ownerOf(tokenId) == msg.sender, NotOwner());
// We prefix the array with length (taking 1 slot), so we need to add 1
_flexBurnedList.setAt(msg.sender, i + burnCount + 1, uint16(tokenId));
_beramonium.safeTransferFrom(msg.sender, address(this), tokenId);
emit Burned(msg.sender, tokenId, block.number);
}
}
}
error NotOwner();
function pause() external onlyRole(DEFAULT_ADMIN_ROLE) {
_pause();
}
function unpause() external onlyRole(DEFAULT_ADMIN_ROLE) {
_unpause();
}
// IERC721Receiver
function onERC721Received(
address,
address,
uint256,
bytes calldata
) external pure override returns (bytes4) {
return IERC721Receiver.onERC721Received.selector;
}
}
IBeramoniumPortal.sol 10 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {IERC721A} from "erc721a/contracts/IERC721A.sol";
interface IBeramoniumPortal {
function burn(uint256[] calldata tokenIds) external;
event Burned(address owner, uint256 tokenId, uint timestamp);
}
Uint13Array19.sol 23 lines
// SPDX-License-Identifier: WTFPL
pragma solidity ^0.8.13;
library Uint13Array19 {
type u13a19 is uint256;
uint8 constant bits = 13;
uint8 constant elements = 19;
uint256 constant range = 1 << bits;
uint256 constant max = range - 1;
function get(u13a19 va, uint256 index) internal pure returns (uint256) {
require(index < elements);
return (u13a19.unwrap(va) >> (bits * index)) & max;
}
function set(u13a19 va, uint256 index, uint256 value) internal pure returns (u13a19) {
require(value < range && index < elements);
index *= bits;
return u13a19.wrap((u13a19.unwrap(va) & ~(max << index)) | (value << index));
}
}
Uint13List.sol 56 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {Uint13Array19} from "./Uint13Array19.sol";
/**
* @notice A dynamic list of `uint13`s for each address.
*/
library Uint13List {
using Uint13Array19 for uint256;
struct Storage {
mapping(address => mapping(uint16 => Uint13Array19.u13a19)) list;
}
/** @dev Effectively a `divmod` for {Uint13Array19.elements}. */
function toPagedIndex(
uint16 listIndex
) internal pure returns (uint16 pageIndex, uint16 indexInPage) {
unchecked {
// Since listIndex is < 65536, then pageIndex can be at most 3449,
// so pageIndex is in {0,1,2,...,3449} range
pageIndex = listIndex / Uint13Array19.elements;
// indexInPage is in {0,1,2,...,18}
indexInPage = listIndex % Uint13Array19.elements;
}
}
/** @notice Sets the value at the given list index for the given address. */
function setAt(
Storage storage self,
address owner,
uint16 listIndex,
uint16 value
) internal {
(uint16 pageIndex, uint16 indexInPage) = toPagedIndex(listIndex);
self.list[owner][pageIndex] = Uint13Array19.set(
self.list[owner][pageIndex],
indexInPage,
value
);
}
/** @notice Gets the value at the given list index for the given address. */
function getAt(
Storage storage self,
address owner,
uint16 listIndex
) internal view returns (uint16) {
(uint16 pageIndex, uint16 indexInPage) = toPagedIndex(listIndex);
return uint16(Uint13Array19.get(self.list[owner][pageIndex], indexInPage));
}
}
Read Contract
DEFAULT_ADMIN_ROLE 0xa217fddf → bytes32
_beramonium 0xe072068b → address
burnedBeraCount 0xc69073e4 → uint16
burnedBeras 0xfd5861a6 → uint16[]
getRoleAdmin 0x248a9ca3 → bytes32
hasRole 0x91d14854 → bool
onERC721Received 0x150b7a02 → bytes4
paused 0x5c975abb → bool
supportsInterface 0x01ffc9a7 → bool
Write Contract 6 functions
These functions modify contract state and require a wallet transaction to execute.
burn 0xb80f55c9
uint256[] tokenIds
grantRole 0x2f2ff15d
bytes32 role
address account
pause 0x8456cb59
No parameters
renounceRole 0x36568abe
bytes32 role
address callerConfirmation
revokeRole 0xd547741f
bytes32 role
address account
unpause 0x3f4ba83a
No parameters
Recent Transactions
No transactions found for this address