Skip to content

Demo on Cross chain transactions b/w chains using LayerZero

Notifications You must be signed in to change notification settings

autonomys/layerzero-playground

Repository files navigation

LayerZero OApp Demo

Description

This aims at showcasing the cross-chain txs from one chain to another.

This project is created following:

npx create-lz-oapp@latest

For the whole project, chain-1 is Sepolia Testnet, chain-2 is Polygon Mumbai.

Both the contracts are OApps so far. Later on, we would also focus on OFT.

Install

yarn

Build

yarn compile

Deploy

OApp

Using Remix IDE

Details:

I have used Remix so far via:

remixd -s .

Make sure, remixd is installed via yarn global add @remix-project/remixd.

The 2 txs are as follows:

  1. Deploy MyOApp on Ethereum Sepolia testnet: Tx url, Details.
  2. Deploy DesOApp on Polygon Mumbai: Tx url, Details.

Using Hardhat

Deployment could be done using foundry/hardhat as well. Personally, I would prefer foundry though.

npx hardhat lz:deploy

Make sure to follow this doc.

Run

OApp

TODO: write script like this.

OFT

Go to examples/lz-token

cd examples/lz-token

# Install the packages
yarn

# Run the script to send tokens TSSC tokens from chain A to B.
yarn start

The script is able to send tokens from chain A to B & viceversa. Also ignore deployments & setting peers, if already done.

Currently, when tokens are transferred from chain A to B, the token-B receives the token.

Details:
Address '0x0370...d246' with token-[0] has balance: 999994.0
Address '0x0370...d246' with token-[1] has balance: 999997.0
Address '0xcd17...76ba' with token-[0] has balance: 3.0
Address '0xcd17...76ba' with token-[1] has balance: 0.0
Address '0x5c91...59cD' with token-[0] has balance: 0.0
Address '0x5c91...59cD' with token-[1] has balance: 6.0

As you can see that 3 addresses (1 EOA, 2 contracts) have balances of the 2 tokens. Cumulatively, on either chain total supply is 1 M, total 2 M.

TODO:
This needs to be fixed as in:
- by default the token recipient should be same as sender, or
- sender can explicitly provide recipient.

Post fixing this on contract end, TokenBridge class & hence main() script needs to be modified.

About

Demo on Cross chain transactions b/w chains using LayerZero

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published