forked from NomicFoundation/hardhat-ignition-examples
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBasicDeploymentsModule.js
36 lines (32 loc) · 1.26 KB
/
BasicDeploymentsModule.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const { buildModule } = require("@nomicfoundation/hardhat-ignition");
module.exports = buildModule("BasicDeployments", (m) => {
// You can deploy a contract by calling the `contract` function
// and passing its name and constructor params.
//
// The contract function returns a Future object, that represents
// the contract to be deployed.
//
// Each Future has unique id, which is used to identify it, which
// Ignition normally autogenerates based on the contract name.
const helloWorld = m.contract("HelloWorld", ["Hello, world!"]);
// You can use Futures as arguments to create other Futures.
const wrappedHelloWorld = m.contract("WrappedHelloWorld", [helloWorld]);
// You can also deploy a contract from an artifact
//
// In this case, we are deploying two instances of HelloWorld, so the
// second one requires an explicit id.
const holaMundo = m.contract(
"HelloWorld",
// We require the artifact manually for this example
require("../artifacts/contracts/BasicDeployments.sol/HelloWorld.json"),
["Hola, mundo!"],
{ id: "HolaMundo" }
);
// Finally, you can return the contract futures that you want to expose to
// Ignition, tests, and other modules.
return {
helloWorld,
wrappedHelloWorld,
holaMundo,
};
});