Introduction
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.
Create2Upgradeable.computeAddress(
keccak256(abi.encodePacked(NFT_CONTRACT_CREATION, owner, baseURI)),
keccak256(CloneFactory.getByteCode(implementation))
);Last updated
Was this helpful?