Deploying the ERC721 NFT Contract on the Sender Chain
Below is an example of a standard ERC721 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/ERC721/ERC721.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
contract SampleERC721 is ERC721 ,Ownable{
using Counters for Counters.Counter;
Counters.Counter private _tokenIds;
string private _baseTokenURI;
constructor(string memory name, string memory symbol) ERC721(name, symbol) {}
function mint() public {
_safeMint(msg.sender, _tokenIds.current());
_tokenIds.increment();
}
function _baseURI() internal view virtual override returns (string memory) {
return _baseTokenURI;
}
function setBaseURI(string calldata baseURI) external onlyOwner{
_baseTokenURI = baseURI;
}
}
Deploying the Mapping Contract on the Receiver Chain
For ERC721, you need to implement the IZKBridgeErc721 interface and grant minting and burning permissions to the NFT bridge contract on the receiver chain.
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.
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.