Hi,
I code with Angular for the front-end and solidity for back-end.
When I want interact with a smart contract, I use as function runContractFunction :
const options = {
chain: “0x539”,
address: “0xBeae252aF0e4E0852ADAbFb6637bC551D4127954”,
function_name: “getTracks”,
abi: this.ABI
}
const allowance = await Moralis.Web3API.native.runContractFunction(options).then(receipt => {
receipt = receipt;
console.log(receipt);
});
But I have this error :
error TS2345: Argument of type ‘{ chain: string; address: string; function_name: string; abi: ({ inputs: any[]; stateMutability: string; type: string; anonymous?: undefined; name?: undefined; outputs?: undefined; } | { anonymous: boolean; … 4 more …; outputs?: undefined; } | { …; } | { …; })[]; }’ is not assignable to parameter of type ‘{ chain?: “eth” | “0x1” | “ropsten” | “0x3” | “rinkeby” | “0x4” | “goerli” | “0x5” | “kovan” | “0x2a” | “polygon” | “0x89” | “mumbai” | “0x13881” | “bsc” | “0x38” | “bsc testnet” | … 6 more … | “0xfa”; subdomain?: string; providerUrl?: string; function_name: string; } & { …; }’.
Type ‘{ chain: string; address: string; function_name: string; abi: ({ inputs: any[]; stateMutability: string; type: string; anonymous?: undefined; name?: undefined; outputs?: undefined; } | { anonymous: boolean; … 4 more …; outputs?: undefined; } | { …; } | { …; })[]; }’ is not assignable to type ‘{ chain?: “eth” | “0x1” | “ropsten” | “0x3” | “rinkeby” | “0x4” | “goerli” | “0x5” | “kovan” | “0x2a” | “polygon” | “0x89” | “mumbai” | “0x13881” | “bsc” | “0x38” | “bsc testnet” | “0x61” | … 5 more … | “0xfa”; subdomain?: string; providerUrl?: string; function_name: string; }’.
Types of property ‘chain’ are incompatible.
Type ‘string’ is not assignable to type ‘“eth” | “0x1” | “ropsten” | “0x3” | “rinkeby” | “0x4” | “goerli” | “0x5” | “kovan” | “0x2a” | “polygon” | “0x89” | “mumbai” | “0x13881” | “bsc” | “0x38” | “bsc testnet” | “0x61” | … 5 more … | “0xfa”’.234 const allowance = await Moralis.Web3API.native.runContractFunction(options).then(receipt => {
I deployed the smart contract on my localhost blockchain using Ganache.
It’s for that I put for chain: “0x539” but I also tried chain: “ganache” or “localdevchain”.
Any thoughts on what could be wrong? Any help would be appreciated