Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

ObjectMinterHook

Git Source

Inherits: IObjectMinterHook

Title: ObjectMinterHook

Base contract for integrating with an external ObjectMinter.

Implements the IObjectMinterHook interface and enforces that only the configured ObjectMinter can trigger the minting logic. Inheriting contracts must implement _mint(...).

Functions

_ObjectMinterHook_initialize

function _ObjectMinterHook_initialize(address objectMinter) internal;

onlyObjectMinter

Restricts function to be called only by the configured ObjectMinter.

modifier onlyObjectMinter() ;

onObjectMint

Called by ObjectMinter after payment is collected and before minting is finalized

  • If id0 is 0, the contract must assign and return a new object ID.
  • If id0 is non-zero, the contract must validate and return the same ID. The call must return onObjectMint.selector to signal success.
function onObjectMint(address operator, address to, uint64 id0, uint256 context, bytes memory data)
    external
    override
    onlyObjectMinter
    returns (bytes4 supported, uint64 id);

Parameters

NameTypeDescription
operatoraddressCaller who initiated the mint (typically msg.sender)
toaddressRecipient of the minted object
id0uint64Requested object ID (0 = auto-assign)
contextuint256Packed 256-bit context for custom mint logic (see MintingContext)
databytesArbitrary input payload for extensible logic

Returns

NameTypeDescription
supportedbytes4selector Must return onObjectMint.selector to proceed
iduint64Final resolved object ID to be minted

supportsInterface

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 pure virtual override returns (bool supported);

_onlyObjectMinter

function _onlyObjectMinter() internal view;

_ObjectMinterHook_supportsInterface

function _ObjectMinterHook_supportsInterface(bytes4 interfaceId) internal pure returns (bool supported);

_mint

Performs the actual minting logic.

Must be implemented by the inheriting contract. The function should resolve and return a valid object ID.

function _mint(address operator, address to, uint64 id0, uint256 context, bytes memory data)
    internal
    virtual
    returns (uint64 id);

Parameters

NameTypeDescription
operatoraddressThe address that initiated the mint (typically msg.sender).
toaddressThe recipient address of the newly minted object.
id0uint64Requested object ID (0 = assign automatically).
contextuint256Packed context data for the minting operation.
databytesArbitrary user-defined input passed through the mint call.

Returns

NameTypeDescription
iduint64The resolved and finalized object ID to be minted.

Errors

NotObjectMinter

error NotObjectMinter();