Okay so I followed through all the videos, now I am back to building the frontend dapp to call a function of my contract. I saw in the Moralis docs and also another post in this forum that @Yoomoo recommended to use the Moralis.execute code.
Hereās the code I found in the docs:
const ABI = [
{
constant: true,
inputs: [
{
internalType: "address",
name: "owner",
type: "address"
},
{
internalType: "address",
name: "spender",
type: "address"
}
],
name: "allowance",
outputs: [
{
internalType: "uint256",
name: "",
type: "uint256"
}
],
payable: false,
stateMutability: "view",
type: "function"
}
];
const options = {
contractAddress: "0xe...56",
functionName: "allowance",
abi: ABI,
params: {
owner: "0x2...45",
spender: "0x3...49"
},
};
const allowance = await Moralis.executeFunction(options);
Since I have the abi of the contract code in another js file from when I followed the Serverless dapp videos, I modified the codes a little. Please take a look:
const claimRewards = {
contractAddress: "0xb48D1488266F636dB97597875dE305Bb981EC5a5",
functionName: "claimRewards",
abi: window.abi,
params: {
// I don't know what to set for params because the function is claimRewards.
// It simply calls the contract to send the rewards to the connected wallet.
}
};
const allowance = await Moralis.executeFunction(claimRewards);
Iād appreciate any help I can get with this!