I executed some contract creation scripts by terminal through hardhat, "npx hardhat run...." what I noticed is balances of hardhat accounts are not reduced. Meaning as there is no gas spent for contract creation. Then I connected to hardhat node through remix and executed simple contract creation and balance reduced. My original script creates proxy contracts and that is the only thing I can see as different. I double checked in script is the chainId same on both terminal script and remix and both are 1337. Run out of ideas.
Problem is seems that command npx hardhat --network hardhat run /somescript.js
not working, even if you have local hardhat network defined in hardhat.config
what is working is npx hardhat --network localhost run /somescript.js
. Assuming you have like me, running hardhat node locally
//in hardhat.config
require("@nomicfoundation/hardhat-toolbox");
require("@openzeppelin/hardhat-upgrades");
module.exports = {
defaultNetwork: "hardhat",
networks: {
hardhat: {
chainId: 1337,
},
//deploy.js
const Destroyer = await ethers.getContractFactory("Destroyer", {
signer: admin,
});
const destroyer = await upgrades.deployProxy(Destroyer, [exchange.address], {
kind: "uups",
});
await destroyer.deployed();
console.log("Destroyer: " + destroyer.address);
npx hardhat --network hardhat run /somescript.js
npx hardhat --network localhost run /somescript.js
with runningnpx hardhat node
I see in terminal logs (trasactions). When I do the same withnpx hardhat --network hardhat run /somescript.js
I do not see transactions executed in terminal. My expectation is that both commands should do the same and run script on hardhat blockchain node on localhost as "hardhat" network is actually localhost. What I was wondering is, if withnpx hardhat --network hardhat run /somescript.js
I do not see transactions, where this script is running as I did not get any errors?