hardhat最新版本部署问题

最新版本引入是没引入hardhat-toolbox吗?全局安装的,文档又说这些依赖可以不用了。 hardhat.config.js:

require("@nomicfoundation/hardhat-toolbox");
require("dotenv").config({ path: ".env" });
const ALCHEMY_RPC_URL = process.env.ALCHEMY_KEY;
const PRIVATE_KEY = process.env.PRIVATE_KEY;

/** @type import('hardhat/config').HardhatUserConfig */
module.exports = {
  solidity: "0.8.17",
  networks: {
    sepolia: {
      url: ALCHEMY_RPC_URL,
      accounts: [PRIVATE_KEY],
    },
  },
};

deploy.js:

const {
  FlashbotsBundleProvider,
} = require("@flashbots/ethers-provider-bundle");
const { BigNumber } = require("ethers");
const { ethers } = require("hardhat");
require("dotenv").config({ path: ".env" });
const hre = require("hardhat");

async function main() {
  const provider = new ethers.providers.JsonRpcProvider(process.env.ALCHEMY_KEY);
  const signer = new ethers.Wallet(
    process.env.PRIVATE_KEY,
    provider
  );
  console.log("signer:",signer);

  // Deploy Contract
  const testNFTDeploy = await hre.ethers.deployContract("NftTest1");
  await testNFTDeploy.deployed();
  console.log("Address of NFT Contract:", testNFTDeploy.address);
  }

main();

image.png

请先 登录 后评论

最佳答案 2023-09-13 11:05

版本问题

请先 登录 后评论

其它 1 个回答

Elvis - 智能合约开发工程师
请先 登录 后评论
  • 2 关注
  • 0 收藏,1409 浏览
  • lalala 提出于 2023-09-11 15:13