Hi all,
I’ve got a very simple login dapp working with Moralis right now. It’s able to authenticate via signature which is the goal, but I’m hoping to add another check (that checks if an NFT from a specific contract is present) in order for the signature to actually give access to the dapp.
/** Connect to Moralis server */
const serverUrl = "https://3blwn0stnuyh.usemoralis.com:2053/server";
const appId = "lxHqQdUecmP7HlR6LO3HN1EI9kCvti2zfC4velJC";
Moralis.start({ serverUrl, appId });
/** Add from here down */
async function login() {
new web3.eth.Contract["./abi.json", "0x...")
const tokenOwner = await tokenContract.methods.ownerOf(tokenId).call()
const hasToken = address === tokenOwner
let user = Moralis.User.current();
if (!user) {
try {
user = await Moralis.authenticate({ signingMessage: "Hello World!" })
console.log(user)
console.log(user.get('ethAddress'))
} catch (error) {
console.log(error)
}
}
}
async function logOut() {
await Moralis.User.logOut();
console.log("logged out");
}
these lines of code
new web3.eth.Contract["./abi.json", "0x1D0513111B51Fe8E3d6dFcE7d63971B6b06Df04f")
const tokenOwner = await tokenContract.methods.ownerOf(tokenId).call()
const hasToken = address === tokenOwner
cause this error in html
Without those lines of code the sign function works and metamask behaves accordingly. The goal is to have our dapp check the wallet for a specific token via the contract object.
Any ideas?