Hook for minting an NFT with Financing
import { Offer, useMintWithFinancing } from '@niftyapes/sdk'
Usage
import React from "react";
import { Address, useWaitForTransaction } from "wagmi";
import { Offer, useMintWithFinancing, useOffers } from "@niftyapes/sdk";
const UseMintWithFinancing: React.FC = () => {
// Retrieve valid mint offers. For a given collection
const offer: Offer = useOffers({})[0];
const { data, write } = useMintWithFinancing({
erc721MintFinancingContractAddress:
"0xB2EG617B2fDc3a2996f1A5174CF8f1AaED466E82" as Address,
offer: offer,
numNftsToMint: 2,
});
const { isLoading, isSuccess, isError } = useWaitForTransaction({
hash: data?.hash,
});
return (
<div>
{isLoading && <div>Minting...</div>}
{isError && <div>Error Minting NFT</div>}
{isSuccess && <div>NFTs Minted successfully</div>}
<button disabled={!write} onClick={() => write?.()}>
Mint
</button>
</div>
);
};
export default UseMintWithFinancing;
Configuration
Requires a valid Offer, signature, as well as a valid ERC721 Mint Financing Integration Contract address.
{
erc721MintFinancingContractAddress: Address;
offer: Offer;
numNftsToMint: number;
}
Return Value
{
data?: TransactionResponse
error?: Error
isError: boolean
isIdle: boolean
isLoading: boolean
isSuccess: boolean
write: (() => void) | undefined
status: 'idle' | 'error' | 'loading' | 'success'
};