Create Collection

Allows user to create an NFT Collection with a different contract (token) address.

Key notes to remember:

  • Metadata is required to allow user to mint NFTs to a collection

  • when the collection is deployed, the NFTs will have a different contract (token) address on Layer 1.

  • User can view/edit their own Collection information on Loopring L2.

Create Collection
const eddsaKey = await signatureKeyPairMock(accInfo);
const {apiKey} = await LoopringAPI.userAPI.getUserApiKey(
 { accountId: accInfo.accountId,},
 eddsaKey.sk
);
const response = await LoopringAPI.userAPI.submitNFTCollection({
	name: 'XXX' + Date.now(), //required, one account is not able to multiple
	tileUri: 'ipfs://QmaNZ2FCgvBPqnxtkbToVVbK2Nes6xk5K4Ns6BsmkPucAM', //required
	description: 'test',
	owner: mockData.accInfo.owner,
	avatar: 'ipfs://QmaNZ2FCgvBPqnxtkbToVVbK2Nes6xk5K4Ns6BsmkPucAM',
	banner: 'ipfs://QmaNZ2FCgvBPqnxtkbToVVbK2Nes6xk5K4Ns6BsmkPucAM',
	nftFactory: NFTFactory_Collection[LOOPRING_EXPORTED_ACCOUNT.chainId as ChainId ]},
	LOOPRING_EXPORTED_ACCOUNT.chainId as ChainId,
	mockData.apiKey,
	mockData.eddsaKey.sk)
console.log('createCollection', response)
getUserNFTByCollection
const response = await LoopringAPI.userAPI
	.getUserNFTCollection(
		{
			accountId: mockData.accInfo.accountId.toString(),
			limit: 24,
			offset: 0,
		},
		mockData.apiKey
	)
	.catch((_error) => {
		throw _error;
	});
console.log("getUserNFFByCollection", response);
getUserOwnCollection (User's own created collection)
const response = await LoopringAPI.userAPI
  .getUserOwnCollection(
    {
      owner: mockData.accInfo.owner,
      limit: 24,
      offset: 0,
      tokenAddress: undefined,
      isMintable: false, //false
    },
    mockData.apiKey
  )
  .catch((_error) => {
    throw _error;
  });
console.log("getUserNFFByCollection", response);
getUserNFTCollection (User asset NFT's Collections)
const response = await LoopringAPI.userAPI
  .getUserNFTCollection({
    tokenAddress: contract, // option
    collectionId: id, // option
    accountId:  mockData.accInfo.accountId,
    limit: 20,
    offset:10,
  }, mockData.apiKey)
getCollectionWholeNFTs (NFTs in the Collection)
 const response = await LoopringAPI.nftAPI.getCollectionWholeNFTs({
  id: 279, // collection id, it can from Market config, my NFT's -> collectionInfo, or getUserNFTCollection  
  offset: 0,
  limit: 24,
  metadata: true,
});

    

Last updated