尝试部署到 goerli 测试网络时收到错误代码"TypeError: Cannot read properties of null (reading 'sendTransaction')"



这是我的hardhat.config.js代码

// hardhat.config.js
require("@nomiclabs/hardhat-ethers");
require("@nomiclabs/hardhat-waffle");
require("dotenv").config()
// You need to export an object to set up your config
// Go to https://hardhat.org/config/ to learn more
const GOERLI_URL = process.env.GOERLI_URL;
const PRIVATE_KEY = process.env.PRIVATE_KEY;
/**
* @type import('hardhat/config').HardhatUserConfig
*/
module.exports = {
solidity: "0.8.4",
networks: {
goerli: {
url: process.env.GOERLI_URL || "https://eth-goerli.alchemyapi.io/v2/PT8BEXCUKwsfvcBz8y3g7A2V7LdhUKQA",
accounts: process.env.PRIVATE_KEY
}
}
};

和我的deploy.js脚本:

// scripts/deploy.js
const hre = require("hardhat");
async function main() {
// We get the contract to deploy.
const BuyMeACoffee = await hre.ethers.getContractFactory("BuyMeACoffee");
const buyMeACoffee = await BuyMeACoffee.deploy();
await buyMeACoffee.deployed();
console.log("BuyMeACoffee deployed to:", buyMeACoffee.address);
}
// We recommend this pattern to be able to use async/await everywhere
// and properly handle errors.
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});

我真的不知道如何把它排序,它几乎让我陷入了一个循环。请帮助。谢谢你!我对使用hardhat和npm还是个新手。我的当前节点v16.13.1 (npm v8.1.2)

硬帽错误。配置文件代替帐户:process.env。[process.env.PRIVATE_KEY]

相关内容

最新更新