Thanks to visit codestin.com
Credit goes to github.com

Skip to content

error in jsonRpcProvider #4827

@block98ct

Description

@block98ct

Ethers Version

6.13.2

Search Terms

No response

Describe the Problem

JsonRpcProvider failed to detect the network and cannot start up; retry in 1s (perhaps the URL is wrong or the node is not started)
getting this error on the server on my local machine it is working fine

network:- polygon-amoy
infuraUrl:- https://polygon-amoy.infura.io/v3/${myPrivateKey}

Code Snippet

const contractInstance = async (privateKey, address, abi) => {
  try {
       const wallet = new ethers.Wallet(privateKey);
       const provider = new ethers.JsonRpcProvider(
       process.env.INFURA_PROVIDER_URL
      );

    const connectedWallet = wallet.connect(provider);
    const contract = new ethers.Contract(address, abi, connectedWallet);

    return contract;
  } catch (error) {
    console.log(error);
  }
};

Contract ABI

No response

Errors

No response

Environment

Ethereum (mainnet/ropsten/rinkeby/goerli)

Environment (Other)

No response

Metadata

Metadata

Assignees

Labels

bugVerified to be an issue.fixed/completeThis Bug is fixed or Enhancement is complete and published.v6Issues regarding v6

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions