NFT minting fails with 404 error using Alchemy provider on Sepolia testnet

I’m trying to create an NFT using Alchemy on the Sepolia network but getting a 404 server error. The script runs without issues in other scenarios, but when I execute node scripts/deploy.js, this error appears:

Error occurred: Error: server response 404 Not Found (request={}, response={}, error=null, code=SERVER_ERROR, version=6.3.0)
    at makeError (.../blockchain/node_modules/ethers/lib.commonjs/utils/errors.js:121:21)
    at assert (.../blockchain/node_modules/ethers/lib.commonjs/utils/errors.js:138:15) 
    at FetchResponse.assertOk (.../blockchain/node_modules/ethers/lib.commonjs/utils/fetch.js:775:32)
    at AlchemyProvider._send (.../blockchain/node_modules/ethers/lib.commonjs/providers/provider-jsonrpc.js:772:18)

Here’s my deployment script:

const { ethers } = require("ethers");

const tokenContract = require("../artifacts/contracts/nftToken.sol/nftToken.json");
const contractABI = tokenContract.abi;

const alchemyProvider = new ethers.AlchemyProvider("sepolia", process.env.ALCHEMY_KEY);

const signerWallet = new ethers.Wallet(process.env.WALLET_PRIVATE_KEY, alchemyProvider);

const NFTToken = new ethers.Contract(process.env.DEPLOYED_CONTRACT_ADDRESS, contractABI, signerWallet);

const deployToken = async () => {
    try {
        const txn = await NFTToken.createToken(process.env.WALLET_PUBLIC_KEY);
        console.log(txn);
    } catch (error) {
        console.log("Error occurred", error);
    }
};

deployToken();

I’ve verified my environment variables multiple times and tried different approaches but the 404 error persists. Has anyone encountered this issue before? Looking for a way to successfully execute the minting script.

hmm, it might be your alchemy endpoint being down or an api key issue. try testing your ALCHEMY_KEY with a simple provider connection first. also, double-check that you’re using the sepolia-specific endpoint url if you set it manually.

Interesting issue! I’ve hit similar 404 errors on Sepolia - they’re super frustrating. First thing I’d check: is your contract address actually valid on Sepolia? Easy to mix up mainnet addresses or miss that deployment failed.

Try calling a simple read function first - like contract name or symbol. This’ll tell you if it’s a provider issue or something contract-specific.

What’s your createToken function look like? Does it need specific parameters or gas settings? Sepolia can be picky about gas estimation.

Also, when did you last try this? Sepolia’s been having network issues lately. Check Alchemy’s status page or try Infura temporarily to rule out provider problems.

What happens if you call NFTToken.name() or another view function instead of minting?