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: website/docs/postman.md
+26-5Lines changed: 26 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,18 @@
1
1
# L1-L2 interaction via Postman
2
2
3
-
Postman is a Starknet utility that allows testing L1-L2 interaction. It is **unrelated** to the [Postman API platform](https://www.postman.com/). Ensure you have an L1 node and a Devnet (L2 node) running, [load](#load) a messaging contract, and [flush](#flush) the queue to transmit the messages to their destinations. The functionality relies on two internal message queues: one for L1->L2 messages, another for L2->L1 messages.
3
+
Postman is a Starknet utility that allows testing L1-L2 interaction. It is **unrelated** to the [Postman API platform](https://www.postman.com/). To use it, ensure you have:
4
4
5
-
You can use [**`starknet-devnet-js`**](https://github.com/0xSpaceShard/starknet-devnet-js) to perform these actions, as witnessed in [**this example**](https://github.com/0xSpaceShard/starknet-devnet-js/blob/master/test/l1-l2-postman.test.ts), or directly send requests to the endpoints specified below.
5
+
- an L1 node (possibilities listed [below](#l1-network))
6
+
- a Devnet instance (acting as L2 node)
7
+
- a [loaded](#load) messaging contract
8
+
- this is an L1 contract for exchanging messages between L1 and L2
9
+
- you can deploy a new instance or specify the address of an old one
10
+
- an L1 contract that can interact with the messaging contract
11
+
- an L2 contract that can interact with the messaging contract
12
+
13
+
There are two internal message queues: one for L1->L2 messages, another for L2->L1 messages. When there are messages in a queue, you will need to [flush](#flush) to transmit the messages to their destinations.
14
+
15
+
You can use [**`starknet-devnet-js`**](https://github.com/0xSpaceShard/starknet-devnet-js) to assist you in the above listed actions. [**This example**](https://github.com/0xSpaceShard/starknet-devnet-js/blob/master/test/l1-l2-postman.test.ts), especially the `it("should exchange messages between L1 and L2")` test case should be of most help. The required contracts are configured and deployed in the `before` block. Alternatively, you can directly send requests to the endpoints specified below.
6
16
7
17
## Load
8
18
@@ -13,7 +23,7 @@ POST /postman/load_l1_messaging_contract
13
23
```json
14
24
{
15
25
"network_url": "http://localhost:8545",
16
-
"address": "0x123...def"
26
+
"address": "0x123...def"// optional
17
27
}
18
28
```
19
29
@@ -32,9 +42,20 @@ JSON-RPC
32
42
33
43
Loads a `MockStarknetMessaging` contract. The `address` parameter is optional; if provided, the `MockStarknetMessaging` contract will be fetched from that address, otherwise a new one will be deployed.
34
44
35
-
`network_url` is the URL of the JSON-RPC API of the L1 node you've run locally or that already exists; possibilities include, and are not limited to:
45
+
:::note L1-L2 with dockerized Devnet
46
+
47
+
L1-L2 communication requires extra attention if Devnet is [run in a Docker container](./running/docker.md). The `network_url` argument must be on the same network as Devnet. E.g. if your L1 instance is run locally (i.e. using the host machine's network), then:
48
+
49
+
- on Linux, it is enough to run the Devnet Docker container with `--network host`
50
+
- on Mac and Windows, replace any `http://localhost` or `http://127.0.0.1` occurrence in the value of `network_url` with `http://host.docker.internal`.
51
+
52
+
:::
53
+
54
+
### L1 network
55
+
56
+
The `network_url` parameter refers to the URL of the JSON-RPC API endpoint of the L1 node you've run locally, or which is publicly accessible. Possibilities include, but are not limited to:
0 commit comments