This example shows you how to use LayerZero to bridge assets from another EVM chain to Abstract.
It shows you how to create a cross-chain NFT collection using LayerZero’s ONFT standard; and bridge an NFT from Base to Abstract using LayerZero.
-
Get a copy of the
layerzero-onftexample directory from the Abstract Examples repository:mkdir -p layerzero-onft && curl -L https://codeload.github.com/Abstract-Foundation/examples/tar.gz/main | tar -xz --strip=2 -C layerzero-onft examples-main/layerzero-onft && cd layerzero-onft
-
Install dependencies:
yarn install
-
Run the scripts in the
deployfolder according to the instructions below.
The code in deploy/deploy-base-sepolia.ts will deploy the cross-chain NFT collection on the Base Sepolia testnet.
yarn deploy-baseThe code in deploy/deploy-abstract-testnet.ts will deploy the cross-chain NFT collection on the Abstract Testnet.
yarn deploy-abstractWe link the two contracts together using LayerZero so we can bridge NFTs between the two chains.
First, take the contract addresses from the previous steps, and add them to the config object in deploy/config.ts:
export const config = {
baseSepolia: {
endpointId: 40245,
// Replace with your own NFT contract address
nftContractAddress: "0x-your-base-nft-contract-address",
},
abstractTestnet: {
endpointId: 40313,
// Replace with your own NFT contract address
nftContractAddress: "0x-your-abstract-nft-contract-address",
},
};Then, run the script to connect the contracts:
yarn connect-contractsThe code in deploy/mint-nft.ts will mint an example NFT on the Base Sepolia testnet.
We’ll use this NFT as an example to bridge across from Base to Abstract.
yarn mint-nftThe code in deploy/bridge-to-abstract.ts will bridge the NFT from Base to Abstract using LayerZero!
yarn bridge-to-abstract