importing hardhat
in javascript
to compile
solidity code
#4982
Closed
hammersharkfish
started this conversation in
General
Replies: 2 comments 1 reply
-
You can run Hardhat's tasks programmatically from a script: // ./scripts/compile.js
// Import Hardhat's runtime environment
const hre = require("hardhat");
async function main() {
// Run the compile task
await hre.run("compile");
console.log("Compilation finished successfully");
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
}); You can then run the script with: npx hardhat run ./scripts/compile.js |
Beta Was this translation helpful? Give feedback.
1 reply
-
This works when compiling local hardhat project (thank you for that) but when I try to point it outside the project directory it throws
My understanding is |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I want to use
hardhat
tocompile
in a script and not in bash is there any way to achieve this ?import hardhat from "hardhat" . . . hardhat.compile(" pragma solidity ...")
Beta Was this translation helpful? Give feedback.
All reactions