Lazy Mint Extension ERC721
Intro
Another common ask is how to do lazy-minting with Manifold. If you're unfamiliar, lazy-minting is a technique by which minting costs are passed on to the buyer. This makes sense in many situations (especially collectible-style projects), but does not make sense in others. We'll take a look at the contract and how to deploy it here, but I would not suggest doing this for collections of less than, say, 20 tokens. The reason for this is that deploying an extension costs gas! And on a smaller scale, the savings from lazy-minting are less than the cost to deploy the contract.
Anyway, let's take a look. We'll do this with a contract that mints ERC721 tokens to your base contract.
Contract
Let's walk through the contract here before we think about deploying it.
The first function we have there is the constructor
and this is called when we deploy the contract. At the time of deployment we must pass in the _creator
(the address of your creator core contract). We have that so we can interact with it later when minting.
The supportsInterface
function simply tells other contracts that are calling this one what functions it supports.
The mint
function is where we allow other people to mint more tokens on this contract. You can see that it is pretty simple, it really just calls the mintExtension
function to mint a token to the person who sent the transaction. Note that we do not specify a tokenURI here. This is because the core contract will hook back into this contracts tokenURI
function later to get the URI.
The setBaseURI
function lets us set the base for the tokenURI we want to return. It also lets us update this information at any time in the future.
The tokenURI
function returns the base tokenURI concatenated with the tokenId. So in this case if your base tokenURI is https://arweave.net/abcd/
this will return https://arweave.net/abcd/1
for tokenId 1.
How to Deploy
Deploy core contract (using Manifold Studio is easiest) - example here
Deploy the extension contract - example here
Register the extension with #14
registerExtension
on your base contract - example hereSet the baseURI for your extension - example here
Mint - example here
Mint again - example here
You should be able to see your tokens on OpenSea TestNet. Here is the first of mine:
https://testnets.opensea.io/assets/0xe2c146396a37883ebd85b74f38e985e8d1ffc4f2/1
And here is the second
https://testnets.opensea.io/assets/0xe2c146396a37883ebd85b74f38e985e8d1ffc4f2/2
As you can see, these are token #1 and token #2 on the core contract. Notice the OpenSea URL which has the address of the core contract.
Congrats! You are done.
FAQ
Is this contract an EC721 contract?
No - but it helps you mint tokens on an ERC721 contract (your core contract)
What is the gas cost for deploying an extension like this?
This particular extension cost me 1,833,652 gas to deploy. At gas prices of 40 gwei, that would be about 0.07 ETH.
Last updated