I’m encountering an error when trying to mint an NFT using a React frontend and the ethers.js library. The specific error I’m getting is:
Error minting NFT: no matching fragment (operation="fragment", info={ "args": [ "ipfs://bafkreiekiirqbrda7nwlrivh62425gspa3mtag6s7oinfh42vletw7wgmi" ], "key": "mintNFT" }, code=UNSUPPORTED_OPERATION, version=6.13.7)
My React component for minting looks like this:
import React, { useState } from 'react';
import { ethers } from 'ethers';
import PhilosophyNFT from '../abis/PhilosophyNFT.json';
const MintPage = () => {
const [minting, setMinting] = useState(false);
const [minted, setMinted] = useState(false);
const [errorMessage, setErrorMessage] = useState("");
const [successMessage, setSuccessMessage] = useState("");
const mintNFT = async () => {
if (minting) return;
setMinting(true);
setSuccessMessage("");
setErrorMessage("");
try {
if (window.ethereum) {
await window.ethereum.request({ method: 'eth_requestAccounts' });
} else {
alert("Please install MetaMask!");
return;
}
const provider = new ethers.BrowserProvider(window.ethereum);
const signer = await provider.getSigner();
const contract = new ethers.Contract(
"0x2020Ac5bCE11e66796aA025a88a6d8E27559Da4E", // Deployed contract address
PhilosophyNFT.abi,
signer
);
const tx = await contract.mintNFT(`ipfs://bafkreiekiirqbrda7nwlrivh62425gspa3mtag6s7oinfh42vletw7wgmi`);
await tx.wait();
setMinted(true);
setSuccessMessage("Minting successful! Your NFT is now minted.");
} catch (error) {
setMinted(false);
setErrorMessage("Error minting NFT: " + error.message);
} finally {
setMinting(false);
}
};
return (
<div className="mint-container">
<h1>Mint Your Philosophy NFT</h1>
{errorMessage && <div className="error-message">{errorMessage}</div>}
{successMessage && <div className="success-message">{successMessage}</div>}
<button onClick={mintNFT} disabled={minting} className="mint-button">
{minting ? "Minting..." : minted ? "Minted!" : "Mint NFT"}
</button>
</div>
);
};
export default MintPage;
The error message suggests that the ethers.js library cannot find a matching function signature (mintNFT) in the provided ABI (PhilosophyNFT.json) that accepts the arguments I’m passing (in this case, a single IPFS URI string).
-
I have already tried:
-
Verifying that the contract address in my React code is correct.
Any help in resolving this error would be greatly appreciated!


