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.
First, we use
CREATE2to 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.
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.
You can compute counterfactual NFT addresses by interacting with the factory smart contract. We also provide an API for convenience.
- 1.nftFactory: the official NFT factory address.
- 2.nftOwner: the owner address.
- 3.nftBaseUri: this is to support another feature in the future, but is currently not supported.
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.