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: STYLE.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -95,12 +95,12 @@ Examples:
95
95
96
96
Too cold/direct:
97
97
98
-
- First, you'll add the `myAccount` property to the `NetworkConnection` object returned by `network.connect()`.
98
+
- First, you'll add the `myAccount` property to the `NetworkConnection` object returned by `network.create()`.
99
99
100
100
Warm and conversational:
101
101
102
-
- Let's start by adding a `myAccount` property to the `NetworkConnection` object returned by `network.connect()`.
103
-
- The first step is adding the `myAccount` property to the `NetworkConnection` object returned by `network.connect()`.
102
+
- Let's start by adding a `myAccount` property to the `NetworkConnection` object returned by `network.create()`.
103
+
- The first step is adding the `myAccount` property to the `NetworkConnection` object returned by `network.create()`.
104
104
105
105
Note that this is really important, and key to our branding. We don't want our documentation to be perceived too cold/direct just to be slightly more concise.
Copy file name to clipboardExpand all lines: src/content/docs/docs/explanations/edr-simulated-networks.mdx
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,7 +20,7 @@ Unlike connecting to a remote node through JSON-RPC, simulated networks give you
20
20
21
21
The only difference between a blockchain simulated by EDR and a production one is that EDR requires no consensus mechanism or peer-to-peer network, as it's run by a single process each time.
22
22
23
-
When you call `await network.connect()` with a Network Config of type `edr-simulated`, Hardhat creates a new, independent blockchain simulation. Each simulation is isolated, so you can create multiple simulations simultaneously without them interfering with each other.
23
+
When you call `await network.create()` with a Network Config of type `edr-simulated`, Hardhat creates a new, independent blockchain simulation. Each simulation is isolated, so you can create multiple simulations simultaneously without them interfering with each other.
24
24
25
25
## How to use simulated networks
26
26
@@ -33,7 +33,7 @@ When you run your tests or scripts, Hardhat automatically creates an in-process
33
33
```ts
34
34
import { network } from"hardhat";
35
35
36
-
const connection =awaitnetwork.connect();
36
+
const connection =awaitnetwork.create();
37
37
```
38
38
39
39
This creates a new blockchain simulation based on the Network Config specified in your configuration file or via the `--network` flag.
Copy file name to clipboardExpand all lines: src/content/docs/docs/explanations/global-options.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,7 @@ Global Options are options that Hardhat can receive and are available across all
11
11
12
12
They are different from Hardhat Task options and arguments in that they are meant to control the functionality of Hardhat itself, and not that of a single task.
13
13
14
-
For example, `--network` is a global option that controls the default value that `network.connect()` uses when no network config name is provided.
14
+
For example, `--network` is a global option that controls the default value that `network.create()` uses when no network config name is provided.
15
15
16
16
Plugins can define their own Global Options, so the complete list depends on your setup. To see all available options, run:
The network simulation will be created using the `op` Chain Type and its simulation will be stricter.
70
70
71
-
Moreover, the Chain Type information will be available to network-related plugins, both at runtime and at type-level. This allows them to modify their behavior and the result of `network.connect()` depending on the Chain Type, potentially adding more functionality.
71
+
Moreover, the Chain Type information will be available to network-related plugins, both at runtime and at type-level. This allows them to modify their behavior and the result of `network.create()` depending on the Chain Type, potentially adding more functionality.
72
72
73
73
For example, the method highlighted in the snippet above is only available when you're using the `op` Chain Type.
Copy file name to clipboardExpand all lines: src/content/docs/docs/explanations/network-management.mdx
+10-8Lines changed: 10 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -69,14 +69,14 @@ This object allows you to create network connections. You can do it like this:
69
69
```ts
70
70
import { network } from"hardhat";
71
71
72
-
const networkConnection =awaitnetwork.connect();
72
+
const networkConnection =awaitnetwork.create();
73
73
```
74
74
75
75
By default, it creates a `NetworkConnection` using the Network Config called `default`, which is always present. You can choose a different fallback Network Config name by using the `network`[Global Option](/docs/explanations/global-options), like this:
76
76
77
77
<Runcommand="hardhat --network mainnet" />
78
78
79
-
Every time you call `network.connect()` a new independent `NetworkConnection` object is created:
79
+
Every time you call `network.create()` a new independent `NetworkConnection` object is created:
80
80
81
81
- If the Network Config is of type `"http"`, the JSON-RPC server in the `url` setting will be used. No synchronization between two HTTP Network Connections is performed by Hardhat, either at the HTTP layer or at the protocol layer (e.g. when handling account nonces).
82
82
@@ -86,19 +86,21 @@ Every time you call `network.connect()` a new independent `NetworkConnection` ob
86
86
This document makes a distinction between blockchain and Network Config, their names, Network Connection, and creating a Network Connection, to be precise in its explanations.
87
87
88
88
In practice, most people will simplify this vocabulary and just say that, for example, running the command above connected to the network mainnet. Using "connect" interchangeably with creating a Network Connection, and the network name with the blockchain they intend to connect to.
89
+
90
+
If you want to reuse the same connection across different parts of your code, you can use `network.getOrCreate()` instead. It returns an existing connection if one was previously created with the same network name and chain type.
89
91
:::
90
92
91
93
### Using an explicit Network Config
92
94
93
-
You can also create a connection using an explicit Network Config, and not just relying on `--network`. This is done by providing parameters to `network.connect()`:
95
+
You can also create a connection using an explicit Network Config, and not just relying on `--network`. This is done by providing parameters to `network.create()`:
@@ -37,7 +37,7 @@ To skip compilation before starting the console, pass the `--no-compile` flag:
37
37
38
38
The `console` task accepts an optional list of positional arguments. Each argument you provide will be executed as a command immediately after the REPL starts, letting you run a series of commands automatically:
0 commit comments