How to define async
? I try to declare async = require('async')
and no success. Then I try on terminal: npm install async --save
and same thing without result.
async function donate() {
let options = {
contractAddress: "0x..",
functionName: "newDonation",
abi: [{ ....
}],
params: {
note: "Thanks from Mr. Popcorn!"
},
msgValue: Moralis.Units.ETH(0.2)
}
await Moralis.executionFunction(options);
}
async function login() {
let user = Moralis.User.current()
if (!user) {
try {
user = await Moralis.authenticate({
signingMessage: `
Authenticate to popcorn!
Please make sure to understand the terms.
`
})
await Moralis.enableWeb3()
console.log(user.get('ethAddress'))
document.getElementById("popcorn").innerHTML = `
<p>Wallet: ${user.get('ethAddress')}</p>
<p><button id="donate_btn" onclick=${donate}>Donate</button></p>
`;
} catch (error) {
console.log(error)
}
}
}
async function logOut() {
await Moralis.User.logOut()
console.log("Logged out!")
}
document.getElementById("login_btn").onclick = login;
document.getElementById("logout_btn").onclick = logOut;