账户
0x15...f1fb
0x15...f1fb

0x15...f1fb

$500
此合同的源代码已经过验证!
合同元数据
编译器
0.8.20+commit.a1b79de6
语言
Solidity
合同源代码
文件 1 的 6:AccessControl.sol
// 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;
        }
    }
}
合同源代码
文件 2 的 6:ChickenData.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/access/AccessControl.sol";

/**
 * @title ChickenData
 * @dev A contract for managing chicken data.
 * This contract utilizes role-based access control for secure management of chicken data.
 */
contract ChickenData is AccessControl {
  /// @notice The constant identifier for the manager role.
  bytes32 public constant MANAGER_ROLE = keccak256("MANAGER_ROLE");

  /// @notice Enumeration to specify option side - CALL or PUT.
  enum OptionSide {
    CALL,
    PUT
  }

  /// @notice Enumeration to specify asset types.
  enum Asset {
    BTC,
    ETH,
    BNB,
    SOL,
    AVAX,
    OP,
    MATIC
  }

  /// @notice Structure to define a feeding schedule.
  struct FeedingSchedule {
    uint256 amount;
    uint256 dueOn;
    bool fed;
  }

  /// @notice Enumeration to specify currency type for feeding.
  enum FeedCurrency {
    COIN,
    TOKEN
  }

  /// @notice Structure to define chicken properties.
  struct Chicken {
    address creator;
    Asset asset;
    uint256 spotPrice;
    uint256 strikePrice;
    uint256 tokenId;
    uint256 size;
    uint256 upfrontPayment;
    uint256[] commissionSchedule;
    OptionSide side;
    uint256 maturityTimestamp;
    uint256 lastFeedTime;
    uint256 valuation;
    bool isClaimed;
    uint256 totalFeeds;
    uint256 hatchTimestamp;
    uint256 lastUpdateTime;
    FeedCurrency feedCurrency;
    address issuer;
    bool settled;
  }

  /// @notice Mapping from chicken ID to chicken data.
  mapping(uint256 => Chicken) private chickens;

  /// @notice Mapping from owner to list of owned chicken IDs.
  mapping(address => uint256[]) private ownedChickens;

  /// @notice Mapping from chicken ID to its feeding schedule.
  mapping(uint256 => FeedingSchedule[]) public feedingSchedules;

  /// @notice Total count of chickens managed by the contract.
  uint256 private totalChickens;

  /// @notice Event emitted when a chicken is added.
  event ChickenAdded(uint256 chickenId, address indexed creator);

  /// @notice Event emitted when a chicken is updated.
  event ChickenUpdated(uint256 chickenId);

  /// @notice Event emitted when a chicken is removed.
  event ChickenRemoved(uint256 chickenId);

  /// @notice Event emitted when all chickens are replaced.
  event AllChickensReplaced();

  /// @notice Event emitted when a chicken is transferred.
  event ChickenTransferred(uint256 chickenId, address indexed from, address indexed to);

  /// @notice Custom error for when a chicken does not exist.
  error ChickenDoesNotExist();

  /// @notice Custom error for when a caller is not a manager.
  error CallerNotManager();

  /// @notice Custom error for when a caller is not the chicken owner.
  error NotChickenOwner();

  /// @notice Custom error for invalid recipient address.
  error InvalidRecipientAddress();

  /// @notice Custom error for input arrays length mismatch.
  error InputArraysLengthMismatch();

  /// @notice Custom error for invalid feeding schedule.
  error InvalidFeedingSchedule();

  /// @notice Custom error for chicken already exists.
  error ChickenAlreadyExists();

  /**
   * @dev Initializes the ChickenData contract with the deployer as admin and manager.
   */
  constructor() {
    _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
    _grantRole(MANAGER_ROLE, msg.sender);
  }

  /**
   * @dev Modifier to restrict access to functions to only manager role.
   */
  modifier onlyManager() {
    if (!hasRole(MANAGER_ROLE, msg.sender)) revert CallerNotManager();
    _;
  }

  /**
   * @dev Modifier to check if the chicken exists.
   * @param _tokenId The ID of the chicken.
   */
  modifier chickenExists(uint256 _tokenId) {
    if (chickens[_tokenId].strikePrice == 0) revert ChickenDoesNotExist();
    _;
  }

  /**
   * @dev Modifier to check if the feeding schedule is valid.
   * @param schedules The array of feeding schedules.
   */
  modifier validFeedingSchedule(FeedingSchedule[] memory schedules) {
    for (uint256 i = 0; i < schedules.length; i++) {
      if (schedules[i].dueOn == 0) revert InvalidFeedingSchedule();
    }
    _;
  }

  /**
   * @notice Adds a new chicken.
   * @dev Only callable by a manager.
   * @param _chicken The chicken data to be added.
   * @return The ID of the added chicken.
   */
  function addChicken(Chicken calldata _chicken) external onlyManager returns (uint256) {
    uint256 tokenId = _chicken.tokenId;
    if (chickens[tokenId].strikePrice != 0) revert ChickenAlreadyExists();

    chickens[tokenId] = _chicken;
    chickens[tokenId].hatchTimestamp = uint64(block.timestamp);
    chickens[tokenId].lastUpdateTime = uint64(block.timestamp);

    //add to ownedChickens
    ownedChickens[_chicken.creator].push(tokenId);

    unchecked {
      ++totalChickens;
    }

    emit ChickenAdded(tokenId, _chicken.creator);
    return tokenId;
  }

  /**
   * @notice Updates an existing chicken.
   * @dev Only callable by a manager.
   * @param _tokenId The ID of the chicken to be updated.
   * @param _updatedChicken The updated chicken data.
   */
  function updateChicken(uint256 _tokenId, Chicken calldata _updatedChicken) external onlyManager chickenExists(_tokenId) {
    chickens[_tokenId] = _updatedChicken;
    chickens[_tokenId].lastUpdateTime = block.timestamp;
    emit ChickenUpdated(_tokenId);
  }

  /**
   * @notice Removes a chicken.
   * @dev Only callable by a manager.
   * @param _tokenId The ID of the chicken to be removed.
   */
  function removeChicken(uint256 _tokenId) external onlyManager chickenExists(_tokenId) {
    delete chickens[_tokenId];
    delete feedingSchedules[_tokenId];
    unchecked {
      --totalChickens;
    }
    emit ChickenRemoved(_tokenId);
  }

  /**
   * @notice Gets the data of a chicken.
   * @param _tokenId The ID of the chicken.
   * @return The chicken data.
   */
  function getChicken(uint256 _tokenId) public view chickenExists(_tokenId) returns (Chicken memory) {
    return chickens[_tokenId];
  }

  /**
   * @notice Fetches a paginated list of chickens.
   * @param startIndex The index to start the query from.
   * @param count The number of chickens to query in this call.
   * @return A paginated array of Chicken structs.
   */
  function getChickensBatch(uint256 startIndex, uint256 count) external view returns (Chicken[] memory) {
    uint256 endIndex = startIndex + count;
    if (endIndex > totalChickens) {
      endIndex = totalChickens;
    }

    uint256 resultCount = endIndex - startIndex;
    Chicken[] memory chickensList = new Chicken[](resultCount);

    for (uint256 i = 0; i < resultCount; i++) {
      chickensList[i] = chickens[startIndex + i];
    }

    return chickensList;
  }

  /**
   * @notice Gets the data of chickens with specific IDs.
   * @param _tokenIds An array of chicken IDs.
   * @return An array of chicken data.
   */
  function getChickensByIds(uint256[] calldata _tokenIds) external view returns (Chicken[] memory) {
    uint256 length = _tokenIds.length;
    Chicken[] memory result = new Chicken[](length);

    uint256 count;
    for (uint256 i = 0; i < length; ) {
      Chicken storage chicken = chickens[_tokenIds[i]];
      if (chicken.spotPrice != 0) {
        result[count] = chicken;
        count++;
      }
      unchecked {
        ++i;
      } // Use unchecked for gas optimization
    }

    // Adjust the size of the result array to include only existing chickens
    assembly {
      mstore(result, count)
    }

    return result;
  }

  function getOwnedChickens(address _owner) external view returns (uint256[] memory) {
    return ownedChickens[_owner];
  }

  /**
   * @notice Gets the creation time and last update time of a chicken.
   * @param _tokenId The ID of the chicken.
   * @return hatchTimestamp The creation time of the chicken.
   * @return lastUpdateTime The last update time of the chicken.
   */
  function getChickenHistory(uint256 _tokenId) external view chickenExists(_tokenId) returns (uint256 hatchTimestamp, uint256 lastUpdateTime) {
    Chicken storage chicken = chickens[_tokenId];
    return (chicken.hatchTimestamp, chicken.lastUpdateTime);
  }

  /**
   * @notice Gets the feeding schedule of a chicken.
   * @param _tokenId The ID of the chicken.
   * @return An array of feeding schedules.
   */
  function getFeedingSchedule(uint256 _tokenId) public view chickenExists(_tokenId) returns (FeedingSchedule[] memory) {
    return feedingSchedules[_tokenId];
  }

  /**
   * @dev Retrieves the feeding schedules for a batch of token IDs.
   * @param tokenIds An array of token IDs for which to retrieve the feeding schedules.
   * @return An array of arrays representing the feeding schedules for each token ID.
   */
  function getBatchFeedingSchedules(uint256[] memory tokenIds) public view returns (FeedingSchedule[][] memory) {
    FeedingSchedule[][] memory schedules = new FeedingSchedule[][](tokenIds.length);

    for (uint256 i = 0; i < tokenIds.length; i++) {
      schedules[i] = feedingSchedules[tokenIds[i]];
    }

    return schedules;
  }

  /**
   * @notice Updates the feeding schedule of a chicken.
   * @dev Only callable by a manager.
   * @param _tokenId The ID of the chicken.
   * @param _newSchedules The updated feeding schedule.
   */
  function updateFeedingSchedule(
    uint256 _tokenId,
    FeedingSchedule[] calldata _newSchedules
  ) external onlyManager chickenExists(_tokenId) validFeedingSchedule(_newSchedules) {
    delete feedingSchedules[_tokenId];

    FeedingSchedule[] storage schedules = feedingSchedules[_tokenId];
    uint256 length = _newSchedules.length;

    for (uint256 i = 0; i < length; ) {
      schedules.push(_newSchedules[i]);
      unchecked {
        ++i;
      }
    }

    emit ChickenUpdated(_tokenId);
  }

  /**
   * @notice Adds a new feeding schedule for a chicken.
   * @param _tokenId The ID of the chicken.
   * @param feedingSchedule The feeding schedule to be added.
   */
  function addFeedingSchedule(uint256 _tokenId, FeedingSchedule calldata feedingSchedule) external onlyManager {
    if (feedingSchedule.dueOn <= block.timestamp) revert InvalidFeedingSchedule();

    feedingSchedules[_tokenId].push(feedingSchedule);
  }

  /**
   * @notice Updates multiple chickens in a batch.
   * @dev Only callable by a manager.
   * @param _updatedChickens An array of updated chicken data.
   * @param _feedingSchedules An array of feed data for the current batch.
   */
  function batchUpdateChickens(Chicken[] calldata _updatedChickens, FeedingSchedule[][] calldata _feedingSchedules) external onlyManager {
    uint256 length = _updatedChickens.length;
    if (length != _feedingSchedules.length) revert InputArraysLengthMismatch();

    for (uint256 i = 0; i < length; ) {
      Chicken calldata updatedChicken = _updatedChickens[i];
      uint256 tokenId = updatedChicken.tokenId;
      if (chickens[tokenId].strikePrice == 0) revert ChickenDoesNotExist();
      chickens[tokenId] = updatedChicken;

      delete feedingSchedules[tokenId];
      FeedingSchedule[] calldata schedules = _feedingSchedules[i];
      for (uint256 j = 0; j < schedules.length; ) {
        feedingSchedules[tokenId].push(schedules[j]);
        unchecked {
          ++j;
        }
      }
      emit ChickenUpdated(tokenId);
      unchecked {
        ++i;
      }
    }
  }

  /**
   * @notice Settles multiple chickens in a batch.
   * @dev Only callable by a manager.
   * @param _tokenIds An array of chicken IDs.
   * @param _settlements An array of settlement values.
   */
  function batchChickenSettlement(uint256[] calldata _tokenIds, uint256[] calldata _settlements) external onlyManager {
    uint256 length = _tokenIds.length;
    if (length != _settlements.length) revert InputArraysLengthMismatch();

    for (uint256 i = 0; i < length; ) {
      Chicken storage chicken = chickens[_tokenIds[i]];
      chicken.settled = true;
      chicken.valuation = _settlements[i];
      chicken.lastUpdateTime = block.timestamp;
      emit ChickenUpdated(_tokenIds[i]);
      unchecked {
        ++i;
      }
    }
  }

  /**
   * @notice Evaluates multiple chickens in a batch.
   * @param _tokenIds An array of chicken IDs.
   * @param _valuations An array of valuation values.
   */
  function batchChickenEvaluation(uint256[] calldata _tokenIds, uint256[] calldata _valuations) external onlyManager {
    uint256 length = _tokenIds.length;
    if (length != _valuations.length) revert InputArraysLengthMismatch();

    for (uint256 i = 0; i < length; ) {
      Chicken storage chicken = chickens[_tokenIds[i]];
      chicken.spotPrice = _valuations[i];
      chicken.lastUpdateTime = block.timestamp;
      emit ChickenUpdated(_tokenIds[i]);
      unchecked {
        ++i;
      }
    }
  }

  /**
   * @notice Adds multiple chickens in a batch.
   * @dev Only callable by a manager.
   * @param _newChickens An array of new chicken data.
   * @param _feedingSchedules An array of feed data for the current batch.
   */
  function addBatchChickens(Chicken[] calldata _newChickens, FeedingSchedule[][] calldata _feedingSchedules) external onlyManager {
    if (_newChickens.length != _feedingSchedules.length) revert InputArraysLengthMismatch();

    for (uint256 i = 0; i < _newChickens.length; ) {
      uint256 newChickenId = _newChickens[i].tokenId;
      if (chickens[newChickenId].strikePrice != 0) revert ChickenAlreadyExists();

      chickens[newChickenId] = _newChickens[i];
      chickens[newChickenId].hatchTimestamp = uint64(block.timestamp);
      chickens[newChickenId].lastUpdateTime = uint64(block.timestamp);

      for (uint256 j = 0; j < _feedingSchedules[i].length; ) {
        feedingSchedules[newChickenId].push(_feedingSchedules[i][j]);
        unchecked {
          ++j;
        }
      }

      unchecked {
        ++totalChickens;
      }
      emit ChickenAdded(newChickenId, _newChickens[i].creator);
      unchecked {
        ++i;
      }
    }
  }

  /**
   * @notice Returns the total number of chickens.
   * @return The total number of chickens as a uint256 value.
   */
  function getTotalChickens() external view returns (uint256) {
    return totalChickens;
  }

  /**
   * @notice Adds a new manager.
   * @dev Only callable by an admin.
   * @param _newManager The address of the new manager.
   */
  function addManager(address _newManager) external onlyRole(DEFAULT_ADMIN_ROLE) {
    grantRole(MANAGER_ROLE, _newManager);
  }

  /**
   * @notice Removes a manager.
   * @dev Only callable by an admin.
   * @param _manager The address of the manager to be removed.
   */
  function removeManager(address _manager) external onlyRole(DEFAULT_ADMIN_ROLE) {
    revokeRole(MANAGER_ROLE, _manager);
  }
}
合同源代码
文件 3 的 6:Context.sol
// 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;
    }
}
合同源代码
文件 4 的 6:ERC165.sol
// 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;
    }
}
合同源代码
文件 5 的 6:IAccessControl.sol
// 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;
}
合同源代码
文件 6 的 6:IERC165.sol
// 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);
}
设置
{
  "compilationTarget": {
    "contracts/ChickenData.sol": "ChickenData"
  },
  "evmVersion": "paris",
  "libraries": {},
  "metadata": {
    "bytecodeHash": "ipfs"
  },
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "remappings": []
}
ABI
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AccessControlBadConfirmation","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bytes32","name":"neededRole","type":"bytes32"}],"name":"AccessControlUnauthorizedAccount","type":"error"},{"inputs":[],"name":"CallerNotManager","type":"error"},{"inputs":[],"name":"ChickenAlreadyExists","type":"error"},{"inputs":[],"name":"ChickenDoesNotExist","type":"error"},{"inputs":[],"name":"InputArraysLengthMismatch","type":"error"},{"inputs":[],"name":"InvalidFeedingSchedule","type":"error"},{"inputs":[],"name":"InvalidRecipientAddress","type":"error"},{"inputs":[],"name":"NotChickenOwner","type":"error"},{"anonymous":false,"inputs":[],"name":"AllChickensReplaced","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"chickenId","type":"uint256"},{"indexed":true,"internalType":"address","name":"creator","type":"address"}],"name":"ChickenAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"chickenId","type":"uint256"}],"name":"ChickenRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"chickenId","type":"uint256"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"}],"name":"ChickenTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"chickenId","type":"uint256"}],"name":"ChickenUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MANAGER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"creator","type":"address"},{"internalType":"enum ChickenData.Asset","name":"asset","type":"uint8"},{"internalType":"uint256","name":"spotPrice","type":"uint256"},{"internalType":"uint256","name":"strikePrice","type":"uint256"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"size","type":"uint256"},{"internalType":"uint256","name":"upfrontPayment","type":"uint256"},{"internalType":"uint256[]","name":"commissionSchedule","type":"uint256[]"},{"internalType":"enum ChickenData.OptionSide","name":"side","type":"uint8"},{"internalType":"uint256","name":"maturityTimestamp","type":"uint256"},{"internalType":"uint256","name":"lastFeedTime","type":"uint256"},{"internalType":"uint256","name":"valuation","type":"uint256"},{"internalType":"bool","name":"isClaimed","type":"bool"},{"internalType":"uint256","name":"totalFeeds","type":"uint256"},{"internalType":"uint256","name":"hatchTimestamp","type":"uint256"},{"internalType":"uint256","name":"lastUpdateTime","type":"uint256"},{"internalType":"enum ChickenData.FeedCurrency","name":"feedCurrency","type":"uint8"},{"internalType":"address","name":"issuer","type":"address"},{"internalType":"bool","name":"settled","type":"bool"}],"internalType":"struct ChickenData.Chicken[]","name":"_newChickens","type":"tuple[]"},{"components":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"dueOn","type":"uint256"},{"internalType":"bool","name":"fed","type":"bool"}],"internalType":"struct ChickenData.FeedingSchedule[][]","name":"_feedingSchedules","type":"tuple[][]"}],"name":"addBatchChickens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"creator","type":"address"},{"internalType":"enum ChickenData.Asset","name":"asset","type":"uint8"},{"internalType":"uint256","name":"spotPrice","type":"uint256"},{"internalType":"uint256","name":"strikePrice","type":"uint256"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"size","type":"uint256"},{"internalType":"uint256","name":"upfrontPayment","type":"uint256"},{"internalType":"uint256[]","name":"commissionSchedule","type":"uint256[]"},{"internalType":"enum ChickenData.OptionSide","name":"side","type":"uint8"},{"internalType":"uint256","name":"maturityTimestamp","type":"uint256"},{"internalType":"uint256","name":"lastFeedTime","type":"uint256"},{"internalType":"uint256","name":"valuation","type":"uint256"},{"internalType":"bool","name":"isClaimed","type":"bool"},{"internalType":"uint256","name":"totalFeeds","type":"uint256"},{"internalType":"uint256","name":"hatchTimestamp","type":"uint256"},{"internalType":"uint256","name":"lastUpdateTime","type":"uint256"},{"internalType":"enum ChickenData.FeedCurrency","name":"feedCurrency","type":"uint8"},{"internalType":"address","name":"issuer","type":"address"},{"internalType":"bool","name":"settled","type":"bool"}],"internalType":"struct ChickenData.Chicken","name":"_chicken","type":"tuple"}],"name":"addChicken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"components":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"dueOn","type":"uint256"},{"internalType":"bool","name":"fed","type":"bool"}],"internalType":"struct ChickenData.FeedingSchedule","name":"feedingSchedule","type":"tuple"}],"name":"addFeedingSchedule","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newManager","type":"address"}],"name":"addManager","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_tokenIds","type":"uint256[]"},{"internalType":"uint256[]","name":"_valuations","type":"uint256[]"}],"name":"batchChickenEvaluation","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_tokenIds","type":"uint256[]"},{"internalType":"uint256[]","name":"_settlements","type":"uint256[]"}],"name":"batchChickenSettlement","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"creator","type":"address"},{"internalType":"enum ChickenData.Asset","name":"asset","type":"uint8"},{"internalType":"uint256","name":"spotPrice","type":"uint256"},{"internalType":"uint256","name":"strikePrice","type":"uint256"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"size","type":"uint256"},{"internalType":"uint256","name":"upfrontPayment","type":"uint256"},{"internalType":"uint256[]","name":"commissionSchedule","type":"uint256[]"},{"internalType":"enum ChickenData.OptionSide","name":"side","type":"uint8"},{"internalType":"uint256","name":"maturityTimestamp","type":"uint256"},{"internalType":"uint256","name":"lastFeedTime","type":"uint256"},{"internalType":"uint256","name":"valuation","type":"uint256"},{"internalType":"bool","name":"isClaimed","type":"bool"},{"internalType":"uint256","name":"totalFeeds","type":"uint256"},{"internalType":"uint256","name":"hatchTimestamp","type":"uint256"},{"internalType":"uint256","name":"lastUpdateTime","type":"uint256"},{"internalType":"enum ChickenData.FeedCurrency","name":"feedCurrency","type":"uint8"},{"internalType":"address","name":"issuer","type":"address"},{"internalType":"bool","name":"settled","type":"bool"}],"internalType":"struct ChickenData.Chicken[]","name":"_updatedChickens","type":"tuple[]"},{"components":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"dueOn","type":"uint256"},{"internalType":"bool","name":"fed","type":"bool"}],"internalType":"struct ChickenData.FeedingSchedule[][]","name":"_feedingSchedules","type":"tuple[][]"}],"name":"batchUpdateChickens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"feedingSchedules","outputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"dueOn","type":"uint256"},{"internalType":"bool","name":"fed","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"}],"name":"getBatchFeedingSchedules","outputs":[{"components":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"dueOn","type":"uint256"},{"internalType":"bool","name":"fed","type":"bool"}],"internalType":"struct ChickenData.FeedingSchedule[][]","name":"","type":"tuple[][]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"getChicken","outputs":[{"components":[{"internalType":"address","name":"creator","type":"address"},{"internalType":"enum ChickenData.Asset","name":"asset","type":"uint8"},{"internalType":"uint256","name":"spotPrice","type":"uint256"},{"internalType":"uint256","name":"strikePrice","type":"uint256"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"size","type":"uint256"},{"internalType":"uint256","name":"upfrontPayment","type":"uint256"},{"internalType":"uint256[]","name":"commissionSchedule","type":"uint256[]"},{"internalType":"enum ChickenData.OptionSide","name":"side","type":"uint8"},{"internalType":"uint256","name":"maturityTimestamp","type":"uint256"},{"internalType":"uint256","name":"lastFeedTime","type":"uint256"},{"internalType":"uint256","name":"valuation","type":"uint256"},{"internalType":"bool","name":"isClaimed","type":"bool"},{"internalType":"uint256","name":"totalFeeds","type":"uint256"},{"internalType":"uint256","name":"hatchTimestamp","type":"uint256"},{"internalType":"uint256","name":"lastUpdateTime","type":"uint256"},{"internalType":"enum ChickenData.FeedCurrency","name":"feedCurrency","type":"uint8"},{"internalType":"address","name":"issuer","type":"address"},{"internalType":"bool","name":"settled","type":"bool"}],"internalType":"struct ChickenData.Chicken","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"getChickenHistory","outputs":[{"internalType":"uint256","name":"hatchTimestamp","type":"uint256"},{"internalType":"uint256","name":"lastUpdateTime","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"startIndex","type":"uint256"},{"internalType":"uint256","name":"count","type":"uint256"}],"name":"getChickensBatch","outputs":[{"components":[{"internalType":"address","name":"creator","type":"address"},{"internalType":"enum ChickenData.Asset","name":"asset","type":"uint8"},{"internalType":"uint256","name":"spotPrice","type":"uint256"},{"internalType":"uint256","name":"strikePrice","type":"uint256"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"size","type":"uint256"},{"internalType":"uint256","name":"upfrontPayment","type":"uint256"},{"internalType":"uint256[]","name":"commissionSchedule","type":"uint256[]"},{"internalType":"enum ChickenData.OptionSide","name":"side","type":"uint8"},{"internalType":"uint256","name":"maturityTimestamp","type":"uint256"},{"internalType":"uint256","name":"lastFeedTime","type":"uint256"},{"internalType":"uint256","name":"valuation","type":"uint256"},{"internalType":"bool","name":"isClaimed","type":"bool"},{"internalType":"uint256","name":"totalFeeds","type":"uint256"},{"internalType":"uint256","name":"hatchTimestamp","type":"uint256"},{"internalType":"uint256","name":"lastUpdateTime","type":"uint256"},{"internalType":"enum ChickenData.FeedCurrency","name":"feedCurrency","type":"uint8"},{"internalType":"address","name":"issuer","type":"address"},{"internalType":"bool","name":"settled","type":"bool"}],"internalType":"struct ChickenData.Chicken[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_tokenIds","type":"uint256[]"}],"name":"getChickensByIds","outputs":[{"components":[{"internalType":"address","name":"creator","type":"address"},{"internalType":"enum ChickenData.Asset","name":"asset","type":"uint8"},{"internalType":"uint256","name":"spotPrice","type":"uint256"},{"internalType":"uint256","name":"strikePrice","type":"uint256"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"size","type":"uint256"},{"internalType":"uint256","name":"upfrontPayment","type":"uint256"},{"internalType":"uint256[]","name":"commissionSchedule","type":"uint256[]"},{"internalType":"enum ChickenData.OptionSide","name":"side","type":"uint8"},{"internalType":"uint256","name":"maturityTimestamp","type":"uint256"},{"internalType":"uint256","name":"lastFeedTime","type":"uint256"},{"internalType":"uint256","name":"valuation","type":"uint256"},{"internalType":"bool","name":"isClaimed","type":"bool"},{"internalType":"uint256","name":"totalFeeds","type":"uint256"},{"internalType":"uint256","name":"hatchTimestamp","type":"uint256"},{"internalType":"uint256","name":"lastUpdateTime","type":"uint256"},{"internalType":"enum ChickenData.FeedCurrency","name":"feedCurrency","type":"uint8"},{"internalType":"address","name":"issuer","type":"address"},{"internalType":"bool","name":"settled","type":"bool"}],"internalType":"struct ChickenData.Chicken[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"getFeedingSchedule","outputs":[{"components":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"dueOn","type":"uint256"},{"internalType":"bool","name":"fed","type":"bool"}],"internalType":"struct ChickenData.FeedingSchedule[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"getOwnedChickens","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getTotalChickens","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"removeChicken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_manager","type":"address"}],"name":"removeManager","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"callerConfirmation","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"components":[{"internalType":"address","name":"creator","type":"address"},{"internalType":"enum ChickenData.Asset","name":"asset","type":"uint8"},{"internalType":"uint256","name":"spotPrice","type":"uint256"},{"internalType":"uint256","name":"strikePrice","type":"uint256"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"size","type":"uint256"},{"internalType":"uint256","name":"upfrontPayment","type":"uint256"},{"internalType":"uint256[]","name":"commissionSchedule","type":"uint256[]"},{"internalType":"enum ChickenData.OptionSide","name":"side","type":"uint8"},{"internalType":"uint256","name":"maturityTimestamp","type":"uint256"},{"internalType":"uint256","name":"lastFeedTime","type":"uint256"},{"internalType":"uint256","name":"valuation","type":"uint256"},{"internalType":"bool","name":"isClaimed","type":"bool"},{"internalType":"uint256","name":"totalFeeds","type":"uint256"},{"internalType":"uint256","name":"hatchTimestamp","type":"uint256"},{"internalType":"uint256","name":"lastUpdateTime","type":"uint256"},{"internalType":"enum ChickenData.FeedCurrency","name":"feedCurrency","type":"uint8"},{"internalType":"address","name":"issuer","type":"address"},{"internalType":"bool","name":"settled","type":"bool"}],"internalType":"struct ChickenData.Chicken","name":"_updatedChicken","type":"tuple"}],"name":"updateChicken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"components":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"dueOn","type":"uint256"},{"internalType":"bool","name":"fed","type":"bool"}],"internalType":"struct ChickenData.FeedingSchedule[]","name":"_newSchedules","type":"tuple[]"}],"name":"updateFeedingSchedule","outputs":[],"stateMutability":"nonpayable","type":"function"}]