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;