project screenshot 1
project screenshot 2
project screenshot 3
project screenshot 4

Omni-NFT-Escrow

This project that demonstrates the use of Layer Zero to create an Omnichain NFT Trading Escrow Contract.

Omni-NFT-Escrow

Created At

ETHGlobal Singapore

Project Description

The goal of this project was to use Layer Zero's Omnichain messaging capabilities to resolve trading NFTs across different chains. Currently, there is no known way for users to seamlessly trade their NFTs that exist on one chain with an NFT on another chain. At the time of writing, to achieve this, the user's NFT either has to have its contract also deployed on the desired chain to swap, which will allow them to bridge or wrap their NFTs to be represented on the desired chain. While this allows certain NFTs to be traded, it will not work for NFTs that do not have a counterpart representation on another chain.

Bored Apes on Ethereum for example, can never be swapped with another NFT on another chain because it does not exist on another chain to be bridged/wrapped over.

By setting up an NFT trading escrow contract powered by Layer Zero and deploying it on both chains, User1 for example, can deposit and initiate an interest to trade on chain 1, which then sends a message to its contract on chain 2 to announce the desired NFT to be traded. A User2, can then deposit the desired NFT on the contract on chain 2 if he wishes to trade and send a message back to chain 1 to confirm that the trade is real and ready to be fulfilled. User1 can then fulfil the trade which triggers the transfers of the NFTs to the new owners.

How it's Made

This project was build using Hardhat. The Solidity smart contracts adopted Layer Zero's OApp as well as OpenZepplin's libraries.

Layer Zero's OApp provides up the _lzSend() function which is what is used within the contract logics to initiate a message to the destination chain. This also required a setup of the peers in order for the chains to connect with each other. The contract is also designed to handle multiple types of message via _lzReceive(). For this project, because of the different messages that need to be sent, a message type enum is introduced and first decoded by _lzReceive() before being handled respectively.

background image mobile

Join the mailing list

Get the latest news and updates