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: pages/stack/interop/tutorials/message-passing.mdx
+21-41Lines changed: 21 additions & 41 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -229,11 +229,10 @@ For development purposes, we'll first use autorelay mode to handle message execu
229
229
```
230
230
231
231
This function encodes a call to `setGreeting` and sends it to a contract on another chain.
232
-
233
-
*`abi.encodeCall(Greeter.setGreeting, (greeting))` constructs the [calldata](https://docs.soliditylang.org/en/latest/internals/layout_in_calldata.html) by encoding the function selector and parameters.
234
-
235
-
* The encoded message is then passed to `messenger.sendMessage`, which forwards it to the destination contract (`greeterAddress`) on the specified chain (`greeterChainId`).
236
-
This ensures that `setGreeting` is executed remotely with the provided `greeting` value.
232
+
`abi.encodeCall(Greeter.setGreeting, (greeting))` constructs the [calldata](https://docs.soliditylang.org/en/latest/internals/layout_in_calldata.html) by encoding the function selector and parameters.
233
+
The encoded message is then passed to `messenger.sendMessage`, which forwards it to the destination contract (`greeterAddress`) on the specified chain (`greeterChainId`).
234
+
235
+
This ensures that `setGreeting` is executed remotely with the provided `greeting` value (as long as there is an executing message to relay it).
237
236
</details>
238
237
239
238
7. Deploy `GreetingSender` to chain A.
@@ -501,52 +500,33 @@ In production we will not have this, we need to create our own executing message
501
500
<details>
502
501
<summary>Explanation</summary>
503
502
504
-
1.**Import Required Libraries**
505
-
506
-
* Imports functions from `viem` for wallet creation, HTTP transport, and contract interactions.
507
-
508
-
* Imports `@eth-optimism/viem` utilities for handling OP-Stack-specific actions and interoperability.
509
-
510
-
* Loads ABI definitions from `Greeter.json` and `GreetingSender.json` for contract interactions.
511
-
512
-
2.**Initialize Wallet Clients**
513
-
514
-
* Uses `privateKeyToAccount` to generate an account from an environment variable.
515
-
516
-
* Creates `walletA` for chain `supersimL2A` and `walletB` for chain `supersimL2B`, extending them with Viem's public and OP-Stack-specific actions.
517
-
518
-
3.**Get Contract Instances**
519
-
520
-
* Retrieves contract instances for `greeter` on `walletB` and `greetingSender` on `walletA` using `getContract`.
521
-
522
-
* The addresses are taken from environment variables, and the clients are set to the respective wallets.
523
-
524
-
4.**Direct Greeting on Chain B**
525
-
526
-
* Calls `setGreeting` on `greeter` to store a greeting directly on chain B.
527
-
528
-
* Waits for the transaction to be confirmed using `waitForTransactionReceipt`.
* Calls `setGreeting` on `greetingSender` to send a greeting through chain A.
511
+
In addition to extending the wallets with [Viem public actions](https://viem.sh/docs/accounts/local#5-optional-extend-with-public-actions), extend with the OP-Stack actions, both the public ones and the ones that require an account.
0 commit comments