I am currently trying to build an NFT Marketplace and trying to establish a connection with alchemy-mumbai using JsonRpcProvider. I keep getting this error and can't figure out what i need to do:

Error when running next.js app

This is my hardhat.config:

const fs = require("fs");  // enable file system
const privateKey = fs.readFileSync(".secret").toString().trim();
const url = fs.readFileSync(".secret2").toString().trim();
const url2 = fs.readFileSync(".secret3").toString().trim();

 module.exports = {
  networks: {
    hardhat: {
      accountsBalance: "100000000000000000000000"
    mumbai: {

      url: url,
      accounts: [privateKey],
    mainnet: {

      url: url2,
      accounts: [privateKey],
  solidity: {
    version: "0.8.10",
    settings: {
      optimizer: {
        enabled: true,
        runs: 200
  paths: {
    sources: "./contracts",
    tests: "./test",
    cache: "./cache",
    artifacts: "./artifacts"
  mocha: {
    timeout: 40000

This is my index.js file:

import {ethers} from 'ethers'; //syn front end to backend smart contracts with ethers
import {useEffect, useState} from 'react'; //keep track of local state and sustain hook functions
import axios from 'axios';  //axios for data fetching
import Web3Modal from 'Web3Modal'; //support metamask/wallet functionality and connectivity
import { nftAddress, nftMarketAddress } from '../config'; // import addresses for NFTix
//import { MoralisProvider } from "react-moralis";
import NFT from "../artifacts/contracts/NFT.sol/NFT.json";
import Market from "../artifacts/contracts/NFTMarket.sol/NFTMarket.json";

// Application Binary Interface (ABI)
// Application Programming interface (API)

// Server1 => API.json <=Server2    See NFT.json

export default function Home() {

  const [nfts, setNfts] = useState([]);
  const [loadingState, setLoadingState] = useState('not-loaded');
  // require("@nomiclabs/hardhat-waffle");
  // const fs = require("fs");
  // const url = fs.readFileSync("../secret2").toString().trim();
  useEffect(() => {

  }, []);

  //establish a connection with abi with ethers (Web3Modal also possible)
  async function loadNFTs(){  
    const provider = new ethers.providers.JsonRpcProvider("https://polygon-mumbai.g.alchemy.com/v2/..",);
    const tokenContract = new ethers.Contract(nftAddress, NFT.abi, provider);
    const marketContract = new ethers.Contract(nftMarketAddress, Market.abi, provider);

    //return an array of unsold market items
    const data = await marketContract.fetchMarketItems();

would really appreciate any tips as to why the mumbai network is not found.


  • ENS simply does not work on all networks. Feb 11 at 22:12
  • So to use matic Mumbai I need to use something else other than jsonRPC? How does one approach using the matic network?
    – jf13
    Feb 12 at 7:27
  • So I am trying to follow this project's github.com/dabit3/polygon-ethereum-nextjs-marketplace. But it still does not work. It seems ENS should work with matic.
    – jf13
    Feb 14 at 19:12

1 Answer 1


This might be the same problem here.
The address that you use might be invalid (e.g. space/numbers accidentally added to address). In this case, your smartcontract address is invalid

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.