1

I'm starting to use HardHat for my project and I created a list of (super useful) tasks ans now I'm trying to implement tests and I want to use some task (like deploy to setup my smart-contract environment without re-writing the code everywhere.

Is this possible ? Thank

2
  • 1
    Pro tip: use my Solidity template the next time you start a Hardhat project from scratch, to save time on setting up your development environment. Commented Mar 25, 2022 at 13:29
  • Yes I already saw your project (multiple times, limit spam, but) I have to admit it's probably the best hardhat boilerplate. I cloned it and check sometime but I prefer understand what I'm doing (as first project, maybe 2de I'll start from your)
    – Arthur
    Commented Mar 25, 2022 at 13:40

1 Answer 1

2

Yes you can run a Hardhat task programmatically by importing the run function from the Hardhat Runtime Environment:

import { run } from "hardhat";

run("task-name");

See the docs for more examples.

1
  • Yes thank. I already read all the hh doc but actually a miss this part ! (Awesome)
    – Arthur
    Commented Mar 25, 2022 at 13:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.