导入{ethers}从“以ethers” vs const {ethers} = require(" hardhat;

发布于 2025-02-11 11:12:44 字数 377 浏览 2 评论 0原文

我正在一个教程的指导下,在NFTmarketplace项目中工作,显然我需要“ Ethers.js”。

在我的 test.js file(我使用npx hardhat test )中,需要使用 const {ethers} = require(“ hardhat”); 。另一方面,在 home.js for react frontend )中,我必须使用 inter import {ethers}从“ ethers” 。

现在我的问题是,为什么我以两种不同的方式导入同样的事情。

I am working on an NFTMarketplace project with the guidance of a tutorial, where I am obviously requiring "ethers.js".

In my test.js file (which I run using npx hardhat test), it is required to use const { ethers } = require("hardhat");. On the other hand, in the Home.js (which is for react frontend), I am required to use import { ethers } from "ethers".

Now my question is, why I'm importing the same thing in 2 different ways.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

⒈起吃苦の倖褔 2025-02-18 11:12:44

使用HardHat时,您不需要导入“以太货币”

硬汉运行时环境(简称HRE)是一个对象
包含HardHat运行时暴露的所有功能
任务,测试或脚本。实际上,hardhat是hre。

When using hardhat you do not need to import "ethers"

The Hardhat Runtime Environment, or HRE for short, is an object
containing all the functionality that Hardhat exposes when running a
task, test or script. In reality, Hardhat is the HRE.

https://hardhat.org/advanced/hardhat-runtime-environment?utm_source=buildspace.so&utm_medium=buildspace_project

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文