Skip to main content

Collections — Admin mint

A solidity extension, React hooks and REST APIs to mint NFTs as an admin.

Relevant use-cases:

  • Gifting NFTs to anyone you want as an admin, without having to pay for the NFTs or waiting for public/sale period.
Require Extension

Features defined below require the ERC721OwnerMintExtension.sol Solidity extension, which is already included in ready-made presets.

Dashboard

For collections that have this extension, you will be able to mint NFTs directly from the dashboard.

You can go to Minting tab when visiting your collection in the dashboard to mint as an admin.

React Hooks

useAdminMinter

Mint NFTs as an admin either by being the owner of contract or having the "MINTER_ROLE".

Minter Role

You can assign the MINTER_ROLE to any address via Flair's collection dashboard, under "Roles" section of your collection management panel.

import { useAccount } from "wagmi";
import { useAdminMinter } from "flair-sdk";

const App = () => {
const { data: account } = useAccount();

const {
data,
error,
isLoading,
writeAndWait: mintOneOfOne,
} = useAdminMinter({
contractAddress: "0x6f90661e8e6133c64d8ec7859da8a8137ab67f01",
minterAddress: account?.address,
toAddress: "0xd56fbe3294ea4d73cca99ff8751ce7bd9b688cd5",
mintCount: 1,
});

return (
<>
<button onClick={() => mintOneOfOne()}>Mint a 1-of-1</button>
</>
);
};

Solidity extensions

ERC721OwnerMintExtension.sol

This extensions provides capability to mint 1-of-1 NFTs by owner of the collection, or any address you give the "MINTER_ROLE" to.

Features:

  • Mint 1 or more one of one NFTs by providing unique metadata URLs for each token.
  • Getting token URI for each minted token.
  • Uses ERC721PerTokenMetadataExtension (and OpenZeppelin's ERC721URIStorage) under the hood.

View the source code.