L2 Restaking Module 
Overview 
The L2 Connext Restaking module leverages Connext's cross-chain technology to facilitate ETH restaking across EVM chains, enabling seamless interactions between different blockchain networks. This project includes contracts for depositing, staking, and bridging assets, specifically focusing on ETH/wETH. By utilizing Connext's cross-chain communication capabilities, it provides users with a smooth experience for staking ETH/WETH on various L2 chains, enhancing interoperability in the blockchain ecosystem.
Compatibility 
- Supports all EVM chains compatible with Connext and Chainlink.
 - Enables cross-chain asset transfers and staking operations.
 - Used in conjunction with the CCIP Rate Cross-Chain Module to enable real-time retrieval of LRD exchange rates from L1 on L2.
 
Contracts 
Introduction 
L2 Connext Restaking Module comprise several key components:
- XDeposit: Handles deposits of ETH/WETH, minting of xLrd tokens, and bridging assets across chains.
 - XStake: Manages cross-chain staking operations, converting WETH to Lrd and wrapping it into xLrd.
 - XERC20Factory: Facilitates the deployment of xERC20 tokens and their associated lockboxes.
 - XERC20Lockbox: Provides a secure mechanism for locking xERC20 tokens.
 - XERC20: An ERC20 token implementation that supports minting and burning operations with configurable limits for bridges. It allows for the creation of tokens that can be minted and burned by authorized bridges, ensuring controlled supply and demand across chains.
 
These components can be deployed and used independently or in conjunction with one another.
Repository: Evm Module Contracts
XDeposit 
Includes the following functionalities:
- Deposit ETH/WETH: Users can deposit ETH, which is wrapped into WETH.
 - Mint xLrd Tokens: Upon deposit, xLrd tokens are minted based on the amount of WETH deposited.
 - Bridge Assets: Facilitates cross-chain transfers of assets using Connext.
 
XStake 
Includes the following functionalities:
- Receive WETH: Accepts WETH from cross-chain transfers.
 - Stake ETH: Converts WETH to Lrd by staking it.
 - Wrap Lrd into xLrd: Wraps the staked Lrd into xLrd and burns the xLrd if already minted on L2.
 
XERC20Factory 
Includes the following functionalities:
- Deploy xERC20 Tokens: Allows for the creation of xERC20 tokens with specified limits for minters and burners.
 - Deploy Lockboxes: Facilitates the creation of lockboxes for managing xERC20 tokens.
 
XERC20Lockbox 
Provides a secure environment for locking xERC20 tokens, ensuring that they are managed properly during cross-chain operations.
XERC20 
The XERC20 contract is an ERC20 token implementation that allows for:
- Minting and Burning: Tokens can be minted for users and burned as needed, with operations restricted to authorized bridges.
 - Configurable Limits: Each bridge can have its own minting and burning limits, which replenish over time, ensuring controlled token supply.
 
Installation 
Prerequisites 
- Node.js
 - Hardhat
 
Steps 
Clone the repository:
bashgit clone https://github.com/stafiprotocol/evm-module-contracts.git cd connextgit clone https://github.com/stafiprotocol/evm-module-contracts.git cd connextInstall dependencies:
bashyarnyarnConfigure the network in
hardhat.config.js:Set up environment variables in
.envfile:
Deployment 
Deploying XERC20Factory and xLRD(L1+L2) 
Deploy the
XERC20Factorycontract:bashnpx hardhat run scripts/connext/deploy_XERC20Factory.js --network <your-network>npx hardhat run scripts/connext/deploy_XERC20Factory.js --network <your-network>Deploy the
xLRDcontract in layer1 and layer2 usingXERC20Factory:bashcp scripts/connext/config.example.json scripts/connext/config.jsoncp scripts/connext/config.example.json scripts/connext/config.jsonbashnpx hardhat run scripts/connext/deploy_XERC20.js --network <your-network>npx hardhat run scripts/connext/deploy_XERC20.js --network <your-network>
Deploying xLRDLockbox(L1) 
- Deploy the 
xLRDLockboxcontract:bashnpx hardhat run scripts/connext/deploy_XERC20Lockbox.js --network <your-network>npx hardhat run scripts/connext/deploy_XERC20Lockbox.js --network <your-network> 
Deploying XDeposit(L2) 
- Deploy the 
XDepositcontract:bashnpx hardhat run scripts/connext/deploy_xDeposit.js --network <your-network>npx hardhat run scripts/connext/deploy_xDeposit.js --network <your-network> 
Deploying XStake(L1) 
- Deploy the 
XStakecontract:bashnpx hardhat run scripts/connext/deploy_xStake.js --network <your-network>npx hardhat run scripts/connext/deploy_xStake.js --network <your-network> 
Configuration 
Configure the
XDepositcontract:- Set the necessary parameters during initialization, including addresses for WETH, LRD, and Connext.
 - Information related to Connext contracts can be found here:Connext
 
Configure the
XStakecontract:- Ensure that the addresses for WETH, Lrd, xLrd, and the stake manager are correctly set.
 
Fund the contracts with necessary tokens for operations.
Usage 
Depositing Assets 
- Users can deposit ETH or WETH into the 
XDepositcontract, which will wrap ETH and mint xLrd tokens. - Call the 
executeBridgemethod to transfer assets across chains. 
Staking Assets 
- The 
XStakecontract will receive WETH from cross-chain transfers. - It will stake the WETH to receive Lrd and wrap it into xLrd.
 
Off-Chain Relayer 
The Off-Chain Relayer, also known as Connext-Relay, is a key component of the L2 Connext Restaking Module. It is used to periodically trigger contract transactions for cross-chain staking from the XDeposit contract on L2 to L1. It facilitates communication between different chains and ensures the smooth execution of cross-chain operations.
Repository: Connext Relay
Installation 
To install Connext-Relay:
git clone https://github.com/stafiprotocol/connext-relay.git
cd connext-relay
make buildgit clone https://github.com/stafiprotocol/connext-relay.git
cd connext-relay
make buildConfiguration 
- Default home directory: 
$HOME/connext-relay - Default log level: Info
 - Custom home directory can be specified using the 
--homeflag 
Key Features 
Account Management:
- Add new Ethereum accounts
 - Import existing Ethereum accounts
 
Relay Service:
- Starts the relay service to periodically trigger cross-chain staking transactions from L2 to L1.
 
Version Control:
- Check the version of Connext-Relay
 
Usage 
1. Adding a New Ethereum Account 
./build/connext-relay add-account./build/connext-relay add-account2. Importing an Existing Ethereum Account 
./build/connext-relay import-account./build/connext-relay import-account3. Starting the Relay Service 
First, create and edit the configuration file:
cp conf.template.toml config.toml
# Edit config.toml as neededcp conf.template.toml config.toml
# Edit config.toml as neededThen start the relay service:
./build/connext-relay start./build/connext-relay start4. Checking Version 
./build/connext-relay version./build/connext-relay versionSecurity Considerations 
- Passwords for accounts should be kept secure
 - Private keys are encrypted before storage
 - Key files are created with 0600 permissions
 
Integration with L2 Connext Restaking Module 
The Connext-Relay works in conjunction with the smart contracts to:
- Relay messages and asset transfer instructions to destination chains
 - Facilitate the execution of cross-chain staking and unstaking operations
 
By running a Connext-Relay alongside the deployed smart contracts, operators can ensure smooth and secure cross-chain asset management within the L2 Connext Restaking Module ecosystem.
For more detailed information or support, please contact the development team.