[Python] Hardhat deploy script: ethers.utils.parseEther is undefined

Discussão em 'Python' iniciado por Stack, Maio 4, 2025.

  1. Stack

    Stack Membro Participativo

    I'm working on a Hardhat project and encountering a TypeError: Cannot read properties of undefined (reading 'parseEther') when running my deploy.js script. The error occurs at the line const amount = ethers.utils.parseEther("1.0");. I have const { ethers } = require("hardhat"); at the top of the script, but ethers still seems to be undefined. I'm using Hardhat v2.22.0 on Windows 11 with Node.js 18, running a local testnet (npx hardhat node). I’ve already tried reinstalling Hardhat, restarting VS Code, using require("ethers") instead (which causes different issues), and searching forums, but the error persists. Other parts of the script like getSigners() and deploy() work fine — the script just fails at this one line. Any ideas why ethers.utils.parseEther would be undefined even when imported from Hardhat?My terminal

    Asker please put your code here

    Continue reading...

Compartilhe esta Página