-
Notifications
You must be signed in to change notification settings - Fork 263
How to use general message passing #1032
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
86b2b0f
Added contents for general message passing on OP Stack
krofax e95498f
Cleaned the code
krofax 483c5a6
Update pages/stack/interop/message-passing.mdx
krofax 8b21235
Update pages/stack/interop/message-passing.mdx
krofax b470e82
fix conflict
krofax ad62629
fix conflict
krofax 9ed4706
Updated the contents
krofax 2df4786
fix lint issues
krofax 89e9fb8
update title
krofax ce9b836
Update pages/stack/interop/_meta.json
krofax 37de46e
fix merge conflict
krofax 21d3139
update meta.json
krofax 5fe83b5
Merge branch 'main' into message-passing
krofax File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
--- | ||
title: Interop message passing overview | ||
lang: en-US | ||
description: Learn about cross-chain message passing in the Superchain. | ||
--- | ||
|
||
import { Callout, Steps } from 'nextra/components' | ||
|
||
# Interop message passing overview | ||
|
||
<Callout> | ||
Interop is currently in active development and not yet ready for production use. The information provided here may change. Check back regularly for the most up-to-date information. | ||
</Callout> | ||
|
||
This guide provides an overview of cross-chain message passing in the Superchain. | ||
|
||
## Overview | ||
|
||
The Superchain uses a pull-based event system for cross-chain communication. Messages are sent through the `L2ToL2CrossDomainMessenger` contract, which provides a secure and standardized way to pass information between chains. | ||
krofax marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## How it works | ||
|
||
The following diagram illustrates how messages flow between chains through the `L2ToL2CrossDomainMessenger` contract, which acts as a bridge for cross-chain communication. When a contract on the source chain initiates a message, it's processed through several stages before reaching its destination, ensuring secure and reliable message delivery. | ||
|
||
```mermaid | ||
sequenceDiagram | ||
participant Source as Source Chain | ||
participant Messenger as L2ToL2CrossDomainMessenger | ||
participant Dest as Destination Chain | ||
|
||
Note over Source,Dest: Message Creation | ||
Source->>Messenger: Emit message event | ||
Note over Source,Dest: Message Serialization | ||
Messenger-->>Messenger: Convert to standard format | ||
Note over Source,Dest: Identifier Creation | ||
Messenger-->>Messenger: Generate unique ID | ||
Note over Source,Dest: Message Execution | ||
Messenger->>Dest: Process message | ||
``` | ||
krofax marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Cross-chain messaging involves four main phases: | ||
|
||
1. **Message Creation**: The source chain contract emits an event containing the message data and destination information. This event serves as the initiating message that will be relayed across chains. | ||
|
||
2. **Message Serialization**: The messenger contract converts the event data into a standardized format that can be consistently processed across different chains in the Superchain. | ||
|
||
3. **Identifier Creation**: A unique identifier is generated for the message, containing information about its `origin`, `timestamp`, and other `metadata`. This identifier helps track and verify the message. | ||
|
||
4. **Message Execution**: The destination chain receives and processes the message, executing any associated actions or state changes specified in the original message. | ||
|
||
krofax marked this conversation as resolved.
Show resolved
Hide resolved
|
||
For detailed implementation steps and code examples, see our [message passing implementation guide](https://supersim.pages.dev/guides/interop/relay-using-viem.html). | ||
|
||
## Common Use Cases | ||
|
||
* Simple messages between identical contracts | ||
* Complex multi-contract interactions | ||
* Cross-chain state synchronization | ||
* Token transfers and bridging | ||
|
||
For a practical example, see our [cross-chain ping pong tutorial](https://supersim.pages.dev/guides/interop/cross-chain-contract-via-l2cdm). | ||
|
||
## Next steps | ||
|
||
* Read about the [anatomy of a cross-chain message](/stack/interop/cross-chain-message) | ||
* Try [Supersim](supersim) for testing cross-chain messages locally | ||
* Learn about [manually relaying messages](https://supersim.pages.dev/guides/interop/manually-relaying-interop-messages-cast) | ||
krofax marked this conversation as resolved.
Show resolved
Hide resolved
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.