ObjectMinterHook
Inherits: IObjectMinterHook
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
constructor
Initializes the contract with the configured ObjectMinter address.
constructor(address minter);
Parameters
Name | Type | Description |
---|---|---|
minter | address | The address of the ObjectMinter. |
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 returnonObjectMint.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
Name | Type | Description |
---|---|---|
operator | address | Caller who initiated the mint (typically msg.sender) |
to | address | Recipient of the minted object |
id0 | uint64 | Requested object ID (0 = auto-assign) |
context | uint256 | Packed 256-bit context for custom mint logic (see MintingContext) |
data | bytes | Arbitrary input payload for extensible logic |
Returns
Name | Type | Description |
---|---|---|
supported | bytes4 | selector Must return onObjectMint.selector to proceed |
id | uint64 | Final 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);
_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
Name | Type | Description |
---|---|---|
operator | address | The address that initiated the mint (typically msg.sender). |
to | address | The recipient address of the newly minted object. |
id0 | uint64 | Requested object ID (0 = assign automatically). |
context | uint256 | Packed context data for the minting operation. |
data | bytes | Arbitrary user-defined input passed through the mint call. |
Returns
Name | Type | Description |
---|---|---|
id | uint64 | The resolved and finalized object ID to be minted. |
Errors
CallerNotObjectMinter
error CallerNotObjectMinter();