The difference between "yarn hardhat deploy" and "yarn hardhat run scripts/deploy.js" #2657
-
Can anyone tell me the difference between "yarn hardhat deploy" and "yarn hardhat run scripts/deploy.js" I'm confusing Thanks!! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 6 replies
-
The
Hardhat Deploy Before going into the details, here is a very simple summary of the basic feature of hardhat-deploy. hardhat-deploy allows you to write deploy scripts in the deploy folder. Each of these files that look as follows will be executed in turn when you execute the following task: Furthermore, you can also ensure these scripts are executed in the test too by calling await deployments.fixture(['MyContract']) in your test. This is optimized, so if multiple tests use the same contract, the deployment will be executed once and each test will start with the exact same state. This is a huge benefit for testing since you are not required to replicate the deployment procedure in your tests. The tag feature (as seen in the script above) and dependencies will also make your life easier when writing complex deployment procedures. You can even group deploy scripts in different sub folder and ensure they are executed in their logical order. Furthermore hardhat-deploy can also support a multi-chain settings like L1, L2 with multiple deploy folder specific to each network. All of this can also be bundled in a npm package so user of hardhat-deploy can reuse your deployment procedure and get started integrating with your project locally. |
Beta Was this translation helpful? Give feedback.
-
Hey @wxy-sudo On the other hand Additionally, the |
Beta Was this translation helpful? Give feedback.
-
I believe this is not as complicated as in the other replies, and should be kept simple, but for an extensive breakdown, you can go through them! :)
Whereas |
Beta Was this translation helpful? Give feedback.
@wxy-sudo
The
yarn hardhat deploy
command is coming from basically thehardhat-deploy
dependency, which runs all of the deploy scripts that are placed inside the deploy folder of the project. It also ensures that those scripts deploy when we run tests throughfixtures
.yarn hardhat run scripts/deploy.js
is basically a hardhat dependency command that runs only the scripts that we give it through a path likescripts/deploy.js
Hardhat Deploy
It is a copy/paste from docs for quick reading.
Before going into the details, here is a very simple summary of the basic feature of hardhat-deploy.
hardhat-deploy allows you to write deploy scripts in the deploy folder. Each of these files that look as …