I am trying to get the NFT details (number or NFTs, purchased date) of those that are purchased by the logged in user from the site owner. I got the result, but I doubt whether my logic is correct. Here is the code.
NFT purchased date is used for some bonus calculation.
Is block_timestamp is the NFT purchased date?
const loged_user_eth_addresss = user.get('ethAddress');
const site_owner_eth_address = '0x3f8f07823e20da54bae50023667c1674d45df834'
const options = { chain: 'eth', address: site_owner_eth_address };
async function getNFTCount(options) {
// get NFTs transfer details
const transfersNFT = await Moralis.Web3API.account.getNFTTransfers(options);
const nft_transfers = transfersNFT.result;
// get only those nft details purchased by loged in user from the site owner
const nfts = nft_transfers.filter(nft_transfer => nft_transfer.to_address == loged_user_eth_addresss);
setNftCount(nfts.length);
// calculate total venom points based on transaction date
let venom_points = 0;
nfts.forEach(async function (nft) {
venom_points += getVenomPoints(nft.block_timestamp);
});
venom_points = Math.round(venom_points);
setVenomPoints(venom_points);
}//endof getNFTs()