Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated LZ bridge instructions #625

Merged
merged 3 commits into from
Mar 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
53 changes: 41 additions & 12 deletions docs/build/zkEVM/integrations/bridges-relays/AstarEVM-zkEVM.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,61 @@
---
title: Astar EVM <-> zkEVM Bridge
title: Astar <-> zkEVM Bridge
---

## Overview

LayerZero integration functionally connects the EVM on Astar parachain to the zkEVM on Ethereum. This takes the form of two smart contract-based endpoints that allow the chains to send messages to one another other.

## Bridge ASTR on mainnet

LayerZero has a standard for synthetic assets that can be locked on a source chain and minted on another called Omnichain Fungible Token or **OFT**, which we will refer to going forward.

For this walkthrough, on the Astar side, the contract is [NativeOFT](https://github.com/AstarNetwork/solidity-examples/blob/main/contracts/token/oft/v2/fee/NativeOFTWithFee.sol), which acts as an ERC20 wrapper contract (the function is payable) that will be used to send a cross-chain message to the OFT contract on zk Astar to mint ASTR, otherwise known as LayerZero (synthetic) ASTR.

On the Astar zkEVM side, the contract is [OFT](https://github.com/AstarNetwork/solidity-examples/blob/main/contracts/token/oft/v2/fee/OFTWithFee.sol), which acts as the ERC20 ASTR synthetic asset on Astar zkEVM, which exist in a 1:1 ratio with its NativeOFT counterpart.

| Contract | Network | Address |
|------------|---------|------------------------------------------------|
| OFT Native | Astar | [0xdf41220C7e322bFEF933D85D01821ad277f90172](https://astar.blockscout.com/address/0xdf41220C7e322bFEF933D85D01821ad277f90172?tab=txs) |
| OFT | zkEVM | [0xdf41220C7e322bFEF933D85D01821ad277f90172](https://astar-zkevm.explorer.startale.com/address/0xdf41220C7e322bFEF933D85D01821ad277f90172?tab=txs) |

### Bridging ASTR

:::note
Please note that the LayerZero bridge is only available between Shibuya and zKatana testnets at this time. In this walkthrough we will describe how to bridge Shibuya token to zKatana.
Token bridging will be integrated to Stargate UI https://stargate.finance/transfer shortly to make it easier for users to bridge tokens.

:::

A LayerZero integration functionally connects the EVM on Astar parachain to the zkEVM on Ethereum. This takes the form of two smart contract-based endpoints that allow the chains to send messages to one another other.
To facilitate token transfer, we have provided a sample repository containing a utility script:

1. Fork the [Repository](https://github.com/AstarNetwork/layer-zero-bridge-mainnet)

2. Install dependencies by running `npm install`

## LSBY Token
3. Create a .env file (based on the .env.example) in the root directory

LayerZero has a standard for synthetic assets that can be locked on a source chain and minted on another called Omnichain Fungible Token or **OFT**, which we will refer to going forward.
4. Add your [private key](https://support.metamask.io/hc/en-us/articles/360015289632-How-to-export-an-account-s-private-key) in the .env file

For this walkthrough, on the Shibuya side, the contract is [NativeOFT](https://github.com/LayerZero-Labs/solidity-examples/blob/main/contracts/token/oft/v2/fee/NativeOFTWithFee.sol), which acts as an ERC20 wrapper contract (the function is payable) so you can send it some SBY tokens, and it will respond by sending a cross-chain message to the OFT contract on zKatana to mint LSBY, otherwise known as LayerZero (synthetic) SBY.
5. Run `npm hardhat compile` to compile the contracts

On the zKatana side, the contract is [OFT](https://github.com/LayerZero-Labs/solidity-examples/blob/main/contracts/token/oft/v2/fee/OFTWithFee.sol), which acts as the ERC20 SBY synthetic asset on zKatana, which should exist in a 1:1 ratio with its NativeOFT counterpart.
#### Astar &rarr; Astar zkEVM
To send 1ASTR from `astar`(`astar L1 mainnet`) to `zk-astar`(`Astar zkEVM`), run the following command (Note that the `--quantity` flag is in wei):

### Bridging LSBY Tokens
`npx hardhat bridge --quantity 1000000000000000000 --target-network zk-astar --network astar`

To facilitate token transfer, we have provided a sample repository containing a utility script:
#### Astar zkEVM &rarr; Astar

:::info
To send 1ASTR from `zk-astar`(`Astar zkEVM`) to `astar`(`astar L1 mainnet`), run the following command (Note that the `--quantity` flag is in wei):

Note: The current method is provisional and specific to testnet environments. The eventual mainnet implementation will incorporate the bridging of Native ASTR tokens through the Astar Portal.
`npx hardhat bridge --quantity 1000000000000000000 --target-network astar --network zk-astar`

:::
## Bridge Shibuya testnet token

We deployed OFT contracts on Shibuya and zKatana to bridge SBY (NAtive token of Shibuya) to zKatana. Please follow the steps below.

### Bridging LSBY Tokens

To facilitate token transfer, we have provided a sample repository containing a utility script:

1. Fork the [Repository](https://github.com/AstarNetwork/layer-zero-bridge-contracts-testnet)

Expand Down