@@ -101,11 +101,11 @@ For development purposes, we'll first use autorelay mode to handle message execu
101101
102102 Supersim creates three ` anvil ` blockchains:
103103
104- | Role | ChainID | RPC URL |
105- | -------* | ------: | ---------------------------------------------* |
106- | L1 | 900 | [ http://127.0.0.1:8545 ] ( http://127.0.0.1:8545 ) |
107- | OPChainA | 901 | [ http://127.0.0.1:9545 ] ( http://127.0.0.1:9545 ) |
108- | OPChainB | 902 | [ http://127.0.0.1:9546 ] ( http://127.0.0.1:9546 ) |
104+ \ | Role | ChainID | RPC URL |
105+ \ | -------\ * | ------: | ---------------------------------------------\ * |
106+ \ | L1 | 900 | [ http://127.0.0.1:8545 ] ( http://127.0.0.1:8545 ) |
107+ \ | OPChainA | 901 | [ http://127.0.0.1:9545 ] ( http://127.0.0.1:9545 ) |
108+ \ | OPChainB | 902 | [ http://127.0.0.1:9546 ] ( http://127.0.0.1:9546 ) |
109109
110110 2 . In a separate shell, store the configuration in environment variables.
111111
@@ -493,41 +493,47 @@ In production we will not have this, we need to create our own executing message
493493 ``` js file=<rootDir>/public/tutorials/app.mts#L1-L51 hash=8f6f776884b8e37ae613f7aea8cd6a3b
494494 ```
495495
496- <details >
497- <summary >Explanation</summary >
496+ <details >
497+ <summary >Explanation</summary >
498498
499- 1 . ** Import Required Libraries**
500- * Imports functions from ` viem ` for wallet creation, HTTP transport, and contract interactions.
501- * Imports ` @eth-optimism/viem ` utilities for handling OP-Stack-specific actions and interoperability.
502- * Loads ABI definitions from ` Greeter.json ` and ` GreetingSender.json ` for contract interactions.
499+ 1 . ** Import Required Libraries**
503500
504- 2 . ** Initialize Wallet Clients **
505- * Uses ` privateKeyToAccount ` to generate an account from an environment variable.
506- * Creates ` walletA ` for chain ` supersimL2A ` and ` walletB ` for chain ` supersimL2B ` , extending them with Viem’s public and OP-Stack-specific actions.
501+ * Imports functions from ` viem ` for wallet creation, HTTP transport, and contract interactions.
502+ * Imports ` @eth-optimism/viem ` utilities for handling OP-Stack-specific actions and interoperability.
503+ * Loads ABI definitions from ` Greeter.json ` and ` GreetingSender.json ` for contract interactions.
507504
508- 3 . ** Get Contract Instances**
509- * Retrieves contract instances for ` greeter ` on ` walletB ` and ` greetingSender ` on ` walletA ` using ` getContract ` .
510- * The addresses are taken from environment variables, and the clients are set to the respective wallets.
505+ 2 . ** Initialize Wallet Clients**
511506
512- 4 . ** Direct Greeting on Chain B**
513- * Calls ` setGreeting ` on ` greeter ` to store a greeting directly on chain B.
514- * Waits for the transaction to be confirmed using ` waitForTransactionReceipt ` .
515- * Reads and logs the greeting stored on chain B.
507+ * Uses ` privateKeyToAccount ` to generate an account from an environment variable.
508+ * Creates ` walletA ` for chain ` supersimL2A ` and ` walletB ` for chain ` supersimL2B ` , extending them with Viem's public and OP-Stack-specific actions.
516509
517- 5 . ** Cross-Chain Greeting via Chain A**
518- * Calls ` setGreeting ` on ` greetingSender ` to send a greeting through chain A.
519- * Waits for the transaction receipt on chain A.
510+ 3 . ** Get Contract Instances**
520511
521- 6 . ** Retrieve and Relay the Cross-Chain Message**
522- * Extracts the message from the transaction receipt using ` createInteropSentL2ToL2Messages ` .
523- * Relays the message to chain B using ` walletB.interop.relayMessage ` .
524- * Waits for confirmation of the relay transaction.
512+ * Retrieves contract instances for ` greeter ` on ` walletB ` and ` greetingSender ` on ` walletA ` using ` getContract ` .
513+ * The addresses are taken from environment variables, and the clients are set to the respective wallets.
525514
526- 7 . ** Verify the Updated Greeting on Chain B**
527- * Reads the greeting from ` greeter ` after the relay process.
528- * Logs the updated greeting, showing that it was successfully relayed from chain A to chain B.
515+ 4 . ** Direct Greeting on Chain B**
529516
530- </details >
517+ * Calls ` setGreeting ` on ` greeter ` to store a greeting directly on chain B.
518+ * Waits for the transaction to be confirmed using ` waitForTransactionReceipt ` .
519+ * Reads and logs the greeting stored on chain B.
520+
521+ 5 . ** Cross-Chain Greeting via Chain A**
522+
523+ * Calls ` setGreeting ` on ` greetingSender ` to send a greeting through chain A.
524+ * Waits for the transaction receipt on chain A.
525+
526+ 6 . ** Retrieve and Relay the Cross-Chain Message**
527+
528+ * Extracts the message from the transaction receipt using ` createInteropSentL2ToL2Messages ` .
529+ * Relays the message to chain B using ` walletB.interop.relayMessage ` .
530+ * Waits for confirmation of the relay transaction.
531+
532+ 7 . ** Verify the Updated Greeting on Chain B**
533+
534+ * Reads the greeting from ` greeter ` after the relay process.
535+ * Logs the updated greeting, showing that it was successfully relayed from chain A to chain B.
536+ </details >
531537
532538 2 . Rerun the JavaScript program, and see that the message is relayed.
533539
@@ -540,22 +546,22 @@ In production we will not have this, we need to create our own executing message
540546 The same contracts are deployed on [ the devnet] ( ../tools/devnet ) .
541547 You can relay messages in exactly the same way you'd do it on Supersim.
542548
543- | Contract | Network | Address |
544- | ---------------* | -------------------------------------------* | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------* |
545- | ` Greeter ` | [ Devnet 1] ( ../tools/devnet#interop-devnet-1 ) | [ ` 0x1A183FCf61053B7dcd2322BbE766f7E1946d3718 ` ] ( https://sid.testnet.routescan.io/address/0x1A183FCf61053B7dcd2322BbE766f7E1946d3718 ) |
546- | ` GreetingSender ` | [ Devnet 0] ( ../tools/devnet#interop-devnet-1 ) | [ ` 0x9De9f84a4EB3616B44CF1d68cD1A9098Df6cB25f ` ] ( https://sid.testnet.routescan.io/address/0x9De9f84a4EB3616B44CF1d68cD1A9098Df6cB25f/contract/420120000/readContract?chainid=420120000 ) |
549+ \ | Contract | Network | Address |
550+ \ | ---------------\ * | -------------------------------------------\ * | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------\ * |
551+ \ | ` Greeter ` | [ Devnet 1] ( ../tools/devnet#interop-devnet-1 ) | [ ` 0x1A183FCf61053B7dcd2322BbE766f7E1946d3718 ` ] ( https://sid.testnet.routescan.io/address/0x1A183FCf61053B7dcd2322BbE766f7E1946d3718 ) |
552+ \ | ` GreetingSender ` | [ Devnet 0] ( ../tools/devnet#interop-devnet-1 ) | [ ` 0x9De9f84a4EB3616B44CF1d68cD1A9098Df6cB25f ` ] ( https://sid.testnet.routescan.io/address/0x9De9f84a4EB3616B44CF1d68cD1A9098Df6cB25f/contract/420120000/readContract?chainid=420120000 ) |
547553
548554 To modify the program to relay messagez on devnet, follow these steps:
549555
550556 1 . In ` src/app.mts ` , replace these lines to update the chains and contract addresses.
551557
552- | Line number | New content |
553- | ----------: | -------------------------------------------------------------------------* |
554- | 10 | ` import { interopAlpha0, interopAlpha1 } from '@eth-optimism/viem/chains' ` |
555- | 24 | ` chain: interopAlpha0, ` |
556- | 32 | ` chain: interopAlpha1, ` |
557- | 40 | ` address: "0x1A183FCf61053B7dcd2322BbE766f7E1946d3718", ` |
558- | 46 | ` address: "0x9De9f84a4EB3616B44CF1d68cD1A9098Df6cB25f", ` |
558+ \ | Line number | New content |
559+ \ | ----------: | -------------------------------------------------------------------------\ * |
560+ \ | 10 | ` import { interopAlpha0, interopAlpha1 } from '@eth-optimism/viem/chains' ` |
561+ \ | 24 | ` chain: interopAlpha0, ` |
562+ \ | 32 | ` chain: interopAlpha1, ` |
563+ \ | 40 | ` address: "0x1A183FCf61053B7dcd2322BbE766f7E1946d3718", ` |
564+ \ | 46 | ` address: "0x9De9f84a4EB3616B44CF1d68cD1A9098Df6cB25f", ` |
559565
560566 2 . Set ` PRIV_KEY ` to the private key of an address that has Sepolia ETH on the two chains.
561567
0 commit comments