Payment Status
userPaymentStatus
is used to check the status of the user's account, whether the user has a maxed limit or is he eligible to pay to buy more or not, etc.
- It takes parameters like
web3
which is a provider which is returned from the signIn hook when the user is logged in,COLLECTION_ID
is the id of the collection created, anduserEmail
is the user's email address. It returns the following methods.
checkIfUserCanPay method
checkIfUserCanPay
takesaccountAddress
and returns auserCanBuy
flag if the user is allowed to mint new nft,totalSupply
gives the total supply of available NFTs,tokenMintedIsLoading
flag is used to indicate the loading status.totalSupplyIsLoading
Flag to indicate whether the total supply has been loaded or not,alreadyMinedError
outputs an error message if the token has already been minted,totalSupplyError
outputs an error if an error occurs in total supply fetching.
isPublicSaleOn method
isPublicSaleOn
method is used for checking if the public sale is on or not, it returns a boolean value accordingly and takesreleaseData
as parameters.
isWhiteListed method
isWhiteListed
takes the parameter releaseData
and returns a boolean if the user is whitelisted or not.
isContractDeployed method
isContractDeployed
takes the parameter releaseData
and returns the status whether the contract has already been deployed or not.
import React from "react";
import { MetastaqInstance } from "./MetastaqInstance";
export const ShowPaymentStatus = () => {
const { userPaymentStatus } = MetastaqInstance;
const {
checkIfUserCanPay,
isPublicSaleOn,
isWhiteListed,
isContractDeployed,
} = userPaymentStatus(web3, COLLECTION_ID, userEmail);
const {
userCanBuy,
totalSupply,
tokenMintedIsLoading,
totalSupplyIsLoading,
alreadyMintedError,
totalSupplyError,
} = checkIfUserCanPay(accountAddress);
const isPublicSale = isPublicSaleOn(releaseData);
const isWhiteListed = isWhiteListed(releaseData);
const isContractDeployed = isContractDeployed(releaseData);
return <div>{userCanBuy ? "User can buy" : "User cannot buy"}</div>;
};