Skip to content

Lay3rLabs/example-cosmos-eth-bridge

Repository files navigation

WAVS Cosmos -> Eth Bridge Example

NOT PRODUCTION READY - FOR DEMO PURPOSES ONLY

  • Clone with --recursive or remember to pull the submodules for solidity dependencies

One-time setup

  1. Copy .env.example to .env and set the right vars

  2. Install WAVS natively

Docker won't work out of the box here because we need WAVS to listen to a local Cosmos chain we'll be running

git clone https://github.com/Lay3rLabs/WAVS.git ~/WAVS

cd ~/WAVS && just install-native ~/wavs-config ~/wavs-data
  1. Build all the contracts and components
just build
  1. Install any other generic tooling that pops up... e.g. just, foundry, docker etc.

That's it!

Up and running

  1. Start the backend
just start-backend

tip: wait until these are ready before proceeding:

This may take some time if you've never started the backend before, but subsequent start-ups should be quick.

  1. Deploy contracts and services
just deploy

This may take some time if you've never deployed before, but subsequent deployments should be quick.

  1. Bridge assets
just bridge

You'll see it do some stuff and then print out your balance.

  1. Stop the backend
just stop-backend

Implementation notes

Almost everyting is in the justfiles (using wavs-cli and forge to do the heavy lifting). A minimal cosmos client is in cosmos-client

Overall flow when running just bridge is:

  1. (user action) sending some ulayer to the Cosmos chain
  2. (cosmos chain) emits an event
  3. (wavs) picks up the event
  4. (wavs) passes the event data to the component
  5. (component) extracts the amount and recipient from the event data
  6. (component) encodes the info into an ethereum-friendly type (shared at compiletime w/ alloy sol! macro)
  7. (wavs) signs this output from the component, submits it to eigenlayer contract
  8. (ethereum: Eigenlayer-aware LayerServiceManager) verifies the operator and signature, calls LayerServiceHandler
  9. (ethereum: Vanilla LayerServiceHandler + ERC20) extracts the data, mints tokens

The only thing copy/pasted from WAVS repo is the solidity interfaces.

Security

For the sake of keeping the example brief, this does not implement any security measures to prevent anyone from minting. That could easily done in a number of ways (e.g. requiring that the caller be the service manager, signing with a secret on the component side, etc.), but would distract from the point of this example.

If you're using this repo for mainnet... erm.. don't :P

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published