![](/img/trans.png)
[英]Why I receive error: TypeError: Cannot read property of 'split' of undefined
[英]"TypeError : Cannot read property 'address' of undefined" i receive this error after lunch the deploy in the testnet, but in localhost works
我收到此错误TypeError: Cannot read property 'address' of undefined
after npx hardhat run scripts/deploy.js --network goerli
,但 localhost 中的相同命令运行良好,为什么?
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}`]
}
},
};
部署.js
错误似乎在这里,但我不明白为什么午餐 npx hardhat run scripts/deploy.js 和 goerly(或其他测试网不)工作得很好
如果我写console.log(accounts[0].address); console.log(accounts[1].address)
console.log(accounts[0].address); console.log(accounts[1].address)
;,我只得到第一个的日志
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();
也许我明白了,我只添加了 1 个私钥,我必须在“帐户”数组中添加更多
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.