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?

Yakitori
  • 767
  • 2
  • 14

1 Answers1

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
Yakitori
  • 767
  • 2
  • 14