Address Contract Partially Verified
Address
0xeEecb56145bcE70DFa5afc5BD8984BAa0dBa793F
Balance
0 ETH
Nonce
1
Code Size
5447 bytes
Creator
0xA04d0297...d723 at tx 0x145154ce...c03132
Indexed Transactions
0 (1 on-chain, 1.4% indexed)
Contract Bytecode
5447 bytes
0x608080604052600436101561001357600080fd5b600090813560e01c90816301ffc9a714610bc157508063188ec35614610b9e578063248a9ca314610b725780632a0acc6a14610b4f5780632f2ff15d14610ab1578063314207e414610a8a578063362626681461073357806336568abe146106925780633f4ba83a146105ee578063459b48b5146105d05780635c975abb146105aa5780636c19e7831461056b578063715018a61461050f57806380927cbc146104f15780638456cb591461047f5780638da5cb5b146104585780638f399324146104195780638fea17e31461030d57806391d14854146102c15780639a7e9a7b1461029e578063a217fddf14610282578063aca732251461025f578063affed0e014610241578063d547741f146102115763f2fde38b1461013457600080fd5b3461020e57602036600319011261020e5761014d610c2c565b610155610ce5565b6001600160a01b038091169081156101a357600154826001600160a01b0319821617600155167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a380f35b60405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608490fd5b80fd5b503461020e57604036600319011261020e5761023e61022e610c16565b610236610ce5565b600435610c70565b80f35b503461020e578060031936011261020e576020600554604051908152f35b503461020e57602036600319011261020e57610279611178565b60043560035580f35b503461020e578060031936011261020e57602090604051908152f35b503461020e57602036600319011261020e576102b8611178565b60043560045580f35b503461020e57604036600319011261020e576001600160a01b0360406102e5610c16565b92600435815280602052209116600052602052602060ff604060002054166040519015158152f35b503461020e5761010036600319011261020e57610328610c2c565b6001600160a01b0391604435918383168303610414576084359184831683036104145760e4359067ffffffffffffffff821161020e57602061040b876104036103ed6103fd8a6103f58b8b6103803660048e01610c42565b6040516bffffffffffffffffffffffff19606094851b81168e8301908152602435601482015297851b8116603489015260643560488901529490931b909316606886015260a435607c86015260c435609c86015291959193918160bc84015b03601f198101835282610d3d565b51902061101b565b923691610d75565b90610f2e565b929092610dbc565b60405191168152f35b600080fd5b503461020e57602036600319011261020e576001600160a01b0361043b610c2c565b610443611178565b166001600160a01b0319600254161760025580f35b503461020e578060031936011261020e5760206001600160a01b0360015416604051908152f35b503461020e578060031936011261020e57610498611178565b6104a06110d3565b7401000000000000000000000000000000000000000060ff60a01b1960015416176001557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586020604051338152a180f35b503461020e578060031936011261020e576020600354604051908152f35b503461020e578060031936011261020e57610528610ce5565b60006001600160a01b036001546001600160a01b03198116600155167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a380f35b503461020e57602036600319011261020e576001600160a01b0361058d610c2c565b610595611178565b166001600160a01b0319600654161760065580f35b503461020e578060031936011261020e57602060ff60015460a01c166040519015158152f35b503461020e578060031936011261020e576020600454604051908152f35b503461020e578060031936011261020e57610607611178565b60015460ff8160a01c161561064d5760ff60a01b19166001557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa6020604051338152a180f35b60405162461bcd60e51b815260206004820152601460248201527f5061757361626c653a206e6f74207061757365640000000000000000000000006044820152606490fd5b503461020e57604036600319011261020e576106ac610c16565b336001600160a01b038216036106c85761023e90600435610c70565b60405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c6600000000000000000000000000000000006064820152608490fd5b5060a036600319011261020e57610748610c16565b6001600160a01b0360643516606435036109b35760843567ffffffffffffffff8111610a865761077c903690600401610c42565b90916107866110d3565b6004543410610a41576002546040516398f7ceab60e01b81526001600160a01b0383811660048084019190915235602483018190529592169190602081604481865afa8015610a36576107e09188916109fc575b50611087565b6040516398f7ceab60e01b81526064356001600160a01b0316600482015260448035602483018190529590602090839081875afa8015610a2b576108b1936108356103fd926108a9958c916109fc5750611087565b6103f5878a6103ed8b6103df610849611127565b60055490604051958694602086019860643592338b95939060bc979592936bffffffffffffffffffffffff199485809360601b168952601489015260601b166034870152604886015260601b166068840152607c830152609c8201520190565b919091610dbc565b6001600160a01b0380600654169116036109b7578085913b156109b3578190602460405180948193630852cd8d60e31b83528860048401525af180156109a857610978575b50600554600019811461096457916001600160a01b037f6c4a689fae8eef91ac5d2b8678e78e7f42c5644aacf0b5a908c6e05b522a49a99492600160a0950160055560405193338552602085015216604083015260608201526001600160a01b03606435166080820152a180f35b634e487b7160e01b85526011600452602485fd5b67ffffffffffffffff81959295116109945760405292386108f6565b634e487b7160e01b82526041600452602482fd5b6040513d87823e3d90fd5b5080fd5b60405162461bcd60e51b815260206004820152601160248201527f496e76616c6964205369676e61747572650000000000000000000000000000006044820152606490fd5b610a1e915060203d602011610a24575b610a168183610d3d565b81019061106f565b386107da565b503d610a0c565b6040513d8a823e3d90fd5b6040513d89823e3d90fd5b60405162461bcd60e51b815260206004820152600e60248201527f4e6f7420456e6f756768204574680000000000000000000000000000000000006044820152606490fd5b8280fd5b503461020e578060031936011261020e5760206001600160a01b0360025416604051908152f35b503461020e57604036600319011261020e57600435610ace610c16565b610ad6610ce5565b818352826020526001600160a01b036040842091169081845260205260ff60408420541615610b03578280f35b818352826020526040832081845260205260408320600160ff1982541617905533917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d8480a438808280f35b503461020e578060031936011261020e5760206040516420a226a4a760d91b8152f35b503461020e57602036600319011261020e57600160406020926004358152808452200154604051908152f35b503461020e578060031936011261020e576020610bb9611127565b604051908152f35b9050346109b35760203660031901126109b35760043563ffffffff60e01b8116809103610a865760209250637965db0b60e01b8114908115610c05575b5015158152f35b6301ffc9a760e01b14905038610bfe565b602435906001600160a01b038216820361041457565b600435906001600160a01b038216820361041457565b9181601f840112156104145782359167ffffffffffffffff8311610414576020838186019501011161041457565b90600091808352826020526001600160a01b036040842092169182845260205260ff604084205416610ca157505050565b80835282602052604083208284526020526040832060ff1981541690557ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b339380a4565b6001600160a01b03600154163303610cf957565b606460405162461bcd60e51b815260206004820152602060248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152fd5b90601f8019910116810190811067ffffffffffffffff821117610d5f57604052565b634e487b7160e01b600052604160045260246000fd5b92919267ffffffffffffffff8211610d5f5760405191610d9f601f8201601f191660200184610d3d565b829481845281830111610414578281602093846000960137010152565b6005811015610f185780610dcd5750565b60018103610e1a5760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606490fd5b60028103610e675760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606490fd5b60038103610ebf5760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608490fd5b600414610ec857565b60405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c604482015261756560f01b6064820152608490fd5b634e487b7160e01b600052602160045260246000fd5b906041815114600014610f5c57610f58916020820151906060604084015193015160001a90610f66565b9091565b5050600090600290565b9291907f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0831161100f5760ff16601b81141580611004575b610ff8579160809493916020936040519384528484015260408301526060820152600093849182805260015afa15610feb5781516001600160a01b03811615610fe5579190565b50600190565b50604051903d90823e3d90fd5b50505050600090600490565b50601c811415610f9e565b50505050600090600390565b60405160208101917f19457468657265756d205369676e6564204d6573736167653a0a3332000000008352603c820152603c81526060810181811067ffffffffffffffff821117610d5f5760405251902090565b90816020910312610414575180151581036104145790565b1561108e57565b60405162461bcd60e51b815260206004820152601760248201527f596f7520417265204e6f7420546f6b656e204f776e65720000000000000000006044820152606490fd5b60ff60015460a01c166110e257565b60405162461bcd60e51b815260206004820152601060248201527f5061757361626c653a20706175736564000000000000000000000000000000006044820152606490fd5b600354603c810290808204603c148115171561116257610e100290808204603c14901517156111625742018042116111625762015180900490565b634e487b7160e01b600052601160045260246000fd5b3360009081527fff164f808567eb9100129b1d5aead1611f532533c7a4cedced7e7f0a6271f53160209081526040808320546420a226a4a760d91b9060ff16156111c25750505050565b81519367ffffffffffffffff3360608701828111888210176114dc578552602a875285870193853686378751156114c857603085538751916001928310156114b457607860218a015360295b83811161144a575061140857908551926080840190848210908211176113f4578652604283528683019360603686378351156113e0576030855383518210156113e05790607860218501536041915b8183116113725750505061133057926112fe60486112ef9794611322946044989785519a8b936112ba8b86019a7f416363657373436f6e74726f6c3a206163636f756e74200000000000000000008c5251809260378801906114f0565b8401917f206973206d697373696e6720726f6c65200000000000000000000000000000006037840152518093868401906114f0565b01036028810189520187610d3d565b5194859362461bcd60e51b85526004850152518092816024860152858501906114f0565b601f01601f19168101030190fd5b60648585519062461bcd60e51b825280600483015260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152fd5b909192600f811660108110156113cc576f181899199a1a9b1b9c1cb0b131b232b360811b901a6113a28587611513565b5360041c9280156113b85760001901919061125d565b634e487b7160e01b82526011600452602482fd5b634e487b7160e01b83526032600452602483fd5b634e487b7160e01b81526032600452602490fd5b634e487b7160e01b85526041600452602485fd5b60648787519062461bcd60e51b825280600483015260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152fd5b90600f811660108110156114a0576f181899199a1a9b1b9c1cb0b131b232b360811b901a611478838c611513565b5360041c90801561148c576000190161120e565b634e487b7160e01b86526011600452602486fd5b634e487b7160e01b87526032600452602487fd5b634e487b7160e01b85526032600452602485fd5b634e487b7160e01b84526032600452602484fd5b634e487b7160e01b84526041600452602484fd5b60005b8381106115035750506000910152565b81810151838201526020016114f3565b908151811015611524570160200190565b634e487b7160e01b600052603260045260246000fdfea164736f6c6343000811000a
Verified Source Code Partial Match
Compiler: v0.8.17+commit.8df45f5f
EVM: london
Optimization: Yes (800 runs)
IMosquitoFamily.sol 7 lines
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.9;
interface IMosquitoFamily {
function burn(uint256 _tokenId) external;
function isTokenOwner(address _owner, uint256 _tokenId) view external returns (bool);
}
MosquitoFamilyBirth.sol 120 lines
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.17;
import "./IMosquitoFamily.sol";
import "@openzeppelin/contracts/access/AccessControl.sol";
import "@openzeppelin/contracts/security/Pausable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
contract MosquitoFamilyBirth is AccessControl, Ownable, Pausable {
using ECDSA for bytes32;
// Manage
bytes32 public constant ADMIN = "ADMIN";
IMosquitoFamily public mosquitoFamily;
// ForSign
uint256 public timezoneDiffHour = 9;
uint256 public birthCost;
uint256 public nonce = 0;
address private _signer;
// Event
event MosquitoBirth(address _sender, uint256 _motherTokenId, address _motherOwner, uint256 _fatherTokenId, address _fatherOwner);
// Modifier
modifier enoughEth() {
require(msg.value >= birthCost, 'Not Enough Eth');
_;
}
modifier isTokenOwner(address _address, uint256 _tokenId) {
require(mosquitoFamily.isTokenOwner(_address, _tokenId), "You Are Not Token Owner");
_;
}
modifier isValidSignature (uint256 _motherTokenId, address _motherOwner, uint256 _fatherTokenId, address _fatherOwner, bytes calldata _signature) {
address recoveredAddress = keccak256(
abi.encodePacked(
msg.sender,
_motherTokenId,
_motherOwner,
_fatherTokenId,
_fatherOwner,
getTimestamp(),
nonce
)
).toEthSignedMessageHash().recover(_signature);
require(recoveredAddress == _signer, "Invalid Signature");
_;
}
// Constructor
constructor() {
_grantRole(ADMIN, msg.sender);
}
function recoverSignature (address _address, uint256 _motherTokenId, address _motherOwner, uint256 _fatherTokenId, address _fatherOwner, uint256 _timestamp, uint256 _nonce, bytes calldata _signature) external view returns (address) {
address recoveredAddress = keccak256(
abi.encodePacked(
_address,
_motherTokenId,
_motherOwner,
_fatherTokenId,
_fatherOwner,
_timestamp,
_nonce
)
).toEthSignedMessageHash().recover(_signature);
return recoveredAddress;
}
// Birth
function birth (uint256 _motherTokenId, address _motherOwner, uint256 _fatherTokenId, address _fatherOwner, bytes calldata _signature) external payable
whenNotPaused
enoughEth()
isTokenOwner(_motherOwner, _motherTokenId)
isTokenOwner(_fatherOwner, _fatherTokenId)
isValidSignature(_motherTokenId, _motherOwner, _fatherTokenId, _fatherOwner, _signature)
{
mosquitoFamily.burn(_fatherTokenId);
nonce++;
emit MosquitoBirth(msg.sender, _motherTokenId, _motherOwner, _fatherTokenId, _fatherOwner);
}
// Getter
function getTimestamp() public view returns (uint256) {
return (block.timestamp + timezoneDiffHour * 60 * 60) / (24 * 60 * 60);
}
// Setter
function setMosquitoFamily(address _value) external onlyRole(ADMIN) {
mosquitoFamily = IMosquitoFamily(_value);
}
function setTimezoneDiffHour(uint256 _value) external onlyRole(ADMIN) {
timezoneDiffHour = _value;
}
function setBirthCost(uint256 _value) external onlyRole(ADMIN) {
birthCost = _value;
}
function setSigner(address _value) external onlyRole(ADMIN) {
_signer = _value;
}
// Pausable
function pause() external onlyRole(ADMIN) {
_pause();
}
function unpause() external onlyRole(ADMIN) {
_unpause();
}
// AccessControl
function grantRole(bytes32 role, address account) public override onlyOwner {
_grantRole(role, account);
}
function revokeRole(bytes32 role, address account) public override onlyOwner {
_revokeRole(role, account);
}
}
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);
}
}
Ownable.sol 83 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_transferOwnership(_msgSender());
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
Pausable.sol 105 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)
pragma solidity ^0.8.0;
import "../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 {
/**
* @dev Emitted when the pause is triggered by `account`.
*/
event Paused(address account);
/**
* @dev Emitted when the pause is lifted by `account`.
*/
event Unpaused(address account);
bool private _paused;
/**
* @dev Initializes the contract in unpaused state.
*/
constructor() {
_paused = false;
}
/**
* @dev 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 {
require(!paused(), "Pausable: paused");
}
/**
* @dev Throws if the contract is not paused.
*/
function _requirePaused() internal view virtual {
require(paused(), "Pausable: not paused");
}
/**
* @dev Triggers stopped state.
*
* Requirements:
*
* - The contract must not be paused.
*/
function _pause() internal virtual whenNotPaused {
_paused = true;
emit Paused(_msgSender());
}
/**
* @dev Returns to normal state.
*
* Requirements:
*
* - The contract must be paused.
*/
function _unpause() internal virtual whenPaused {
_paused = false;
emit Unpaused(_msgSender());
}
}
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());
}
}
}
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;
}
ECDSA.sol 218 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.3) (utils/cryptography/ECDSA.sol)
pragma solidity ^0.8.0;
import "../Strings.sol";
/**
* @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
*
* These functions can be used to verify that a message was signed by the holder
* of the private keys of a given address.
*/
library ECDSA {
enum RecoverError {
NoError,
InvalidSignature,
InvalidSignatureLength,
InvalidSignatureS,
InvalidSignatureV
}
function _throwError(RecoverError error) private pure {
if (error == RecoverError.NoError) {
return; // no error: do nothing
} else if (error == RecoverError.InvalidSignature) {
revert("ECDSA: invalid signature");
} else if (error == RecoverError.InvalidSignatureLength) {
revert("ECDSA: invalid signature length");
} else if (error == RecoverError.InvalidSignatureS) {
revert("ECDSA: invalid signature 's' value");
} else if (error == RecoverError.InvalidSignatureV) {
revert("ECDSA: invalid signature 'v' value");
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature` or error string. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {toEthSignedMessageHash} on it.
*
* Documentation for signature generation:
* - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
* - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
*
* _Available since v4.3._
*/
function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {
if (signature.length == 65) {
bytes32 r;
bytes32 s;
uint8 v;
// ecrecover takes the signature parameters, and the only way to get them
// currently is to use assembly.
/// @solidity memory-safe-assembly
assembly {
r := mload(add(signature, 0x20))
s := mload(add(signature, 0x40))
v := byte(0, mload(add(signature, 0x60)))
}
return tryRecover(hash, v, r, s);
} else {
return (address(0), RecoverError.InvalidSignatureLength);
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature`. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {toEthSignedMessageHash} on it.
*/
function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, signature);
_throwError(error);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
*
* See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]
*
* _Available since v4.3._
*/
function tryRecover(
bytes32 hash,
bytes32 r,
bytes32 vs
) internal pure returns (address, RecoverError) {
bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
uint8 v = uint8((uint256(vs) >> 255) + 27);
return tryRecover(hash, v, r, s);
}
/**
* @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.
*
* _Available since v4.2._
*/
function recover(
bytes32 hash,
bytes32 r,
bytes32 vs
) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, r, vs);
_throwError(error);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `v`,
* `r` and `s` signature fields separately.
*
* _Available since v4.3._
*/
function tryRecover(
bytes32 hash,
uint8 v,
bytes32 r,
bytes32 s
) internal pure returns (address, RecoverError) {
// EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
// unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
// the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
// signatures from current libraries generate a unique signature with an s-value in the lower half order.
//
// If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
// with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
// vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
// these malleable signatures as well.
if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
return (address(0), RecoverError.InvalidSignatureS);
}
if (v != 27 && v != 28) {
return (address(0), RecoverError.InvalidSignatureV);
}
// If the signature is valid (and not malleable), return the signer address
address signer = ecrecover(hash, v, r, s);
if (signer == address(0)) {
return (address(0), RecoverError.InvalidSignature);
}
return (signer, RecoverError.NoError);
}
/**
* @dev Overload of {ECDSA-recover} that receives the `v`,
* `r` and `s` signature fields separately.
*/
function recover(
bytes32 hash,
uint8 v,
bytes32 r,
bytes32 s
) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, v, r, s);
_throwError(error);
return recovered;
}
/**
* @dev Returns an Ethereum Signed Message, created from a `hash`. This
* produces hash corresponding to the one signed with the
* https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
* JSON-RPC method as part of EIP-191.
*
* See {recover}.
*/
function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {
// 32 is the length in bytes of hash,
// enforced by the type signature above
return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash));
}
/**
* @dev Returns an Ethereum Signed Message, created from `s`. This
* produces hash corresponding to the one signed with the
* https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
* JSON-RPC method as part of EIP-191.
*
* See {recover}.
*/
function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {
return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", Strings.toString(s.length), s));
}
/**
* @dev Returns an Ethereum Signed Typed Data, created from a
* `domainSeparator` and a `structHash`. This produces hash corresponding
* to the one signed with the
* https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]
* JSON-RPC method as part of EIP-712.
*
* See {recover}.
*/
function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {
return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
}
}
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);
}
Read Contract
ADMIN 0x2a0acc6a → bytes32
DEFAULT_ADMIN_ROLE 0xa217fddf → bytes32
birthCost 0x459b48b5 → uint256
getRoleAdmin 0x248a9ca3 → bytes32
getTimestamp 0x188ec356 → uint256
hasRole 0x91d14854 → bool
mosquitoFamily 0x314207e4 → address
nonce 0xaffed0e0 → uint256
owner 0x8da5cb5b → address
paused 0x5c975abb → bool
recoverSignature 0x8fea17e3 → address
supportsInterface 0x01ffc9a7 → bool
timezoneDiffHour 0x80927cbc → uint256
Write Contract 12 functions
These functions modify contract state and require a wallet transaction to execute.
birth 0x36262668
uint256 _motherTokenId
address _motherOwner
uint256 _fatherTokenId
address _fatherOwner
bytes _signature
grantRole 0x2f2ff15d
bytes32 role
address account
pause 0x8456cb59
No parameters
renounceOwnership 0x715018a6
No parameters
renounceRole 0x36568abe
bytes32 role
address account
revokeRole 0xd547741f
bytes32 role
address account
setBirthCost 0x9a7e9a7b
uint256 _value
setMosquitoFamily 0x8f399324
address _value
setSigner 0x6c19e783
address _value
setTimezoneDiffHour 0xaca73225
uint256 _value
transferOwnership 0xf2fde38b
address newOwner
unpause 0x3f4ba83a
No parameters
Recent Transactions
This address has 1 on-chain transactions, but only 1.4% of the chain is indexed. Transactions will appear as indexing progresses. View on Etherscan →