project screenshot 1

LayerHop

A dApp to enable cross chain value streaming and transfers. Additionally it will allow inexpensive L1 Ethereum actions to be initiated from EVM L2s.

LayerHop

Created At

Scaling Ethereum

Project Description

I could not complete LayerHop, getting stuck on the very last step which I could not debug in time. I focused on function first and planned to clean it up the UX afterwards. I figured submitting something was better than nothing even though I'm very disappointed. I learned a ton and plan to finish the project before trying some other ideas.

LayerHop at it's core allows users or contracts to take actions on L1 Ethereum for L2 costs from any EVM L2 starting with Polygon. Users or contracts can submit tokens and plans to LayerHop on the L2, and once enough have built up, any user or server can elect to ship the tokens and plans to the L1 LayerHop which will take execute those plans with the provided tokens. At critical mass there could be fee incentive on every block to ship these plans, guaranteeing a stable link between layers.

This allows users to pay L2 prices to do things like:

  • Establish a SuperFluid token stream from an L2 to any L1 or L2 address.
  • Deposit tokens into Yearn, Alchemix, Compound, etc, and withdraw them back to any L2.

At any time tokens can be withdrawn from the L1 or L2 side of LayerHop.

How it's Made

This project consists of a contract on each layer where users or contracts can deposit tokens with plans. Another user or contract (the "captain") can read those plans from the contract and decide to get paid a fee to send those tokens and plans to another layer. The captain opens a Connext state channel and gets a deposit address, which he then sends to the LayerHop contract, which in turn deposits tokens there into the state channel.

To incentivize the captain to provide the correct address (and not just steal the funds) he is required to have a deposit with LayerHop which is locked until delivery confirmation to the LayerHop contract on the other network.

Once the state channel has the proper deposit with meta-transaction the captain can tell the state channel to withdraw to the LayerHop contract on the destination layer network. That LayerHop contract receives the tokens and the meta-transaction which contains the set of plans that users had submitted on the original network. These plans are executed, with several possible actions like investing in Yearn, streaming SuperFluid tokens, etc. At the same time this contract emits a message with a hash of the received token balance and meta-transaction, which is used to unlock the captain's collateral on the original network.

The original network uses an oracle like Chainlink and an API like The Graph or Covalent to check for an event from the destination network LayerHop contract that contains the correct hash. The captain can then request his funds unlocked after that event is available. This provides a trustless feedback loop to allow a captain to move other user's funds. If the event is not received within a certain time the contract could assume ownership. I'd prefer another more solid technique than an oracle, however I figured the shipments could be limited in size to reduce risk, and billions of dollars are already secured by oracles.

Any tokens could be invested while they're not being moved by depositing and withdrawing from AAVE, etc. while they're waiting.

I got as far as getting tokens to the other network and registering in the LayerHop contract balance, proving the meta-transaction worked, but for some reason the SuperFluid stream didn't open (the last step I could not get to work).

background image mobile

Join the mailing list

Get the latest news and updates