Create Collection
Group various atomic assets in a collection.
There are two ways to create a collection:
- Using Asset IDs - If you have already created atomic assets or want more control on each atomic asset in the collection, you can use this method.
- Using Asset Files - This method is used to create a collection from a set of files. The Assets will share the same traits such as License, Description but will vary in suffixes. eg -
Asset #0
,Asset #1
,Asset #2
etc.
Using Asset IDs
Basic Syntax
The function is called as follows:
Input Parameters
The function takes one input parameter - opts: CreateTradableAssetOpts
. It contains the following parameters
- assetIds:
string[]
: An array of asset IDs to be grouped in the collection. - collection:
CollectionSpecificTags
: The collection specific tags as per Collection Data Protocol. It contain feilds such as name, collectionType, thumbnail, banner and collectionCode. For details on the options see the Collection Specific Tags section. - discoverability:
DiscoverabilityTags
: The discoverability tags for the Collection as per ANS-110 Specification. Contains feilds like title, description, type and topics. For details on the options see the Discoverability Tags section.
type should be equal to Document
as per the Collection Data Protocol
- stamp (optional):
StampableType
: The stamping options for the collection. If stamp is specified the your collection can be stamped by others. Defaults to false. For details on the options see the Stamping Options section. - additionalTags (optional):
Tag[]
: Additional tags for the Atomic Asset. Duplicate tags will throw an error. For details on the options see the Tag section.
For details on the options see the Create Collection Options section.
Return Value
The function returns a promise that resolves to UploadResponse
, Transaction
, or TurboUploadDataItemResponse
depending on whether Irys or Turbo are used or not.
UploadResponse
- Returned when Irys is used. It contains fields such as:- id:
string
- The transaction ID of the collection. - signature:
string
- The signature used while creating the collection. - timestamp:
number
- The timestamp of the transaction.
- id:
Transaction
- Returned when Arweave is used. It contains fields such as:- id:
string
- The transaction ID of the collection. - owner:
string
- The owner of the collection. - tags:
Tag[]
- The tags of the collection. - data:
Uint8Array
- The data of the collection. - signature:
string
- The signature used while creating the collection.
- id:
TurboUploadDataItemResponse
- Returned when Turbo is used. It contains fields such as:- id:
string
- The transaction ID of the collection, - timestamp:
number
- The timestamp of the transaction, - winc:
string
- The amount of Turbo Credits, in Winston Credits, spent on the upload, - version:
string
- The version number of the upload receipt returned, - deadlineHeight:
number
- The latest block height in which the uploaded data will be settled on Arweave, - dataCaches:
array
- A list of nodes where the data was cached while upload to Arweave is pending, - fastFinalityIndexes:
array
- A list of nodes where data is made available while waiting for it to settle on Arweave, - public:
string
- The public key of the wallet used for upload, - signature:
string
- The signature used while creating the collection, - owner:
string
- The owner of the collection.
- id:
Example Usage
Using Asset Files
Basic Syntax
The function is called as follows:
Input Parameters
The function takes two input parameters:
-
callback:
(progress: CollectionProgress, error?: string) => void
: The callback function to be called for progress, CollectionProgress has two parameters:- step:
string
: The current step of the transaction. - progress:
number
: The progress of the transaction out of 100.
- step:
-
opts:
CreateCollectionOpts
: It contains the following parameters:- assets:
File[]
|string
: An array of files or the path to the directory containing the files to be grouped in the collection. - thumbnail:
File
|string
: The thumbnail file or the path to the thumbnail file for the collection. - banner:
File
|string
: The banner file or the path to the banner file for the collection. - license (optional):
LicenseTags
: Universal Data License Tags for the Asset. By default base UDL tags will be used. For details on the options see the License Tags section. - initState: The Initial state for each Atomic Asset, it contains the following parameters:
- ticker:
string
: The ticker for the asset. - balances:
Record<string,number>
: The initial balances for each wallet. The key is the wallet address and the value is the balance.
- ticker:
- collection:
CollectionSpecificTags
: The collection specific tags as per Collection Data Protocol. It contain feilds such as name, collectionType, and collectionCode. For details on the options see the Collection Specific Tags section. - discoverability:
DiscoverabilityTags
: The discoverability tags for the Collection as per ANS-110 Specification. Contains feilds like title, description, type and topics. For details on the options see the Discoverability Tags section.
type should be equal to
Document
as per the Collection Data Protocol- stamp (optional):
StampableType
: The stamping options for the collection. If stamp is specified the your collection can be stamped by others. Defaults to false. For details on the options see the Stamping Options section. - additionalTags (optional):
Tag[]
: Additional tags for the Atomic Asset. Duplicate tags will throw an error. For details on the options see the Tag section.
- assets:
For details on the options see the Create Collection Options section.
Return Value
The function returns a function called mutateAsync
which when called returns a promise that will resolve to UploadResponse
, Transaction
, or TurboUploadDataItemResponse
depending on whether Irys or Turbo are used or not.
UploadResponse
- Returned when Irys is used. It contains fields such as:- id:
string
- The transaction ID of the collection. - signature:
string
- The signature used while creating the collection. - timestamp:
number
- The timestamp of the transaction.
- id:
Transaction
- Returned when Arweave is used. It contains fields such as:- id:
string
- The transaction ID of the collection. - owner:
string
- The owner of the collection. - tags:
Tag[]
- The tags of the collection. - data:
Uint8Array
- The data of the collection. - signature:
string
- The signature used while creating the collection.
- id:
TurboUploadDataItemResponse
- Returned when Turbo is used. It contains fields such as:- id:
string
- The transaction ID of the collection, - timestamp:
number
- The timestamp of the transaction, - winc:
string
- The amount of Turbo Credits, in Winston Credits, spent on the upload, - version:
string
- The version number of the upload receipt returned, - deadlineHeight:
number
- The latest block height in which the uploaded data will be settled on Arweave, - dataCaches:
array
- A list of nodes where the data was cached while upload to Arweave is pending, - fastFinalityIndexes:
array
- A list of nodes where data is made available while waiting for it to settle on Arweave, - public:
string
- The public key of the wallet used for upload, - signature:
string
- The signature used while creating the collection, - owner:
string
- The owner of the collection.
- id:
You don’t need to include the banner and thumbnail feilds in the collection parameter. They will be automatically added to the collection after uploading.
Example Usage
Was this page helpful?