Loopring announced NFT support in protocol release (v3.6.2). Since then, further enhancements have been made to NFT support on Loopring. NFT contracts no longer need to be deployed on Ethereum before being minted, transferred, and traded on Loopring. This new type of NFT is called a Counterfactual NFT.

How is it implemented?

First, we use CREATE2 to calculate the counterfactual NFT’s smart contract address that can be deployed on Ethereum L1 later. All we need are:
  • A counterfactual NFT factory (factory ) that will deploy the actual NFT contract for us when necessary. Deploying a new NFT contract is simply creating a new proxy instance that delegates all logic to a concrete counterfactual NFT implementation.
  • The NFT contract’s owner address (owner ). The owner is also the only account allowed to mint the NFT on Loopring Layer 2 under this contract.
The following code sample demonstrates how to calculate the contract address. You can refer to our GitHub repo for more details on the contract implementation.
keccak256(abi.encodePacked(NFT_CONTRACT_CREATION, owner, baseURI)),
Loopring only supports our own NFTFactory implementation. On Ethereum mainnet, our official NFTFactory address is 0xc852aC7aAe4b0f0a0Deb9e8A391ebA2047d80026; on Goerli testnet, the address is 0x25315F9878BA07221db684b7ad3676502E914894. Third-party counterfactual NFT factories can implement our factory method.

Compute NFT Address API

You can compute counterfactual NFT addresses by interacting with the factory smart contract. We also provide an API for convenience.
Endpoint: /api/v3/nft/info/computeTokenAddress Parameters:
  1. 1.
    nftFactory: the official NFT factory address.
  2. 2.
    nftOwner: the owner address.
  3. 3.
    nftBaseUri: this is to support another feature in the future, but is currently not supported.
tokenAddress: "0x883ef03d5039c63a03bacf7e37cfccb067829cb5"

When to deploy counterfactual NFT contracts?

If all the NFTs under a counterfactual NFT contract only ever stay on Layer 2, the contract will never need to be deployed. But Layer 1 deployment is necessary for the following transactions to be successful:
  • An NFT is to be withdrawn to Layer 1.
  • The owner wants to mint on Layer 1.
Deploying counterfactual NFT contracts is permissionless. The idea is that for someone to perform the above transactions, they will first have to deploy the contract at his/her own cost. It’s possible to interact with our factory contracts directly to deploy counterfactual NFT contracts. Loopring also provides an API so people can request for us to deploy counterfactual NFT contracts on their behalf, but Layer 2 fees will apply.