I’m attempting to deploy a contract on a hardhat forked mainnet.
I run ‘npx hardhat run scripts/deploy.js --network hardhat’
But I keep getting same error
‘Error: Transaction reverted: function call to a non-contract account’
This is my constructor
constructor (address payable charityWallet, address payable marketingWallet) {
_rOwned[_msgSender()] = _rTotal;
_charityWallet = charityWallet;
_marketingWallet = marketingWallet;
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
// Create a uniswap pair for this new token
uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory())
.createPair(address(this), _uniswapV2Router.WETH());
// set the rest of the contract variables
uniswapV2Router = _uniswapV2Router;
//exclude owner and this contract from fee
_isExcludedFromFee[owner()] = true;
_isExcludedFromFee[address(this)] = true;
emit Transfer(address(0), _msgSender(), _tTotal);
}
This is my deploy.js
const hre = require("hardhat");
async function main() {
const Givers = await hre.ethers.getContractFactory("Givers");
const givers = await Givers.deploy("0x8626f6940e2eb28930efb4cef49b2d1f2c9c1199", "0xdd2fd4581271e230360230f9337d5c0430bf44c0");
await givers.deployed();
console.log("Givers deployed to:", givers.address);
};
main().catch((error) => {
console.error(error);
process.exitCode = 1;
});
My hardhat.config.js
require("dotenv").config();
require("@nomiclabs/hardhat-etherscan");
require("@nomiclabs/hardhat-waffle");
require("hardhat-gas-reporter");
require("solidity-coverage");
task("accounts", "Prints the list of accounts", async (taskArgs, hre) => {
const accounts = await hre.ethers.getSigners();
for (const account of accounts) {
console.log(account.address);
}
});
module.exports = {
solidity: "0.8.5",
networks: {
hardhat: {
forking: {
url: "https://speedy-nodes-nyc.moralis.io/c65ccf112b7b7f0c317075b7/eth/mainnet",
}
}
},
gasReporter: {
enabled: process.env.REPORT_GAS !== undefined,
currency: "USD",
},
etherscan: {
apiKey: process.env.ETHERSCAN_API_KEY,
},
};
module.exports = {
solidity: {
version: "0.8.5",
settings: {
optimizer: {
enabled: true,
runs: 1,
},
},
},
};
I’m freaking out, I don’t understand why isn’t it working. Please help