> For the complete documentation index, see [llms.txt](https://docs-protocol.loopring.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs-protocol.loopring.io/counterfactual-nft/sdk-guides/create-collection.md).

# Create Collection

{% hint style="info" %}
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.
* [Example of a Collection metadata](https://loopring-1.gitbook.io/loopring-university/create-your-nft/minting-nft-on-loopring/requirements-when-minting/example-with-collection-metadata)
  {% endhint %}

<details>

<summary>Create Collection</summary>

{% code overflow="wrap" lineNumbers="true" %}

```ts
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)
```

{% endcode %}

</details>

<details>

<summary>getUserNFTByCollection</summary>

{% code overflow="wrap" lineNumbers="true" %}

```ts
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);
```

{% endcode %}

</details>

<details>

<summary>getUserOwnCollection (User's own created collection)</summary>

{% code overflow="wrap" lineNumbers="true" %}

```ts
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);
```

{% endcode %}

</details>

<details>

<summary>getUserNFTCollection  (User asset NFT's Collections)</summary>

{% code overflow="wrap" lineNumbers="true" %}

```ts
const response = await LoopringAPI.userAPI
  .getUserNFTCollection({
    tokenAddress: contract, // option
    collectionId: id, // option
    accountId:  mockData.accInfo.accountId,
    limit: 20,
    offset:10,
  }, mockData.apiKey)
```

{% endcode %}

</details>

<details>

<summary>getCollectionWholeNFTs (NFTs in the Collection)</summary>

{% code overflow="wrap" lineNumbers="true" %}

```ts
 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,
});

    
```

{% endcode %}

</details>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs-protocol.loopring.io/counterfactual-nft/sdk-guides/create-collection.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
