Skip to content

require ethers or require hardhat #298

Answered by PatrickAlphaC
Sairam002 asked this question in Q&A
Discussion options

You must be logged in to vote

Amazing question!

So... in lesson 5 we just used the "raw" ethers package. But the "ethers" package by itself doesn't have all the functionality we want for it!

However, you'll notice in our package.json we have this dependency:

"@nomiclabs/hardhat-ethers": "^2.0.4",

(it could be a different number other than ^2.0.4 depending on when you read this...

This package wraps the ethers package inside the hardhat package to give it extra functionality!

So while in hardhat, we want to use the hardhat wrapped edition of ethers! This is where those extra functions like getContractFactory come from!

That's why we use:

const {ethers} = require("hardhat");

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@Sairam002
Comment options

@PatrickAlphaC
Comment options

@Sairam002
Comment options

@PatrickAlphaC
Comment options

Answer selected by PatrickAlphaC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants