i receive this error TypeError : Cannot read property 'address' of undefined
after lunched npx hardhat run scripts/deploy.js --network goerli
, but the same command in localhost works well, why?
hardhat.config.js
require('dotenv').config();
require("@nomiclabs/hardhat-ethers");
const { API_URL, PRIVATE_KEY } = process.env;
module.exports = {
solidity: '0.8.4',
defaultNetwork: "goerli",
networks: {
hardhat: {},
goerli: {
url: API_URL,
accounts: [`0x${PRIVATE_KEY}`]
}
},
};
deploy.js
the error seems to be here, but i don't get why lunching npx hardhat run scripts/deploy.js works well and with goerly (or other testnet not)
if i write console.log(accounts[0].address); console.log(accounts[1].address)
; , i get the log only of the first one!
const { ethers } = require("hardhat");
const main = async () => {
let accounts;
accounts = await ethers.getSigners();
const OWNERS = [
accounts[0].address,
accounts[1].address,
accounts[2].address
]
const NUM_CONFIRMATIONS = 2
const MultiSig = await ethers.getContractFactory("MultiSig");
const multiInstance = await MultiSig.deploy(OWNERS, NUM_CONFIRMATIONS);
const TestContract = await ethers.getContractFactory("TestContract");
const testContract = await TestContract.deploy("msg");
await multiInstance.deployed();
await testContract.deployed();
console.log('multisig contract address: ', multiInstance.address);
console.log('test contract address: ', testContract.address);
};
const runMain = async () => {
try {
await main();
process.exit(0);
} catch (error) {
console.error(error);
process.exit(1);
}
};
runMain();
maybe i got it, i added only 1 private key, i have to add more in the "accounts"array