首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ParseEther正在变得没有定义

ParseEther正在变得没有定义
EN

Ethereum用户
提问于 2023-02-11 06:14:06
回答 1查看 361关注 0票数 2

我的守则:

代码语言:javascript
复制
const ethers = require("hardhat")

const networkConfig = {
  4: {
    name: "goerli",
    vrfCoordinatorv2: "0x2Ca8E0C643bDe4C2E08ab1fA0da3401AdAD7734D",
    enterenceFee: ethers.utils.parseEther("1.0"),
    gasLane: "0x79d3d8832d904592c0bf9818b621522c988bb8b0c05cdc3b15aea1b6e8db0c15",
    subscriptionId: "0",
    callbackGasLimit: "500000",
    interval: "30",
  },
  31337: {
    name: "hardhat",
    entehenceFee: ethers.utils.parseEther("1.0"),
    gasLane: "0x79d3d8832d904592c0bf9818b621522c988bb8b0c05cdc3b15aea1b6e8db0c15",
  },
}

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

module.exports = [networkConfig, developmentChains]

我的错误:

代码语言:javascript
复制
Error: ERROR processing skip func of C:\Users\user\OneDrive\Desktop\BlockChain\hardhat-lottery\deploy\00-deploy-mocks.js:
TypeError: Cannot read properties of undefined (reading 'parseEther')
    at Object. (C:\Users\user\OneDrive\Desktop\BlockChain\hardhat-lottery\helper-hardhat-config.js:7:32)
    at Module._compile (node:internal/modules/cjs/loader:1103:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object. (C:\Users\user\OneDrive\Desktop\BlockChain\hardhat-lottery\deploy\00-deploy-mocks.js:5:31)
    at Module._compile (node:internal/modules/cjs/loader:1103:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10)
    at DeploymentsManager.executeDeployScripts (C:\Users\user\OneDrive\Desktop\BlockChain\hardhat-lottery\node_modules\hardhat-deploy\src\DeploymentsManager.ts:1100:15)
    at DeploymentsManager.runDeploy (C:\Users\user\OneDrive\Desktop\BlockChain\hardhat-lottery\node_modules\hardhat-deploy\src\DeploymentsManager.ts:1052:16)
    at SimpleTaskDefinition.action (C:\Users\user\OneDrive\Desktop\BlockChain\hardhat-lottery\node_modules\hardhat-deploy\src\index.ts:438:5)
    at Environment._runTaskDefinition (C:\Users\user\OneDrive\Desktop\BlockChain\hardhat-lottery\node_modules\hardhat\src\internal\core\runtime-environment.ts:311:14)
    at Environment.run (C:\Users\user\OneDrive\Desktop\BlockChain\hardhat-lottery\node_modules\hardhat\src\internal\core\runtime-environment.ts:159:14)
    at SimpleTaskDefinition.action (C:\Users\user\OneDrive\Desktop\BlockChain\hardhat-lottery\node_modules\hardhat-deploy\src\index.ts:584:32)
    at Environment._runTaskDefinition (C:\Users\user\OneDrive\Desktop\BlockChain\hardhat-lottery\node_modules\hardhat\src\internal\core\runtime-environment.ts:311:14)
    at Environment.run (C:\Users\user\OneDrive\Desktop\BlockChain\hardhat-lottery\node_modules\hardhat\src\internal\core\runtime-environment.ts:159:14)
    at SimpleTaskDefinition.action (C:\Users\user\OneDrive\Desktop\BlockChain\hardhat-lottery\node_modules\hardhat-deploy\src\index.ts:669:5)
    at Environment._runTaskDefinition (C:\Users\user\OneDrive\Desktop\BlockChain\hardhat-lottery\node_modules\hardhat\src\internal\core\runtime-environment.ts:311:14)

有人能告诉我哪里不对吗?我想不出.

EN

回答 1

Ethereum用户

回答已采纳

发布于 2023-02-11 21:16:53

请查看代码的第一行:

const ethers = require("hardhat")

您要导入作为ethers的安全帽,一个简单的解决方法是执行以下操作

const { ethers } = require("hardhat")

或者称它为hardhat,并在您现在使用ethers的任何地方使用D9

票数 4
EN
页面原文内容由Ethereum提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://ethereum.stackexchange.com/questions/144709

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档