4

I have next app with typescript template and using wagmi (https://www.npmjs.com/package/wagmi) package I am trying to send ether to the contract function

Code

const { config } = usePrepareContractWrite({
    address: "0x53f2d86edcb67c9ea04eada4c2333aebeab717ef",
    abi: [
      {
        name: "mint",
        type: "function",
        stateMutability: "payable",
        inputs: [{ name: "quantity", type: "uint256" }],
        outputs: [],
      },
    ],
    functionName: "mint",
    args: [ethers.BigNumber.from(props.q)],
    overrides: {
      from: "0xfc2df69DF76Fe18866bFc5396f35255e7EFa274a",
      value: ethers.utils.parseEther("0.001"),
    },
  });

I am getting below error

Type '{ from: "0xfc2df69DF76Fe18866bFc5396f35255e7EFa274a"; value: ethers.BigNumber; }' is not assignable to type 'Overrides & { from?: `0x${string}` | undefined; }'.
Object literal may only specify known properties, and 'value' does not exist in type 'Overrides & { from?: `0x${string}` | undefined; }'

According to docs (https://wagmi.sh/react/prepare-hooks/usePrepareContractWrite#overrides-optional), I should be able to send ether to the function but I am getting type error

2
  • 1
    I wasn't able to fix the types issue so I just disabled types for that particular file by adding // @ts-nocheck at the top. This was the only workaround I could find for the issue Commented Dec 1, 2022 at 11:03
  • Have you solved this?
    – OhItsPM
    Commented Apr 24, 2023 at 14:12

1 Answer 1

0

for type '0x${string} you can use type Address

you can import it like this:

import { Address } from "wagmi";

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.