# Mint Permissions

## Implementations

Basic implementations (ERC721 and ERC1155) of a Mint Permissions contract that works with a singular creator contract are shown below. Note the approveMint function requires the sender to be the configured creator.

### ERC721

```solidity
abstract contract ERC721CreatorMintPermissions is ERC165, AdminControl, IERC721CreatorMintPermissions {
     address internal immutable _creator;

     constructor(address creator_) {
         require(ERC165Checker.supportsInterface(creator_, type(IERC721CreatorCore).interfaceId), "Must implement IERC721CreatorCore");
         _creator = creator_;
     }

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165, AdminControl) returns (bool) {
        return interfaceId == type(IERC721CreatorMintPermissions).interfaceId
            || super.supportsInterface(interfaceId);
    }

    /**
     * @dev See {IERC721CreatorMintPermissions-approve}.
     */
    function approveMint(address, address, uint256) public virtual override {
        require(msg.sender == _creator, "Can only be called by token creator");
    }
}
```

### ERC155

```solidity
abstract contract ERC1155CreatorMintPermissions is ERC165, AdminControl, IERC1155CreatorMintPermissions {
     address internal immutable _creator;

     constructor(address creator_) {
         require(ERC165Checker.supportsInterface(creator_, type(IERC1155CreatorCore).interfaceId), "Must implement IERC1155CreatorCore");
         _creator = creator_;
     }

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165, AdminControl) returns (bool) {
        return interfaceId == type(IERC1155CreatorMintPermissions).interfaceId
            || super.supportsInterface(interfaceId);
    }

    /**
     * @dev See {IERC1155CreatorMintPermissions-approve}.
     */
    function approveMint(address, address[] calldata, uint256[] calldata, uint256[] calldata)  public virtual override {
        require(msg.sender == _creator, "Can only be called by token creator");
    }
}
```

## Adding a Mint Permissions Contract

Adding a Mint Permissions contract is similar to registering an extension. Add a mint permissions contract by calling the `setMintPermissions` function and indicating the registered extension contract and mint permissions contract you wish to set.

For detailed Mint Permissions functions information see [Mint Permissions Functions](https://docs.manifold.xyz/manifold-for-developers/smart-contracts/manifold-creator/contracts/mint-permissions/mint-permissions-functions).
