Code 141 abi required (Ethereum Boilerplate)

I am trying to interact with a smart contract on the Rinkeby testnet using the useAPIContract function with the Ethereum Boilerplate code. The code comes back with the following error, even though I have an ABI defined:

{“code”:141,“error”:“param abi is required!”}

Can anyone see what I am doing wrong?

import { useAPIContract } from "hooks/useAPIContract";

const contractAbi = [
  {
    constant: true,
    inputs: [],
    name: "BUSDbal",
    outputs: [
      {
        internalType: "uint256",
        name: "",
        type: "uint256",
      },
    ],
    payable: false,
    stateMutability: "view",
    type: "function",
  },
];

const Claim = () => {
  const {
    runContractFunction,
    contractResponse,
    error,
    isLoading,
    isFetching,
  } = useAPIContract({
    abi: contractAbi,
    address: "0x9Fe76E58801CED8CC8Be79717Bde933Ab7eA7b3b",
    functionName: "BUSDbal",
    params: {},
    chain: "rinkeby",
  });

  return (
    <div>
      <button onClick={() => runContractFunction()} disabled={isLoading}>
        Claim
      </button>
      <h3>Error</h3>
      {JSON.stringify(error)}
      <h3>ContractResponse</h3>
      {JSON.stringify(contractResponse)}
      <h3>IsLoading</h3>
      {JSON.stringify(isLoading)}
      <h3>IsFetching</h3>
      {JSON.stringify(isFetching)}
    </div>
  );
};

export default Claim;

What version of Marsalis sdk are you using?

You can also use the syntax presented here to call that function in react: https://docs.moralis.io/moralis-dapp/web3-api/native#runcontractfunction

Hi! I have the same problem. The ABI is correct but I get the {“code”:141,“error”:“param abi is required!”} error.

Here’s the code:

const {
        runContractFunction,
        data,
        error,
        isLoading,
        isFetching,
    } = useApiContract({
        address: gcxAddress,
        abi: abi,
        functionName: "getSaleState",
        chain: "rinkeby"
    });

    useEffect(() => {
        if (isInitialized) {
            runContractFunction();
        }
    }, [isInitialized])

    useEffect(() => {
        data ? setSaleState(data) : runContractFunction()
        error ? console.log(error) : console.log(data)
    }, [data])

I’m also using the exact same code I’ve also used in the past with success

Which Moralis / react-moralis versions are you using? Can you try passing a random string into abi e.g. abi: "test" and see what the error is?