You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: docs/src/content/ignition/docs/guides/scripts.md
+16-10
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,10 @@
1
-
# Advanced deployment with Hardhat scripts
1
+
# Deploying within Hardhat scripts
2
2
3
3
Hardhat Ignition is a powerful deployment engine, but you may find there are some programming concepts that are not allowed within an Ignition module. Conditional logic, `async/await`, and `console.log` of deployment variables are some examples of operations that cannot be performed within an Ignition module. However, this guide will show you how you can perform all of these operations by pairing Ignition with Hardhat scripts.
4
4
5
5
:::tip
6
6
7
-
This guide will be using the contracts and Ignition module from the [quick start guide](/ignition/docs/getting-started#quick-start), but you can follow along in your own project if you prefer.
7
+
This guide will be using the contracts and Ignition module from the [quick start guide](/ignition/docs/getting-started#quick-start).
8
8
9
9
:::
10
10
@@ -22,7 +22,7 @@ import ApolloModule from "../ignition/modules/Apollo";
22
22
asyncfunction main() {
23
23
const { apollo } =awaithre.ignition.deploy(ApolloModule);
24
24
25
-
console.log(`Apollo deployed to: ${apollo.target}`);
25
+
console.log(`Apollo deployed to: ${awaitapollo.getAddress()}`);
In this script, we've added a new function called `getRocketNameFromAPI`, which simulates an asynchronous API call. We then call this function to retrieve the rocket name and pass it as a parameter to the Ignition module when deploying the `Apollo` module. You can run this script using the same command as before.
171
+
In this script, we've added a new function called `getRocketNameFromAPI`, which simulates an asynchronous API call. We then call this function to retrieve the rocket name and pass it as a parameter under the named Ignition module when deploying the `Apollo` module. You can run this script using the same command as before.
172
+
173
+
:::tip
174
+
175
+
You can read more about defining and using parameters in Ignition modules in the [deployment guide](/ignition/docs/guides/deploy#defining-parameters-during-deployment).
176
+
177
+
:::
172
178
173
179
## Conditional logic
174
180
@@ -194,7 +200,7 @@ async function main() {
194
200
parameters: { Apollo: { rocketName } },
195
201
});
196
202
197
-
console.log(`Apollo deployed to: ${apollo.target}`);
203
+
console.log(`Apollo deployed to: ${awaitapollo.getAddress()}`);
198
204
} else {
199
205
console.log("No name given for Rocket contract, skipping deployment");
200
206
}
@@ -223,7 +229,7 @@ async function main() {
223
229
parameters: { Apollo: { rocketName } },
224
230
});
225
231
226
-
console.log(`Apollo deployed to: ${apollo.target}`);
232
+
console.log(`Apollo deployed to: ${awaitapollo.getAddress()}`);
227
233
} else {
228
234
console.log("No name given for Rocket contract, skipping deployment");
229
235
}
@@ -238,4 +244,4 @@ main().catch(console.error);
238
244
239
245
In this script, we've added an `if` statement to check if the `rocketName` is not `undefined`. If it is not `undefined`, we proceed with deploying the `Apollo` module; otherwise, we log a message to the console indicating that the deployment has been skipped. You can run this script using the same command as before.
240
246
241
-
By combining Ignition with Hardhat scripts, you can perform advanced deployment operations that are not possible within an Ignition module alone. These are just a few examples of what you can achieve with this powerful combination. Feel free to experiment further and explore the possibilities!
247
+
By combining Hardhat Ignition with Hardhat scripts, you can perform advanced deployment operations that are not possible within an Ignition module alone. These are just a few examples of what you can achieve with this powerful combination. Feel free to experiment further and explore the possibilities!
0 commit comments