I am running a function that is supposed to mint an NFT from the browser. I am able to execute the script from within node.js CLI . When I try to do it from the browser I get:
Uncaught (in promise) TypeError: ethers.getContractFactory is not a function
Here is how I am importing it currently:
import { ethers } from "https://cdn-cors.ethers.io/lib/ethers-5.5.4.esm.min.js";
As I understand, "getContractFactory" is actually a hardhat helper. How should I import it? I am not using a compiler like webpack since I had issues with it.
As you mentioned getContractFactory() is a helper function which hardhat added to the ethers object and is only available in your hardhat environment.
The function is used to actually deploy a new contract.
What you want to use in the browser is probably ethers.Contract() to "import" an already deployed contract for interacting with it.
const mintingContract = new ethers.Contract(
nftContractAddress,
ABI,
signer)