Mint a Layer 2 NFT. Loopring follows the IPFS NFT format.
The SDK can be used to mint NFTs on Loopring's Layer 2. Minting uses IPFS and the CID will convert into the nftId. Review MetaNFT.md for additional details.
Step 1: Get Account
Prepare your Loopring Layer 2 account. Retrieve account information.
conststorageId=awaitLoopringAPI.userAPI.getNextStorageId( { accountId:accInfo.accountId, sellTokenId:LOOPRING_EXPORTED_ACCOUNT.nftTokenId,// same as maxFee tokenId }, apiKey);
Step 5: Get tokenAddress
Before mint user should create an collection for information with an url, follow code using the user own collection-list first item as demo
constcollectionRes=awaitLoopringAPI.userAPI.getUserOwenCollection({ owner:accInfo.owner, isMintable:true }, apiKey )if ((collectionRes && ((collectionRes assdk.RESULT_INFO).code || (collectionRes assdk.RESULT_INFO).message)) ||!collectionRes.collections.length) {console.log("Collection is disable to mint ");throw"Collection is disable to mint ";}constcollectionMeta= (collectionRes asany).collections[ 0 ] asCollectionMeta;constcounterFactualNftInfo:NFTCounterFactualInfo= { nftOwner:accInfo.owner, nftFactory:collectionMeta.nftFactory ??sdk.NFTFactory_Collection[ sdk.ChainId.GOERLI ], nftBaseUri:collectionMeta.baseUri,};constnftTokenAddress=collectionMeta.contractAddress,
Step 6: Get fee
Retrieve the mint fee.
Step 7: Mint
Mint the NFT
Congratulations! You have now minted your counterfactual NFT!