2

Is it possible with Hardhat to launch a script, wait for its completion (or an error), and then jump into the console, with access to the current environment variables?

When using eth-brownie, or python in general, you can add the -i flag to achieve this. Does the equivalent exist with node/hardhat? If yes, how to do it?

1
  • did you find a solution?
    – Yash Sodha
    Apr 28, 2022 at 11:44

1 Answer 1

1

Question answered here:

"You can use repl.start() at the end of your code to do that.

const repl = require("repl");

const myVariable = 1;
console.log("myVariable: ", myVariable);
// provide extra contexts here to access in the REPL
repl.start().context.myVariable = myVariable;

Note that by default only global variables are accessible in the REPL. If you want to access other variables, you must pass them via context"

repl.start().context.yourVariable

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.