Skip to main content

Bridging ERC721 Tokens

Introduction

The ERC721 bridge is a smart contract-based mechanism that enables the seamless transfer of non-fungible tokens (NFTs) between native and non-native chains. It operates similarly to the ERC20 router, allowing for seamless token transfer between chains. By wrapping the native token on the non-native chain, the ERC721 bridge ensures that the metadata of the transferred token remains intact, making it easy to recognize and use.

Similar to the ERC20 router, it has three possible flows for transferring tokens between chains:

Going from a token's native chain to a non-native chain: This flow occurs when a user wants to bridge an NFT from a native chain to a non-native chain. The router on the destination chain will create a wrapped version of the NFT with the same metadata as the native token. This wrapped token is then used on the non-native chain, allowing users to recognize and use the token as if it were the native token.

Going from a token's non-native chain to a native chain: This flow occurs when a user wants to bridge an NFT from a non-native chain to its native chain. The router on the non-native chain will burn the wrapped token from the user and will unlock the token on the native chain. This ensures that the metadata of the transferred token remains intact, making it easy to recognize and use.

Going from a token's non-native chain to another non-native chain where the token may or may not exist: This flow occurs when a user tries to send an NFT from a non-native chain to another non-native chain where the token does not exist natively. The ERC721 router will burn the token from the user on the source chain, create a wrapped version of the token on the destination chain (if it doesn't exist already), and mint it to the recipient address. By doing this, the user can easily transfer their NFT to a chain where it wasn't previously available.

In each of these flows, the ERC721 router ensures that the metadata remains intact. This is achieved by creating a wrapped version of the token with the same metadata as the native token. This makes it easy for users to recognize and use the token on non-native chains.

How to bridge ERC721 tokens

In order to bridge ERC721 tokens from a source chain to a target chain, we use the egress function:

struct CollectionWithTokens {
address collection;
uint256[] tokenIds;
}

function egress(
uint8 targetChainId_,
CollectionWithTokens[] calldata assets_,
bytes calldata receiver_
) external payable
targetChainId_The Messaging Protocol Chain id of the destination chain
assets_An array of structs, containing a collection address and an array of token IDs
receiver_Address who will receive the tokens on the destination chain