1

//List Products

  const listProducts = async (
    seller,
    price,
    rating,
    name,
    description,
    category,
    imgUrl
  ) => {
    if (!name || !description || !price || !rating || !category || !imgUrl) {
      alert("Pls provide necessary details");
      const contract = await connectingWithSmartContract();
      const getListedProducts = await contract.listNewProduct({
        price: ethers.utils.parseEther(price),
        rating: rating,
        name: rating,
        description: description,
        category: category,
        imgUrl: imgUrl,
      });
      alert("products listed sucessfully");
      return getListedProducts;
    } else {
      alert("something went wrong while listing products");
    }
  };

the error is coming from the above code maybe the price format is wrong how do i format it, im using matic as method of payment

2 Answers 2

1

One of your input variables is of type BigNumber, so your code is failing to enter it in the contract. Try using the BigNumber package or send the variable in string format. Sometimes that work.

2
  • how can change to string
    – Josephdev
    Commented Dec 1, 2022 at 9:59
  • I guess .toString() works fine. Commented Dec 1, 2022 at 9:59
0

use toString function inside ethers.utils.parseEther(price) like this ethers.utils.parseEther(price.toString()) it will work.

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.