For John
async function handleAuth(provider) {
await Moralis.enableWeb3({
throwOnError: true,
provider,
});
const { account, chainId } = Moralis;
if (!account) {
throw new Error(
"Connecting to chain failed, as no connected account was found"
);
}
if (!chainId) {
throw new Error(
"Connecting to chain failed, as no connected chain was found"
);
}
const { message } = await Moralis.Cloud.run("requestMessage", {
address: account,
chain: parseInt(chainId, 16),
network: "evm",
});
return Moralis.authenticate({
signingMessage: message,
throwOnError: true,
});
}