Hi guys,
I have been trying to deploy two upgradeable contracts to mumbai network but I am getting this error (with debug):
It is weird because about a week ago the deployment was successful with the same code. I believe there is some problem with the Admin Proxy address, it is not assigned correctly, but this is just thought.
The problem persists if I change the account.
If I try to deploy these same contracts to rinkeby, it works.
hardhat.config.js:
require('@nomiclabs/hardhat-waffle');
require('@openzeppelin/hardhat-upgrades');
const fs = require('fs');
require('dotenv').config();
const privateKey = process.env.PRIVATE_KEY || '';
const infuraId = process.env.INFURA_API_KEY || '';
module.exports = {
defaultNetwork: 'hardhat',
networks: {
hardhat: {
chainId: 1337,
},
development: {
url: 'http://127.0.0.1:8545',
chainId: 1337, // Match any network id
},
mumbai: {
// Infura
url: `https://polygon-mumbai.infura.io/v3/${infuraId}`,
accounts: [privateKey],
},
matic: {
// Infura
url: `https://polygon-mainnet.infura.io/v3/${infuraId}`,
accounts: [privateKey],
},
},
solidity: {
version: '0.8.4',
settings: {
optimizer: {
enabled: true,
runs: 200,
},
},
},
};
deployment script:
const { ethers, upgrades } = require('hardhat');
const hardhat = require('hardhat');
const fs = require('fs');
async function main() {
const NFTMarket = await ethers.getContractFactory('NFTMarket');
console.log('Deploying contracts to: ' + hardhat.network.name + ' network');
const nftMarket = await upgrades.deployProxy(NFTMarket, []);
await nftMarket.deployed();
console.log('nftMarket deployed to:', nftMarket.address);
const NFT = await ethers.getContractFactory('NFT');
const nft = await upgrades.deployProxy(NFT, [nftMarket.address]);
await nft.deployed();
console.log('nft deployed to:', nft.address);
let config = `
export const network = "${hardhat.network.name}"
export const nftmarketaddress = "${nftMarket.address}"
export const nftaddress = "${nft.address}"
`;
let config_scripts = `
const nftmarketaddress = "${nftMarket.address}"
module.exports = { nftmarketaddress }
`;
let data = JSON.stringify(config);
fs.writeFileSync('config.js', JSON.parse(data));
let data_scripts = JSON.stringify(config_scripts);
fs.writeFileSync('config-scripts.js', JSON.parse(data_scripts));
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});
I would really appreciate your help, since this problem is difficulting the progress of the project.
Request any other file if you think is needed!
Thank you in advance.