I am getting a Wep3 API error while trying to get the totalSupply of tokens.
import { useMoralisWeb3Api, useMoralisWeb3ApiCall } from "react-moralis";
import { Moralis } from "moralis";
import { TestContractAbi, TestcontractAddress } from "../data/ContractData";
import { Container, PrimarySection } from "../components/Themes";
const contractAddress = TestcontractAddress;
const contractAbi = JSON.stringify(TestContractAbi);
console.log(contractAbi);
function test() {
const {
native: { runContractFunction },
} = useMoralisWeb3Api();
const getTotalSupply = useMoralisWeb3ApiCall(runContractFunction, {
chain: "rinkeby",
address: contractAddress,
function_name: "totalSupply",
abi: {
inputs: [],
name: "totalSupply",
outputs: [
{
internalType: "uint256",
name: "",
type: "uint256",
},
],
stateMutability: "view",
type: "function",
},
});
return (
<>
<PrimarySection>
<Container></Container>
</PrimarySection>
<PrimarySection>
<Container>
<button onClick={() => getTotalSupply.fetch()}>
get total supply
</button>
<pre>{JSON.stringify(getTotalSupply, null, 2)}</pre>
</Container>
</PrimarySection>
</>
);
}
export default test;