A full-stack demonstration of Ethrex L2, showcasing a Layer 2 rollup solution with bridge capabilities and account abstraction features. This React-based frontend allows users to:
- Bridge assets between L1 and L2 (deposit, withdraw, claim)
- Use Account Abstraction to mint and transfer tokens with passkey authentication (fingerprint/biometrics)
- Interact with Ethrex Rollup without complex wallet management
Before starting, ensure you have the following installed:
- Node.js v21+ (Download)
- npm (comes with Node.js)
- Solc - v0.8.29
- Rex - Utility tool for debugging and interacting with Ethereum. Install here
Follow these steps to get the entire system running.
- Clone ethrex
git clone https://github.com/lambdaclass/ethrex.git && cd ethrex- Checkout the branch required for this project
git checkout test_sponsor- Build ethrex
export COMPILE_CONTRACTS=true && cargo build --bin ethrex --release --manifest-path Cargo.toml --features l2,l2-sql- Start L1 and L2
This command will:
- Start the L1 on port 8545
- Deploy L1 contracts (Bridge, OnChainProposer, Verifier)
- Start the L2 on port 1729
If you want to use the account abstraction feature, you need to create a txt file with the addresses of the contract you want to sponsor. You
target/release/ethrex l2 --dev --no-monitor --sponsorable-addresses <YOUR_SPONSORABLE_ADDRESSES_FILE>Wait for the chains to fully initialize. You should see logs indicating both L1 (port 8545) and L2 (port 1729) are running. The deployment will also fund test accounts with ETH.
- Initialize the Prover
In a new terminal window, run:
./ethrex l2 prover --backend exec --proof-coordinators tcp://127.0.0.1:3900Keep this terminal running. The prover must stay active for the L2 to function properly. Without it, withdrawals cannot be finalized.
- Configure environment variables
In another terminal window, in the root of the project, run:
cp app/.env.example app/.env- Deploy smart contracts
Important
Running the following command requires a rex version that supports compiling contracts and outputting JSON ABI files. To install this version run the following commands:
git clone https://github.com/lambdaclass/rex.git
cd rex
git checkout add_abi_json_flag
make cliThis deploys two contracts to the L2:
Delegation: Enables account abstraction with passkey authenticationTestToken: ERC-20 token for testing transfers
make deployAfter deployment, you'll see output with contract addresses. Copy these addresses:
Deployed Delegation to: 0x...
Deployed TestToken to: 0x...
- Update environment variables
Edit app/.env and update the following variables with the addresses from step 7:
VITE_DELEGATION_CONTRACT_ADDRESS=0x... # Address from Delegation deployment
VITE_TEST_TOKEN_CONTRACT_ADDRESS=0x... # Address from TestToken deployment- Run the frontend
The app should now be running at http://localhost:5173
make run-frontTransfer assets between the L1 and L2 chains:
- Deposit: Move ETH from L1 to L2 for faster and cheaper transactions
- Withdraw: Initiate a withdrawal from L2 back to L1
- Claim: Finalize and claim your withdrawal on L1 (after proof generation)
The bridge ensures secure asset transfers by locking funds on one chain and minting/releasing them on the other.
Experience transactions using biometric authentication:
- Mint Tokens: Create tokens on L2 using your device's fingerprint or Face ID
- Transfer Tokens: Send tokens to other addresses without traditional wallet signatures
- Passkey Authentication: Uses WebAuthn (device biometrics) instead of private keys
This feature leverages:
- EIP-7702: Account delegation for enabling smart contract functionality on EOAs
- RIP-7212: secp256r1 curve precompile for efficient passkey signature verification
- Open the app in your browser (
http://localhost:5173) - Click
Connect Wallet - Approve the connection in MetaMask or your preferred Web3 wallet
To Deposit (L1 → L2):
Note
You will need to have some ETH in your L1 wallet to be able to deposit. You can use the rich account to transfer ETH to your wallet.
rex send 0xb9d9ede845d349369eef96ef8e853b2cda387d88 --value 100000000000000000000 --private-key 0x941e103320615d394a55708be13e45994c7d93b932b064dbcb2b511fe3254e2e --rpc-url http://localhost:8545
This will transfer 100 ETH to your wallet.
- Navigate to the
/bridge/depositpage - Enter the amount of ETH to transfer
- Confirm the transaction in your wallet
- Wait for the transaction to be processed on both L1 and L2
To Withdraw (L2 → L1):
- Navigate to the
/bridge/withdrawpage - Enter the amount to withdraw
- Submit the withdrawal request
- Wait for the L2 block to be proven (Search for a)
To Claim Withdrawal:
- After your withdrawal is proven, you will be able to claim it by clicking on the "Claim Withdrawal" button
- Your funds will be released on L1
Note
You will need to add the Delegation address to a file in ethrex/crates/l2/sponsorable.txt.
This allows the Delegation contract to sponsor transactions for you.
- Navigate to the
/passkey_demopage - Create Account: Click to create a new account with passkey authentication
- You'll be prompted to use your device's biometric authentication
- Mint Tokens: Enter an amount and mint tokens using your passkey
- Transfer Tokens: Enter a recipient address and amount to transfer
- No gas fees required! Transactions are sponsored by the
Delegationcontract
- No gas fees required! Transactions are sponsored by the
Rex is a CLI tool that helps you debug and interact with your L1 and L2 chains. Here are some useful commands:
# Check the transaction receipt for error details
rex receipt <DEPLOYMENT_TX_HASH> <RPC_URL>
# Check the code of a contract
rex code <CONTRACT_ADDRESS> <RPC_URL>
# Verify L2 is producing blocks
rex block-number <L2_RPC_URL>
# Check balance
rex balance <YOUR_ADDRESS> <RPC_URL>
Feel free to submit pull requests or open issues for bug fixes and feature suggestions.
The following links, repos, companies and projects have been important in the development of this repo, we have learned a lot from them and want to thank and acknowledge them.
MIT