Last active
April 5, 2022 17:25
-
-
Save polluterofminds/9e8514c965ab5651613621ac86e681a1 to your computer and use it in GitHub Desktop.
Members Only Step 6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const validateNFTOwnership = async (address) => { | |
try { | |
const { abi } = require("../../../helpers/erc721.js"); | |
const contractAddress = '0x_NFT_CONTRACT_ADDRESS_HERE' | |
const provider = await new ethers.providers.JsonRpcProvider(process.env.ALCHEMY_ENDPOINT); | |
const contract = await new ethers.Contract( contractAddress , abi() , provider ); | |
const balance = await contract.balanceOf(address); | |
if(balance.toString() !== "0") { | |
return true; | |
} | |
return false; | |
} catch (error) { | |
console.log(error); | |
return null; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment