@@ -47,7 +47,7 @@ Sending an interop message using the `L2ToL2CrossDomainMessenger`:
47
47
48
48
### On source chain (OPChainA 901)
49
49
50
- 1 . Invoke ` L2NativeSuperchainERC20.sentERC20 ` to bridge funds
50
+ 1 . Invoke ` L2NativeSuperchainERC20.sendERC20 ` to bridge funds
51
51
* this leverages ` L2ToL2CrossDomainMessenger.sendMessage ` to make the cross chain call
52
52
2 . Retrieve the log identifier and the message payload for the ` SentMessage ` event.
53
53
@@ -98,34 +98,47 @@ struct Identifier {
98
98
99
99
### Get the log emitted by the ` L2ToL2CrossDomainMessenger `
100
100
101
- The token contract calls the [ L2ToL2CrossDomainMessenger] ( https://github.com/ethereum-optimism/optimism/blob/92ed64e171c6eb9c6a080c626640e8836f0653cc /packages/contracts-bedrock/src/L2/L2ToL2CrossDomainMessenger.sol ) , which emits a message (log) that can be relayed on the destination chain.
101
+ The token contract calls the [ L2ToL2CrossDomainMessenger] ( https://github.com/ethereum-optimism/optimism/blob/develop /packages/contracts-bedrock/src/L2/L2ToL2CrossDomainMessenger.sol ) , which emits a message (log) that can be relayed on the destination chain.
102
102
103
103
``` sh
104
- $ cast logs --address 0x4200000000000000000000000000000000000023 --rpc-url http://127.0.0.1:9545
104
+ cast logs --address 0x4200000000000000000000000000000000000023 --rpc-url http://127.0.0.1:9545
105
+ ```
106
+
107
+ Sample output:
105
108
109
+ ```
106
110
address: 0x4200000000000000000000000000000000000023
107
- blockHash: 0x3905831f1b109ce787d180c1ed977ebf0ff1a6334424a0ae8f3731b035e3f708
108
- blockNumber: 4
109
- data: 0x000000000000000000000000420beef00000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000064d9f50046000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb92266000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb9226600000000000000000000000000000000000000000000000000000000000003e800000000000000000000000000000000000000000000000000000000
110
- logIndex: 1
111
+ blockHash: 0x311f8ccea3fc121aa3af18e0a87766ae56ed3f1d08cae91ec29f34a9919abcc0
112
+ blockNumber: 14
113
+ data: 0x0000000000000000000000004200000000000000000000000000000000000028000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000847cfd6dbc000000000000000000000000420beef000000000000000000000000000000001000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb92266000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb9226600000000000000000000000000000000000000000000000000000000000003e800000000000000000000000000000000000000000000000000000000
114
+ logIndex: 2
115
+ removed: false
111
116
topics: [
112
- 0x382409ac69001e11931a28435afef442cbfd20d9891907e8fa373ba7d351f320
113
- 0x0000000000000000000000000000000000000000000000000000000000000386
114
- 0x000000000000000000000000420beef000000000000000000000000000000001
115
- 0x0000000000000000000000000000000000000000000000000000000000000000
117
+ 0x382409ac69001e11931a28435afef442cbfd20d9891907e8fa373ba7d351f320
118
+ 0x0000000000000000000000000000000000000000000000000000000000000386
119
+ 0x0000000000000000000000004200000000000000000000000000000000000028
120
+ 0x0000000000000000000000000000000000000000000000000000000000000000
116
121
]
117
- ...
122
+ transactionHash: 0x746a3e8a3a0ed0787367c3476269fa3050a2f9113637b563a4579fbc03efe5c4
123
+ transactionIndex: 0
118
124
```
119
125
120
126
### Retrieve the block timestamp the log was emitted in
121
127
122
128
Since the message identifier requires the block timestamp, fetch the block info to get the timestamp.
123
129
124
130
``` sh
125
- $ cast block 0xREPLACE_WITH_CORRECT_BLOCKHASH --rpc-url http://127.0.0.1:9545
126
- ...
127
- timestamp 1728507703
128
- ...
131
+ cast block 0xREPLACE_WITH_CORRECT_BLOCKHASH --rpc-url http://127.0.0.1:9545
132
+ ```
133
+
134
+ Sample output:
135
+
136
+ ```
137
+ // (truncated for brevity)
138
+
139
+ timestamp 1743801675
140
+
141
+ // ...
129
142
```
130
143
131
144
### Prepare the message identifier & payload
@@ -144,17 +157,82 @@ struct Identifier {
144
157
145
158
```
146
159
0x + 382409ac69001e11931a28435afef442cbfd20d9891907e8fa373ba7d351f320
147
- + 0000000000000000000000000000000000000000000000000000000000000386
148
- + 000000000000000000000000420beef000000000000000000000000000000001
149
- + 0000000000000000000000000000000000000000000000000000000000000000
150
- + 000000000000000000000000420beef00000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000064d9f50046000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb92266000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb9226600000000000000000000000000000000000000000000000000000000000003e800000000000000000000000000000000000000000000000000000000
160
+ + 0000000000000000000000000000000000000000000000000000000000000386
161
+ + 0000000000000000000000004200000000000000000000000000000000000028
162
+ + 0000000000000000000000000000000000000000000000000000000000000000
163
+ + 0000000000000000000000004200000000000000000000000000000000000028000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000847cfd6dbc000000000000000000000000420beef000000000000000000000000000000001000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb92266000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb9226600000000000000000000000000000000000000000000000000000000000003e800000000000000000000000000000000000000000000000000000000
164
+ ```
165
+
166
+ Payload: ` 0x382409ac69001e11931a28435afef442cbfd20d9891907e8fa373ba7d351f3200000000000000000000000000000000000000000000000000000000000000386000000000000000000000000420000000000000000000000000000000000002800000000000000000000000000000000000000000000000000000000000000000000000000000000000000004200000000000000000000000000000000000028000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000847cfd6dbc000000000000000000000000420beef000000000000000000000000000000001000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb92266000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb9226600000000000000000000000000000000000000000000000000000000000003e800000000000000000000000000000000000000000000000000000000 `
167
+
168
+ ### Construct the access list for the message
169
+
170
+ An access list must be passed along with the relay message tx. There are two admin RPC methods that can be used to construct the access list: ` admin_getAccessListByMsgHash ` and ` admin_getAccessListForIdentifier ` and.
171
+
172
+ a. To get the access list using the ` admin_getAccessListByMsgHash ` RPC method, call the method with the message hash.
173
+
174
+ 1 . Retrieve the message hash from the supersim logs
175
+
176
+ ``` sh
177
+ INFO [04-04| 14:21:15.587] L2ToL2CrossChainMessenger#SentMessage sourceChainID=901 destinationChainID=902 nonce=0 sender=0x4200000000000000000000000000000000000028 target=0x4200000000000000000000000000000000000028 msgHash=0xccff97c17ef11d659d319cbc5780235ea03ef34b0fa34f40b208a9519f257379 txHash=0x746a3e8a3a0ed0787367c3476269fa3050a2f9113637b563a4579fbc03efe5c4
151
178
```
152
179
153
- Payload: ` 0x382409ac69001e11931a28435afef442cbfd20d9891907e8fa373ba7d351f3200000000000000000000000000000000000000000000000000000000000000386000000000000000000000000420beef0000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000420beef00000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000064d9f50046000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb92266000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb9226600000000000000000000000000000000000000000000000000000000000003e800000000000000000000000000000000000000000000000000000000 `
180
+ 2 . Call ` admin_getAccessListByMsgHash ` with the message hash.
181
+
182
+ ``` sh
183
+ cast rpc admin_getAccessListByMsgHash 0xccff97c17ef11d659d319cbc5780235ea03ef34b0fa34f40b208a9519f257379 --rpc-url http://localhost:8420
184
+ ```
185
+
186
+ Sample output:
187
+
188
+ ```
189
+ {
190
+ "accessList": [
191
+ {
192
+ "address": "0x4200000000000000000000000000000000000022",
193
+ "storageKeys": [
194
+ "0x010000000000000000000385000000000000000e0000000067f04d4b00000002",
195
+ "0x03c6d2648cef120ce1d7ccf9f8d4042d6b25ff30a02e22d9ea2a47d2677ccb8d"
196
+ ]
197
+ }
198
+ ]
199
+ }
200
+ ```
201
+
202
+ b. To get the access list using the ` admin_getAccessListForIdentifier ` RPC method, call the method with the identifier and the message payload.
203
+
204
+ ``` sh
205
+ cast rpc admin_getAccessListForIdentifier \
206
+ ' {
207
+ "origin": "0x4200000000000000000000000000000000000023",
208
+ "blockNumber": "14",
209
+ "logIndex": "2",
210
+ "timestamp": "1743801675",
211
+ "chainId": "901",
212
+ "payload": "0x382409ac69001e11931a28435afef442cbfd20d9891907e8fa373ba7d351f3200000000000000000000000000000000000000000000000000000000000000386000000000000000000000000420000000000000000000000000000000000002800000000000000000000000000000000000000000000000000000000000000000000000000000000000000004200000000000000000000000000000000000028000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000847cfd6dbc000000000000000000000000420beef000000000000000000000000000000001000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb92266000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb9226600000000000000000000000000000000000000000000000000000000000003e800000000000000000000000000000000000000000000000000000000"
213
+ }' \
214
+ --rpc-url http://localhost:8420
215
+ ```
216
+
217
+ Sample output:
218
+
219
+ ```
220
+ {
221
+ "accessList": [
222
+ {
223
+ "address": "0x4200000000000000000000000000000000000022",
224
+ "storageKeys": [
225
+ "0x010000000000000000000385000000000000000e0000000067f04d4b00000002",
226
+ "0x03c6d2648cef120ce1d7ccf9f8d4042d6b25ff30a02e22d9ea2a47d2677ccb8d"
227
+ ]
228
+ }
229
+ ]
230
+ }
231
+ ```
154
232
155
233
### Send the relayMessage transaction
156
234
157
- Call ` relayMessage ` on the [ L2ToL2CrossDomainMessenger] ( https://github.com/ethereum-optimism/optimism/blob/92ed64e171c6eb9c6a080c626640e8836f0653cc /packages/contracts-bedrock/src/L2/L2ToL2CrossDomainMessenger.sol#L126 )
235
+ Call ` relayMessage ` on the [ L2ToL2CrossDomainMessenger] ( https://github.com/ethereum-optimism/optimism/blob/develop /packages/contracts-bedrock/src/L2/L2ToL2CrossDomainMessenger.sol ) with the access list.
158
236
159
237
``` solidity
160
238
// L2ToL2CrossDomainMessenger.sol (truncated for brevity)
@@ -180,10 +258,11 @@ struct Identifier {
180
258
Below is an example call, but make sure to replace them with the correct values you received in previous steps.
181
259
182
260
``` sh
183
- $ cast send 0x4200000000000000000000000000000000000023 --gas-limit 200000 \
261
+ cast send 0x4200000000000000000000000000000000000023 \
184
262
" relayMessage((address, uint256, uint256, uint256, uint256), bytes)" \
185
- " (0x4200000000000000000000000000000000000023, 4, 1, 1728507703, 901)" \
186
- 0x382409ac69001e11931a28435afef442cbfd20d9891907e8fa373ba7d351f3200000000000000000000000000000000000000000000000000000000000000386000000000000000000000000420beef0000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000420beef00000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000064d9f50046000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb92266000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb9226600000000000000000000000000000000000000000000000000000000000003e800000000000000000000000000000000000000000000000000000000 \
263
+ " (0x4200000000000000000000000000000000000023, 14, 2, 1743801675, 901)" \
264
+ 0x382409ac69001e11931a28435afef442cbfd20d9891907e8fa373ba7d351f3200000000000000000000000000000000000000000000000000000000000000386000000000000000000000000420000000000000000000000000000000000002800000000000000000000000000000000000000000000000000000000000000000000000000000000000000004200000000000000000000000000000000000028000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000847cfd6dbc000000000000000000000000420beef000000000000000000000000000000001000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb92266000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb9226600000000000000000000000000000000000000000000000000000000000003e800000000000000000000000000000000000000000000000000000000 \
265
+ --access-list ' [{"address":"0x4200000000000000000000000000000000000022","storageKeys":["0x010000000000000000000385000000000000000e0000000067f04d4b00000002", "0x03c6d2648cef120ce1d7ccf9f8d4042d6b25ff30a02e22d9ea2a47d2677ccb8d"]}]' \
187
266
--rpc-url http://127.0.0.1:9546 \
188
267
--private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
189
268
```
0 commit comments