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
The Scroll Messenger contracts allow for sending arbitrary messages from L1 to L2 or vice versa. This enables executing functions on another chain in a secure and permissionless way. To send a message from L1 to L2, use
14
-
the messenger smart contract deployed on L1, `L1ScrollMessenger`. To send a message from L2 to L1, use the contract deployed on L2, `L2ScrollMessenger`.
15
-
16
-
<Asidetype="caution"title="">
17
-
When sending a transaction through the **Scroll Messenger** deployed on L1 and L2, the resulting transaction sender
18
-
(`CALLER` or `msg.sender`) will be the Messenger Contract address deployed on the receiving chain.
19
-
<br />
20
-
In future Scroll versions, enforced transactions from the L1 will allow setting the sender on L2 as the original EOA
21
-
on L1. It will also allow 3rd parties to relay signed transactions securely.
22
-
</Aside>
13
+
The Scroll Messenger contracts allow for sending arbitrary messages from L1 to L2 or vice versa. This enables executing functions on another chain in a secure and permissionless way. To send a message from L1 to L2, use the messenger smart contract deployed on L1, `L1ScrollMessenger`. To send a message from L2 to L1, use the contract deployed on L2, `L2ScrollMessenger`. You can find the smart contract addresses in the [Scroll Contracts](/developers/scroll-contracts) page.
14
+
15
+
## Sending a Message
16
+
17
+
Sending a cross-chain message through the `ScrollMessenger` is performed by calling the [`sendMessage`](#sendmessage) function. In this function you set the `target` address that will receive the message in the other chain, a `value` parameter for ETH transfers and `message` byte array to be sent as `CALLDATA` for smart contract execution. Notice the contract also expects a `gasLimit` parameter that you can safely set to `0` and a `refundAddress` which you can set as the sender EOA. These last two parameters are legacy since L1 to L2 transactions don't need to pay gas and L2 to L1 gas costs are handled differently, as we’ll cover in the next section.
23
18
24
-
## Finalizing transactions on L1
19
+
## Relaying Transactions on L1
25
20
26
-
Any upcoming transactions from L2 need to be finalized using the `relayMessageWithProof` function on the Scroll Messenger
27
-
contract. We call this process "submitting an Execute Withdrawal transaction," and it is required for both sending arbitrary messages and transferring assets through a gateway or the router. When you use `relayMessageWithProof`, you'll have to provide a Merkle inclusion proof showing your transaction is included in the trie of "withdrawal" messages, along with other parameters. Producing this proof and these values can be done locally and permissionlessly, but at the moment, the easiest way to retrieve these parameters is through our backend APIs:
21
+
Unlike L1 to L2 transactions, L2 to L1 transactions need to be finalized using the [`relayMessageWithProof`](#relaymessagewithproof) function on the Scroll Messenger contract. We call this process "submitting an Execute Withdrawal transaction", and it is required for both sending arbitrary messages and transferring assets through a gateway or the router. When you use `relayMessageWithProof`, you'll have to provide a Merkle inclusion proof showing your transaction is included in the trie of "withdrawal" messages, along with other parameters. Producing this proof and these values can be done locally and permissionlessly, but at the moment, the easiest way to retrieve these parameters is through our backend APIs:
This API was made for our Bridge UI. It is not yet finalized and may change in the future. We will update this guide
34
-
when the API is finalized. Additionally, all examples below use the Sepolia API service -- the calls should be easily
35
-
adapted to work on mainnet.
36
-
</Aside>
37
-
38
-
Supply the address of the EOA or contract responsible for initiating the original transaction on L2 to the `/claimable`
39
-
endpoint. The API backend will provide you with all the necessary information to successfully conclude the transaction on L1.
40
-
Take a look at the following example:
26
+
Supply the address of the EOA or contract responsible for initiating the original transaction on L2 to the `/unclaimed` endpoint. The API backend will provide you with all the necessary information to successfully conclude the transaction on L1. Take a look at the following example:
The `address` parameter on the `/withdrawals` endpoint expects the sender EOA or contract address in the case sensitive [EIP-55 Mixed-cased Checksum](https://eips.ethereum.org/EIPS/eip-55) format.
34
+
</Aside>
35
+
46
36
The API should return your transaction data in the following format:
The `claimInfo` object under the `result` json returned has all the information needed to execute your transaction on L1. The
90
-
parameters needed by the `relayMessageWithProof` are: `from`, `to`, `value`, `nonce`, `message` and `proof`. Supply these to
91
-
the `relayMessageWithProof` function on L1 to execute and finalize your transaction on L1.
84
+
When the transaction finalizes on L1, `claim_info` object under the `result` json returned will have all the information needed to execute your transaction on L1. The
85
+
parameters needed by the `relayMessageWithProof` are: `from`, `to`, `value`, `nonce`, `message` and `proof`. Supply these to the `relayMessageWithProof` function on L1 to execute and finalize your transaction on L1.
92
86
93
87
<Asidetype="tip"title="">
94
-
All L2 transactions are bundled into batches – you have to wait for the batch that includes your transaction to
95
-
finalize before calling `relayMessageWithProof`. Your transaction batch index is returned in the `batch_index` value
96
-
on the `/claimable` endpoint, and you can follow the progress on the [Scroll Rollup
All L2 transactions are bundled into batches, you have to wait for the batch that includes your transaction to finalize before calling `relayMessageWithProof`. Your transaction batch index is returned in the `batch_index` value on the `/unclaimed` endpoint, and you can follow the progress on the [Scroll Rollup Explorer](https://scroll.io/rollupscan?page=1&per_page=10).
98
89
</Aside>
99
90
100
91
## Messenger API
101
92
102
-
Please visit the [npm library](https://www.npmjs.com/package/@scroll-tech/contracts?activeTab=code) for the complete Scroll contract API documentation.
103
-
104
93
### sendMessage
105
94
95
+
See implementation at [L2ScrollMessenger on Github](https://github.com/scroll-tech/scroll-contracts/blob/main/src/L2/L2ScrollMessenger.sol).
96
+
106
97
```solidity
107
98
function sendMessage(
108
99
address target,
@@ -125,6 +116,8 @@ Sends arbitrary data from one chain to another. It allows us to execute function
125
116
126
117
### relayMessageWithProof
127
118
119
+
See implementation at [L1ScrollMessenger on Github](https://github.com/scroll-tech/scroll-contracts/blob/main/src/L1/L1ScrollMessenger.sol).
120
+
128
121
```solidity
129
122
function relayMessageWithProof(
130
123
address from,
@@ -136,7 +129,7 @@ function relayMessageWithProof(
0 commit comments