Thanks for response. I am changing ids, hopefully enough to not hit another working endpoint. Yes, I agree it is weird, I actually changed the provider connection several times before I tried Alchemy. This is relevant code:
const provider = new ethers.providers.JsonRpcProvider("https://polygon-mumbai.g.alchemy.com/v2/id");
//const provider = new ethers.providers.InfuraProvider("maticmum", {projectId: "id",projectSecret: "secret",});
//const provider = new ethers.providers.JsonRpcProvider("https://polygon-mumbai.infura.io/v3/id");
//const provider = new ethers.providers.InfuraProvider("maticmum", { projectId: "id",});
//const provider = new ethers.providers.InfuraProvider("ropsten","id");
Only two of those works, ropsten on Infura and mumbai on Alchemy (I guess ropsten on Alchemy will work too). I think that the problem is probably with hardhat deployment, as the contract IDs seems to be invalid, but can’t figure out how (I don’t have much experience with hardhat though). This is the whole file:
require("@nomiclabs/hardhat-waffle");
const fs = require("fs");
const privateKey = process.env.privateKey || fs.readFileSync(".secret").toString().trim();
const infuraId = process.env.infuraId || fs.readFileSync(".infuraid").toString().trim();
module.exports = {
defaultNetwork: "hardhat",
networks: {
hardhat: {
chainId: 1337,
},
mumbai: {
// Infura
//url: `https://polygon-mumbai.infura.io/v3/${infuraId}`,
url: `https://polygon-mumbai.g.alchemy.com/v2/${infuraId}`,
accounts: [privateKey],
},
matic: {
// Infura
url: `https://polygon-mainnet.infura.io/v3/${infuraId}`,
//url: "https://rpc-mainnet.maticvigil.com",
accounts: [privateKey],
},
ropsten: {
// Infura
url: `https://ropsten.infura.io/v3/${infuraId}`,
accounts: [privateKey],
},
},
solidity: {
version: "0.8.4",
settings: {
optimizer: {
enabled: true,
runs: 200,
},
},
},
};