-
Notifications
You must be signed in to change notification settings - Fork 182
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enforced tx guide draft + finalizing tx on L1 doc
- Loading branch information
Showing
5 changed files
with
82 additions
and
4 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
58 changes: 58 additions & 0 deletions
58
src/content/docs/en/developers/guides/enforced-tx-from-sepolia-etherscan.mdx
This file contains 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,58 @@ | ||
--- | ||
section: developers | ||
date: Last Modified | ||
title: "Sending an Enforced Transaction from Sepolia Etherscan" | ||
lang: "en" | ||
permalink: "developers/guides/enforced-tx-from-sepolia-etherscan" | ||
excerpt: "The Enforced Transaction deployed on Sepolia is the most direct and permisionless way to send a transaction from L1 to L2. In this guide we will launch a Greeter contract on L2 and set the greeter value from Sepolia L1 from the Sepolia Etherscan UI." | ||
--- | ||
|
||
import Aside from "../../../../../components/Aside.astro" | ||
import ClickToZoom from "../../../../../components/ClickToZoom.astro" | ||
|
||
import enforcedTxData from "../_images/enforcedTxData.png" | ||
import enforcedTxSepoliascan from "../_images/enforcedTxSepoliascan.png" | ||
|
||
The Enforced Transaction deployed on Sepolia is the most direct and permisionless way to send a transaction from L1 to L2. In this guide we will launch a Greeter contract on L2 and set the greeter value from Sepolia L1 from the Sepolia Etherscan UI. | ||
|
||
#### Target Smart Contract | ||
|
||
Let’s start by deploying the target smart contract on Scroll testnet. On this guide we will be using a Greeter contract and we will use Remix to deploy it and interact with it. Keep in mind that you can deploy any other contract with the tool of your choice. | ||
|
||
```solidity | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.21; | ||
// This Greeter contract will be interacted with through the EnforcedTransaction contract deployed on Sepolia | ||
contract Greeter { | ||
string public greeting = "Hello World!"; | ||
// This function will be called by sendTransaction on Sepolia | ||
function setGreeting(string memory greeting_) public { | ||
greeting = greeting_; | ||
} | ||
// This function is not mandatory, is just a convinient way of getting the data needed to execute the setGreeting function from an external source | ||
function getEncodedData(string memory greeting_) public pure returns (bytes memory) { | ||
return abi.encodeWithSignature("setGreeting(string)", greeting_); | ||
} | ||
} | ||
``` | ||
|
||
Once your contract contract is deployed, execute the `getEncodedData` by passing as parameter the new greeting that will be set from L1, try passing `“Crosschain message!”` as parameter. It will return a big sequence of bytes. Save both the result of the function call and the contract address because both will be needed later. | ||
|
||
<ClickToZoom src={enforcedTxData} /> | ||
|
||
#### Sending an enforced transaction from Sepolia Etherscan | ||
|
||
Now go to the [EnforcedTransaction contract tab](https://sepolia.etherscan.io/address/0x97f421ca37889269a11ae0fef558114b984c7487#writeProxyContract#F3) on Sepolia Scan and execute the sendTransaction by passing the following params: | ||
|
||
- `payableAmount`: The amount of ETH used to pay gas on L2 `0.001` should be more than enough. | ||
- `target`: The address of the Greeter smart contract deployed on L2. | ||
- `value`: Pass 0 as param becuase the `setGreeting` function is not payable. | ||
- `gasLimit`: The amount gas limit to execute the transaction on L2. `200000` should be enough. | ||
- `data`: The big sequence of bytes you got from calling the `getEncodedData` function on your Greeter contract. | ||
|
||
<ClickToZoom src={enforcedTxSepoliascan} /> | ||
|
||
After executing and confirming the transaction on Sepolia, the new state of `greeting` on the `Greeter` contract should be `“Crosschain message!”` or any message you set when calling `getEncodedData`. Sending a message from Sepolia to Scroll testnet should take around 20mins after the transactions are confirmed on Sepolia. |
This file contains 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 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