- Products
- Ecosystem
- Use Cases
- Resources
- About
Non-fungible token (NFT) technology is rapidly evolving, with new daily developments and trends. One such trend gaining popularity is the ERC-404 standard and cross-chain NFTs. These NFTs offer unique features and capabilities not found in standard NFTs, thanks to their interoperability.
In this post, we’ll explore the concept of cross-chain NFTs and explain how Analog GMP’s secure cross-chain NFT design fosters innovation in the Web3 space.
A cross-chain NFT refers to an NFT for which ownership rights can be sent/received across multiple chains using a blockchain interoperability solution. For example, you could deploy an NFT collection on Astar and move it to the Ethereum blockchain. In the current Web3 ecosystem, most NFT projects are limited to a single blockchain on which they are minted, hindering their adoption and utility.
For example, in a multi-chain ecosystem, such NFTs cannot be used across different blockchains, and users on different networks can only interact with your NFT if they switch to the underlying chain hosting the NFT.
This constraint not only creates a barrier for newcomers, hindering the adoption of NFTs, but it also causes liquidity issues in NFT marketplaces by isolating assets on their respective blockchain networks. This is why it is crucial for a developer to have a clear focus on which chain will host your NFT collection.
For a deeper dive into cross-chain NFTs, check out our blog: NFTs Cross-Chain? What Are the Possibilities?
Fortunately, with Analog GMP and NFT standards like ERC-404, you can now implement a cross-chain NFT that users can leverage across different chains, promoting greater interoperability and collaboration in the NFT markets.
For more details about ERC-404, check out our blog: What is ERC 404 and How It May Be Changing The Game | Analog Insights.
Analog GMP is a chain-agnostic, secure, and modular framework for cross-chain interoperability, enabling seamless state transitions across connected blockchain networks. Utilizing the Timechain as its underlying infrastructure, Analog GMP enables a smart contract on one chain to pass messages (e.g., data and tokens) to other smart contracts on other blockchains.
It has two essential functions you can leverage to build a cross-chain NFT project:
submitMessage()
, which sends the GMP message from the source contract to the Gateway Smart Contract (GSC) on the source chain. The GMP message is then forwarded to the destination chain.
onGmpReceived()
, which receives and processes the GMP message on the destination chain.
For a detailed overview of Analog GMP, check out our documentation.
An NFT project can utilize Analog GMP’s messaging capabilities to mint their NFTs on a single chain, pay once, and have those assets distributed to users across multiple chains. This allows users to own and share their assets regardless of the chain they are using.
Here’s how you could implement such a project. Let’s say you have a simple NFT contract with this mint function:
function mint(address to, uint256 tokenId) public
{
unchecked {
tokenId+=1;
}
_safeMint(to, tokenId);
}
To proceed, you need to implement two contracts: SourceNFTMinter
on the source chain and DestNFTMinter
on the target blockchain. For cross-chain functionality, the mint
function in the SourceNFTMinter
contract must include logic for sending a cross-chain request to DestNFTMinter
with an ABI-encoded payload, as shown here:
function mint(address recipient, uint16 destinationNetwork, uint256 executionGasLimit, uint256 tokenId) external payable (bytes32 messageID)
{
// Create the payload
bytes32 memory payload = abi.encode(“mint(address)”, msg.sender);
messageID = _trustedGateway.submitMessage(address(recipient), destinationNetwork, MSG_GAS_LIMIT, payload);
emit MessageSent(messageID);
}
The logic for this smart contract has two basic steps. First, it creates a payload
from the caller (i.e., msg.sender
) and recipient
. Next, it creates a messageID
and calls the gateway contract on the source chain, specifying details such as recipient
address, destinationNetwork
, execution gas limit, and payload
.
Now, let’s take a look at what happens at the destination chain.
The DestNFTMinter
contract inherits from the IGmpReceiver
interface to handle messages on the destination chain. This interface includes a function named onGmpReceived()
, which receives the GMP message from the source chain containing an ABI-encoded mint function as its payload.
When invoked, the contract mints a new NFT to the msg.sender
account, which is the same account that minted the NFT on the source chain:
function onGmpReceived(bytes32, uint128, bytes32, bytes calldata) external payable returns (bytes32)
{
// Validate the GMP message
require(msg.sender == address(_trustedGateway), "Unauthorized: only the gateway can call this method");
require(network == _recipientNetwork, "Unauthorized network");
require(senderAddr == address(_recipient), "Unauthorized sender");
address user = abi.decode(messageID, (address));
_safeMint(user, cur_tokenId);
cur_tokenId++;
}
In this implementation, the contract first validates the message, ensuring that only the gateway can call this method and verifying the validity of the network and sender address. Afterward, the payload is decoded to retrieve the source chain’s caller address, enabling an NFT to be minted at the specified address.
With this implementation, users who minted their NFTs on one chain can now own their assets across multiple chains by paying just once on the original chain. NFT projects aiming to maintain non-fungibility can adapt this implementation by burning the asset on the source chain, guaranteeing that only a single version of the asset exists across various blockchains.
Are you excited to explore the new realm of cross-chain DApps and discover the innovative applications you can create? We invite you to explore our extensive documentation, which will guide you through building your first cross-chain DApp. NFT projects like PixelPort are already utilizing Analog GMP to develop cross-chain NFTs. You can learn more about this advancement here.
Join us on our cross-chain-verse journey and become part of the hundreds of developers building unique Analog GMP projects. Stay up-to-date with Analog:
Discord: https://discord.com/invite/analog
Telegram: @analogannouncements | https://t.me/analogtimer
Blockchains have radically redefined our interaction with the digital world. Decentralized applications (DApps) are proliferating, creating fresh opportunities...
Read moreDecentralized Exchanges — or more simply DEXs — are peer-to-peer (P2P) marketplaces that allow crypto traders to trade their tokens directly without handing over the management of their assets to an intermediary.
Read moreWe have witnessed many blockchain networks emerging over the past couple of years, each with its own strengths and weaknesses. Some of these blockchains have different degrees of decentralization, security, throughput, or transaction fees.
Read more