I’m trying to adapt some code from vfat.tools to Moralis.
The source code is here: https://github.com/vfat-tools/vfat-tools/blob/master/src/static/js/curve.js
This code connects to curve and gets the number of pools. I’m trying to make the same contract call using Moralis. Here’s my attempt:
const GAUGE_CONTRACT_ABI = [...same as on vfat tools/curve.js, line 6...]
const ASSETS_ADDRESS = "0x90E00ACe148ca3b23Ac1bC8C240C2a7Dd9c2d7f5";
const options = {
chain: "eth",
address: ASSETS_ADDRESS,
function_name: "pool_count",
abi: GAUGE_CONTRACT_ABI,
params: {},
};
const result = moralis.Moralis.Web3API.native
.runContractFunction(options)
.then(console.log);
But I get this error:
node:internal/process/promises:246
triggerUncaughtException(err, true /* fromPromise */);
^
[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "#<Object>".] {
code: 'ERR_UNHANDLED_REJECTION'
}
What am I doing wrong?
Thanks!