useMintDrop
Hook for minting a drop, accessing the active process step as well as the transaction hash
Usage
import { MintDropStep, useMintDrop } from '@liteflow/react'
import { useMemo } from 'react'
import { publicActions } from 'viem'
import { useWalletClient } from 'wagmi'
export default function Component() {
const { data: walletClient } = useWalletClient()
const signer = useMemo(() => {
return walletClient?.extend(publicActions)
}, [walletClient])
const [mintDrop, { activeStep, transactionHash }] = useMintDrop(signer)
const handleClick = async () => {
await mintDrop(
'10d07af7-1fd1-433c-b92c-e4e5f86752cf', // the dropId of the drop to mint
5, // the quantity of the drop to mint
)
}
return (
<>
{activeStep === MintDropStep.INITIAL && (
<button onClick={handleClick}>Create NFT</button>
)}
{activeStep === MintDropStep.TRANSACTION_SIGNATURE && (
<p>Please sign transaction in wallet</p>
)}
{activeStep === MintDropStep.TRANSACTION_PENDING && (
<p>Transaction is pending</p>
)}
{activeStep === MintDropStep.OWNERSHIP && <p>Verifying ownership</p>}
{transactionHash && <p>Transaction hash is {transactionHash}</p>}
</>
)
}
Configuration
useMintDrop(
signer: Signer & TypedDataSigner, // Ethers signer: https://docs.ethers.io/v5/api/signer/
)
Return values
[
(
dropId: UUID // The dropId of the drop to mint
quantity: BigNumberish // The quantity of the drop to mint
) => Promise<{ chain: ChainId; collection: Address; token: string }[]>, // MintDrop function
{
activeStep: MintDropStep, // steps of the drop minting process
transactionHash: string | undefined // returns the transaction hash after transaction has been placed on the blockchain
}
]
mintDrop
Function to mint a drop that returns a promise that resolves to an array of objects containing the chain
, collection
, and token
of the minted asset.
Arguments:
{
dropId: UUID // The dropId of the drop to mint
quantity: BigNumberish // The quantity of the drop to mint
}
activeStep
The status of the transaction as an enum MintDropStep
executed in this order. Once the drop minting has been complete the state returns to MintDropStep.INITIAL
enum MintDropStep {
INITIAL, // Default
TRANSACTION_SIGNATURE, // Transaction has been initiated
TRANSACTION_PENDING, // Transaction is pending
OWNERSHIP, // Ownership is being verified
}
transactionHash
The hash of the blockchain transaction of the created NFT. This is only accessible after the approval of the transaction (after MintDropStep.TRANSACTION_SIGNATURE
)