You need to enable JavaScript to run this app. 部署Hardhat智能合约时遇ERROR processing skip func错误求助
优惠活动
大模型
产品
解决方案
定价
更多

部署Hardhat智能合约时遇ERROR processing skip func错误求助

解决部署VRFCoordinatorV2Mock时的skip func错误

错误信息

ERROR processing skip func of /home/deepak/blockchain-dev/hardhat-raffle/deploy/00-deploy-mock.js:

问题代码

const { network } = require("hardhat")
const { developmentChains, networkConfig } = require("../helper-hardhat-config")

const BASE_FEE = ethers.utils.parseEther("0.25") //0.25link is cost to get Random no
const GAS_PRICE_LINK = 1e9 // calculated value based on the gas price of the chain
const args = [BASE_FEE, GAS_PRICE_LINK]
module.exports = async function ({ getNamedAccounts, deployments }) {
   const { deploy, log } = deployments
   const { deployer } = await getNamedAccounts()
   const chainId = network.config.chainId

   if (developmentChains.includes(network.name)) {
      log("Local Network detected! Deploying.......")
      await deploy("VRFCoordinatorV2Mock", {
         from: deployer,
         args: args,
         log: true,
         waitConfirmations: network.config.blockConfirmations || 1,
      })
      log("Mocks Deployed!")
      log("-------------------------------------------------")
   }
}
module.exports.tags = ["all", "mocks"]

可能的原因及修复方案

1. 未导入ethers模块

代码中使用了ethers.utils.parseEther但未在顶部导入ethers,运行时错误会触发skip func处理异常。

修复:在文件开头添加ethers导入:

const { network, ethers } = require("hardhat")

2. developmentChains配置不匹配

检查helper-hardhat-config.js里的developmentChains数组,确保包含你当前使用的本地网络名称(比如hardhat、localhost、ganache等)。若当前网络不在数组内,脚本逻辑会跳过部署,配置错误可能引发skip函数处理异常。

示例正确配置:

const developmentChains = ["hardhat", "localhost"]

3. Hardhat Deploy插件版本或配置问题

  • 确保已安装hardhat-deploy插件:
    npm install --save-dev hardhat-deploy
    
  • 在hardhat.config.js中正确引入插件:
    require("hardhat-deploy")
    
  • 若版本兼容有问题,尝试更新到最新版本:
    npm update hardhat-deploy
    

4. 网络配置缺失

检查hardhat.config.js中本地网络的配置,确保chainId和blockConfirmations等参数正确设置,示例:

networks: {
  hardhat: {
    chainId: 31337,
    blockConfirmations: 1
  },
  localhost: {
    chainId: 31337,
    blockConfirmations: 1
  }
}

内容的提问来源于stack exchange,提问作者Newbie coder

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.03 15:10:16