Replies: 1 comment 1 reply
|
Hi @evbots. This is not possible right now. We want to add some way to programmatically create Hardhat contexts, which wouldn't modify the global scope and would probably be what you want. But we don't have that feature yet. Without knowing a lot about your app, my guess is that your best shot is to call Hardhat in a sub-process. For example, you can do something like this: const { exec } = require("child_process")
const child = exec("npx hardhat compile", { cwd: pathToProjectRoot })
// read stdout and stderr from child, wait for it to finish, etc.There's a lot to hate about this solution, and there are several ways it can be improved (like using |
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hi hardhat community,
I'm attempting to use hardhat as a javascript library inside a web server to compile contracts "on the fly".
My web server does these things:
Each user request requires saving contract output in a different artifacts directory, which is why I need to pass in that config into an Environment constructor (as shown below in my example).
I am using hardhat successfully, but I've noticed that I'm not able to just create objects in local scope. I can't seem to create an
Environmentobject without creating aHardhatContextobject, which appears to inject a variable into the global scope.Is there a way to use hardhat that does not inject objects into the global scope? This would address my worries that there is some kind of race condition happening inside global scope if the web server is serving multiple requests at the same time.
Thank you! Example below.
All reactions