Currently, I am experimenting with TypeScript following a wagmi example found at this link: https://wagmi.sh/examples/contract-write. Here is the code snippet I am working with:
export function Write() {
const { config } = usePrepareContractWrite({
address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2', //< Error Occurs Here
abi: [
{
name: 'mint',
type: 'function',
stateMutability: 'nonpayable',
inputs: [],
outputs: [],
},
] as const,
functionName: 'mint',
});
const { data, write } = useContractWrite(config);
const { isLoading, isSuccess } = useWaitForTransaction({
hash: data?.hash,
});
return (
<div>
<button disabled={!write || isLoading} onClick={() => write?.()}>
{isLoading ? 'Minting...' : 'Mint'}
</button>
{isSuccess && (
<div>
Successfully minted your NFT!
<div>
<a href={`https://etherscan.io/tx/${data?.hash}`}>Etherscan</a>
</div>
</div>
)}
</div>
);
}
The specific issue I am encountering is:
Object literal may only specify known properties, and 'address' does not exist in type 'UsePrepareContractWriteArgs & UsePrepareContractWriteConfig'.ts(2345)
I attempted to use a const assertion on the abi but it didn't resolve the problem. Any suggestions or thoughts on how to fix this?
const abi = […] as const