I tried a few times to paste codes directly into VS Code, but any time I do that, I get an error in the console
For example, I copied your code:
let contractAbi = [{"inputs":[],"name":"viewRewardsAndLiquidityInfo","outputs":[{"internalType":"uint256","name":"budsAccumulationFromRewardsFee","type":"uint256"},{"internalType":"uint256","name":"sumOfAllHOLDRBalances","type":"uint256"},{"internalType":"uint256","name":"theCurrentRewardsCycle","type":"uint256"},{"internalType":"uint256","name":"lengthOfRewardsCycle","type":"uint256"},{"internalType":"uint256","name":"budsAccumulationFromLiquidityFee","type":"uint256"},{"internalType":"uint256","name":"lastTimeDividendsWereReleased","type":"uint256"},{"internalType":"uint256","name":"dividendsClaimableNow","type":"uint256"},{"internalType":"uint256","name":"dividendsLeftFromReservedSupplyForHOLDRs","type":"uint256"}],"stateMutability":"view","type":"function"}];
const options = {
contractAddress: "0x058cdF0fF70f19629D4F50faC03610302e746e58",
functionName: "viewRewardsAndLiquidityInfo",
abi: contractAbi,
};
x = await Moralis.executeFunction(options)
Console error: Uncaught SyntaxError: await is only valid in async functions and the top level bodies of modules.
So then I tried to make it into an async function:
async function totalRewards(){
let contractAbi = [{"inputs":[],
"name":"viewRewardsAndLiquidityInfo",
"outputs":[
{"internalType":"uint256","name":"budsAccumulationFromRewardsFee","type":"uint256"},
{"internalType":"uint256","name":"sumOfAllHOLDRBalances","type":"uint256"},
{"internalType":"uint256","name":"theCurrentRewardsCycle","type":"uint256"},
{"internalType":"uint256","name":"lengthOfRewardsCycle","type":"uint256"},
{"internalType":"uint256","name":"budsAccumulationFromLiquidityFee","type":"uint256"},
{"internalType":"uint256","name":"lastTimeDividendsWereReleased","type":"uint256"},
{"internalType":"uint256","name":"dividendsClaimableNow","type":"uint256"},
{"internalType":"uint256","name":"dividendsLeftFromReservedSupplyForHOLDRs","type":"uint256"}
],"stateMutability":"view","type":"function"}];
const options = {
contractAddress: "0x058cdF0fF70f19629D4F50faC03610302e746e58",
functionName: "viewRewardsAndLiquidityInfo",
abi: contractAbi,
};
x = await Moralis.executeFunction(options)
}
And I went to the console, I typed in await Moralis.executeFunction (options)
and I get console error: Uncaught ReferenceError: options is not defined
at :1:31
Sorry if Iām making newbie mistakes lol Iāve been trying to piece together info from this forum and docs to get what I want done.