Hello people.
I suddenly have a problem when executing functions with “Moralis.executeFunction(options)”.
I always get the message “tx.on is not a function”.
It used to work. Do you have any idea what the problem could be? I am at my wit’s end.
Code snippet:
<script src="https://unpkg.com/moralis/dist/moralis.js"></script>
<script type="text/javascript">
async function EnableVoting() {
const VotingABI = 'xxx'; //removed
const VotingContract = 'xxx'; //removed
const serverUrl = "xxx"; //removed
const appId = "xxx"; //removed
await Moralis.start({ serverUrl, appId });
const web3 = await Moralis.enableWeb3();
const options = {
contractAddress: VotingContract,
functionName: "EnableVoting",
abi: VotingABI,
msgValue: Moralis.Units.ETH("0"),
awaitReceipt: false // should be switched to false
};
const tx = await Moralis.executeFunction(options);
tx.on("transactionHash", (hash) => { console.log(hash); })
.on("receipt", (receipt) => { console.log(receipt); })
.on("confirmation", (confirmationNumber, receipt) => { console.log(confirmationNumber); })
.on("error", (error) => { console.log(error); });
}
</script>
The transaction in MetaMask goes through without any problems, but as soon as the transaction is started, the error message “tx.on is not a function” appears.