Skip to content

Commit d49b605

Browse files
authored
Improve L1-L2 docs (#726)
* [skip ci]
1 parent fef38cc commit d49b605

File tree

1 file changed

+26
-5
lines changed

1 file changed

+26
-5
lines changed

website/docs/postman.md

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
11
# L1-L2 interaction via Postman
22

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:
44

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.
616

717
## Load
818

@@ -13,7 +23,7 @@ POST /postman/load_l1_messaging_contract
1323
```json
1424
{
1525
"network_url": "http://localhost:8545",
16-
"address": "0x123...def"
26+
"address": "0x123...def" // optional
1727
}
1828
```
1929

@@ -32,9 +42,20 @@ JSON-RPC
3242

3343
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.
3444

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:
3657

37-
- [**Anvil**](https://github.com/foundry-rs/foundry/tree/master/crates/anvil)
58+
- [**Anvil**](https://github.com/foundry-rs/foundry/tree/master#anvil)
3859
- [**Sepolia testnet**](https://sepolia.etherscan.io/)
3960
- [**Ganache**](https://www.npmjs.com/package/ganache)
4061
- [**Geth**](https://github.com/ethereum/go-ethereum#docker-quick-start)

0 commit comments

Comments
 (0)