Trouble creating a single NFT on Sepolia using Alchemy

Hey everyone,

I’m stuck trying to create an NFT with Alchemy on the Sepolia network. I’ve followed all the steps in their guide, but when I run node script/mint.js, I get a 404 error. Here’s what it looks like:

Error: server response 404 Not Found
code: 'SERVER_ERROR',
request: FetchRequest {},
response: FetchResponse {},
error: undefined

I’ve double-checked my mint.js file, which looks like this:

const { ethers } = require("ethers");
const contractStuff = require("../artifacts/contracts/nftart.sol/nftart.json");
const contractABI = contractStuff.abi;

const networkConnection = new ethers.AlchemyProvider("sepolia", process.env.API_KEY);
const myWallet = new ethers.Wallet(process.env.SECRET_KEY, networkConnection);
const NFTContract = new ethers.Contract(process.env.NFT_ADDRESS, contractABI, myWallet);

async function createNFT() {
  try {
    const result = await NFTContract.create(process.env.WALLET_ADDRESS);
    console.log(result);
  } catch (error) {
    console.log("Oops! Something went wrong", error);
  }
}

createNFT();

I’ve made sure to import ethers and I’ve triple-checked my API key. I even asked an AI for help, but no luck. Any ideas on what I’m missing? I just want to mint one NFT without any issues. Thanks!

hey isaac31, i feel your pain! nft minting can be super tricky. :upside_down_face: have you double-checked that your NFT_ADDRESS in the .env file is correct? sometimes i’ve run into issues where i accidentally used the wrong contract address or it wasn’t properly deployed on sepolia.

also, might be worth trying to console.log your environment variables at the start of the script to make sure they’re all loading correctly.

oh, and another thing - are you sure the contract you’re trying to interact with has a ‘create’ function? maybe it’s called something else like ‘mint’ or ‘safeMint’?

let us know if any of these help! nft stuff can be a real headache sometimes :sweat_smile:

I’ve encountered similar issues when working with Alchemy and Sepolia. One thing that often gets overlooked is the contract deployment status. Have you verified that your contract is actually deployed and active on the Sepolia network? You can check this using Sepolia’s block explorer.

Another potential issue could be with the contract’s ABI. Ensure that the ABI in your artifacts folder matches the deployed contract. Sometimes, if you’ve made changes to the contract after deployment, the local ABI might be out of sync.

Lastly, I’d recommend using Alchemy’s debug mode or increasing the verbosity of your logs. This can provide more detailed error information, which is crucial for troubleshooting. You might want to add some console logs within your try-catch block to pinpoint exactly where the error is occurring.

If none of these solve the issue, consider reaching out to Alchemy’s support team. They’re usually quite helpful with these kinds of problems.

hey isaac, that 404 error’s a real pain! :confounded: have u tried clearing ur node_modules and reinstalling? sometimes that fixes weird issues. also, double-check ur .env file - make sure there’s no extra spaces or quotes around the values. if nothin else works, maybe try deploying a fresh contract? good luck, nft stuff can be super frustrating!