I’ve been working on building an NFT minting script and running into some problems. I managed to deploy my smart contract successfully, but now I’m stuck on the actual minting part. The script should connect to my deployed contract and mint an NFT to my wallet.
Here’s what I have so far:
// scripts/createNFT.js
require("dotenv").config();
const { ethers } = require("ethers");
const contractABI = require("../artifacts/contracts/CoolCat.sol/CoolCat.json");
const abi = contractABI.abi;
const provider = ethers.getDefaultProvider("sepolia", {
alchemy: process.env.ALCHEMY_API_KEY,
});
const signer = new ethers.Wallet(process.env.WALLET_PRIVATE_KEY, provider);
const coolCatContract = new ethers.Contract(
process.env.DEPLOYED_CONTRACT_ADDRESS,
abi,
signer
);
const mintNFT = async () => {
try {
const txn = await coolCatContract.mintToken(process.env.WALLET_PUBLIC_KEY);
console.log(txn);
} catch (error) {
console.log("Minting failed:", error);
}
};
mintNFT();
I keep getting a “quorum not met” error when trying to estimate gas. The contract address is definitely correct since deployment worked fine. Has anyone encountered this before? What am I missing in my minting setup?
That’s a tricky one! I’ve hit this “quorum not met” error before and it’s always annoying to debug.
First things first - you sure your wallet has enough ETH for gas on Sepolia? Error messages can be misleading when you’re just low on funds. Also, what’s your mintToken function look like in the contract? Does it need any specific parameters besides the address?
One thing - you’re using ethers.getDefaultProvider which can be unreliable. Try switching to the Alchemy provider directly:
const provider = new ethers.providers.AlchemyProvider("sepolia", process.env.ALCHEMY_API_KEY);
Quick sanity checks: Did you verify the contract deployed successfully on Etherscan? Are you running this on the same network where you deployed?
Try calling a simple read function first to test the connection. That’ll help figure out if it’s a connection issue or something with the minting function specifically.
Let me know what you find - I’m curious since your setup looks pretty standard!
looks like a provider issue. try adding waitForTransaction() after your mint call - sometimes the transaction gets broadcasted but the provider loses track of it. also check if your contract has access controls or is paused, which might be blocking the mint.
Hit the same thing last month on Sepolia. Wasn’t my code - Alchemy’s free tier craps out during peak hours and throws that quorum error.
Before switching providers, test a basic contract call first. Check the owner or total supply if you’ve got those functions. If simple reads fail, it’s definitely the provider.
Also - double-check your environment variables are actually loading. I burned hours debugging once because my .env file was in the wrong folder. Throw some console.log statements in there to make sure your contract address and wallet address aren’t empty.
If reads work but minting fails, check your mintToken function for requirements like whitelist checks or supply limits. Gas estimation breaks when the transaction would revert anyway.