zkBridge
  • Polyhedra Network
  • zkBridge: Trustless Cross-chain Bridges Made Practical
    • Introducing zkBridge protocol
    • Block header relay network
    • Updater contract
    • Proof systems of zkBridge
    • zkBridge Research Paper
  • zkLightClient Overview
    • Introduction
    • zkLightClient on LayerZero ​
  • LayerZero zkLightClient Configurations
    • LayerZero V1 zkLightClient Oracle Addresses
    • LayerZero V2 zkLightClient DVN Addresses
    • LayerZero UA Configuration
  • Proving Ethereum Full PoS Consensus in ZK
    • Overview
    • Why Proving Ethereum full consensus?
    • System design for proving Ethereum full consensus
    • Efficient proof system for proving Ethereum full consensus
    • Performance evaluation
    • Concluding remarks
  • Application Use Cases
    • NFT transfer
    • Message passing
  • Tutorial
    • Import and transfer NFTs
  • Code Examples
    • Deploying Cross-chain NFTs
      • Cross-chain ERC-721
      • Cross-chain ERC-1155
Powered by GitBook
On this page
  • Deploying the ERC1155 NFT Contract on the Sender Chain
  • Deploying the Mapping Contract on the Receiver Chain
  1. Code Examples
  2. Deploying Cross-chain NFTs

Cross-chain ERC-1155

PreviousCross-chain ERC-721

Last updated 1 year ago

Deploying the ERC1155 NFT Contract on the Sender Chain

Below is an example of a standard ERC1155 contract. You can use the to deploy this contract on an EVM-compatible blockchain.

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC1155/extensions/ERC1155URIStorage.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

contract SimpleErc1155 is ERC1155URIStorage, Ownable {

    constructor(string memory baseUri) ERC1155(baseUri) {}

    function mint(address to, uint256 tokenId, uint256 amount) external {
        _mint(to, tokenId, amount, "");
    }

    function setURI(uint256 tokenId, string calldata tokenURI) external onlyOwner {
        _setURI(tokenId, tokenURI);
    }
}

Deploying the Mapping Contract on the Receiver Chain

For ERC1155, you need to implement the IZKBridgeErc1155 interface and grant minting and burning permissions to the NFT bridge contract on the receiver chain.

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC1155/extensions/ERC1155URIStorage.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

interface IZKBridgeErc1155 {
    function zkBridgeMint(address _to, uint256 _id, uint256 _amount, string calldata _uri) external;

    function zkBridgeBurn(address _from, uint256 _id, uint256 _amount) external;
}

contract ONFT1155 is IZKBridgeErc1155, ERC1155URIStorage, Ownable {
    address public bridge;

    modifier onlyBridge() {
        require(msg.sender == bridge, "caller is not the bridge");
        _;
    }

    constructor(address _bridge, string memory _baseUri) ERC1155(_baseUri) {
        bridge = _bridge;
    }

    function zkBridgeMint(address _to, uint256 _id, uint256 _amount, string calldata _uri) external onlyBridge {
        _mint(_to, _id, _amount, "");
        // can cover uri
        // _setURI(_id, _uri);
    }

    function zkBridgeBurn(address _from, uint256 _id, uint256 _amount) external onlyBridge {
        _burn(_from, _id, _amount);
    }

    function setURI(uint256 tokenId, string calldata tokenURI) external onlyOwner {
        _setURI(tokenId, tokenURI);
    }

}

After deploying the contract on the receiver chain, please notify us and provide both the sender chain's and receiver chain's contract addresses, so we can add the mapping relationship for you.

To get in touch, you may either:

  1. Send an email to [email protected]

Example:

Once the contract is deployed, you can mint an NFT and conduct a cross-chain transfer via the . If this is the first time you are transferring this NFT, zkBridge will automatically create a mapping contract on the receiver chain. If you wish to deploy the mapping contract for the NFT on the receiver chain by yourself, please refer to the tutorial below.

Reach out to our community moderators on our

Fill out the

BscTestnet-NFT:

OpbnbTestnet-NFT:

Remix - Ethereum IDE
zkBridge official website
Discord Server
from for Ecosystem Partnership
0x55D7680998778e2C8df1255a8b2FE57e56623126
0x106d3cD51e1Af35F7328aab6e8C070500f9d517d