AtomicAssets Collection Management with JavaScript (I)

Categories TutorialsPosted on

Collections are the main pillar of NFT management. If we want to use the AtomicAssets standard to create our NFTs in WAX blockchain, the first thing we have to do is to create a collection that serves as a container catalogue for all the NFTs (and that are part of the context of that collection).

It doesn’t matter if our intention is to create a series of NFTs for blockchain video games or to sell art; it is very important that all the NFTs that are related to the project are part of a collection that facilitates their management by us and by users and third-party applications.

All the collection creation and management operations can be done from the official AtomicHub interface but, in this series of articles, we are going to explain how we can manage all the necessary operations to create and maintain our collection of NFTs from JavaScrip.

These are the actions we are going to cover in this article:

  • createcol: Create collection
  • addcolauth: Add authorised account to the collection
  • remcolauth: Remove an authorised account
  • addnotifyacc: Add account that will receive notifications
  • remnotifyacc: Remove an account from the list of notifications
  • setcoldata: Modify collection information
  • setmarketfee: Modify collection fee
First we are going to create the working environment so that we can connect to the blockchain. We must connect to a WAX full API node to be able to send our calls to the AtomicAssets smart contract actions.

Data types for atomicassets

Before we start we need to familiarise ourselves with the structure of the data types used by atomicassets to serialise the information in the NFTs. The documentation can be found here:

https://github.com/pinknetworkx/atomicassets-contract/wiki/Custom-Types#attribute_map

Some Sample Data for Testing

To document our examples we will use the blockchain testnet and several example accounts. The reader should use their own test accounts.

Sample accounts used:

  • arpegiator21 -> Collection owner
  • arpegiator25 -> Secondary account
  • arpecol11111 -> Collection name

The private “active” key of the authorised account is required to sign transactions when a contract action is called. In our example we have stored this key in an environment file that we load into the code using the “dotenv” library.

Create collection

The contract action to create a collection is “createcol”.

  • author: Account creator and owner of the collection.
  • collection_name: Collection name (eosio names format)
  • allow_notify: Allow notifications to other accounts (Yes/No)
  • authorised_accounts: Array of accounts authorised to perform other operations, such as NFT minting.
  • notify_accounts: Array of accounts that will receive notifications of actions performed with the collection (mint, transfer, burn, etc).
  • market_fee: % commission that the creator of the collection will receive for operations in other markets. Max 17%.
  • data: Description of the collection in ATTRIBUTE_MAP format.

For our example we will use the following data:

  • author: arpegiator21
  • collection_name: arpecol11111

Let’s see the complete collection description:

And call to action “createcol“:

Modify AtomicAssets Collection Data

To modify a NFT collection in AtomicAssets we will use a data structure very similar to the one used to create the collection. The action must be signed by an authorised account in the collection.

And call to action “setcoldata“:

Add or Remove Authorized Accounts to AtomicAssets Collection

We can add or remove authorised accounts in our collection at any time by using the “addcolauth” or “remcolauth” actions.

The input parameters will be the name of the collection and the account name to add or remove.

The action must be signed by an authorised account in the collection.

To simplify our example we have designed a function that will add or remove the bead depending on the value of a logical switch.

If the switch is true, the action “addcolauth” (account_to_add parameter) will be called and if it is false, the action “remcolauth” (account_to_remove parameter) will be called.

Add or Remove Notify Accounts to AtomicAssets Collection

We can add or remove accounts to the notification list through actions very similar to the previous ones; “addnotifyacc” and “remnotifyacc“.

Modifying the market fee for a collection of AtomicAssets NFTs

To conclude this section, we will see how we can modify the royalty rate of our collection. This fee will be collected by the NFT markets on the purchase/sale operations of any NFT in our collection.

Follow us on:
Discord: https://discord.gg/3dkrender
Twitter: https://twitter.com/MarcoS3DK

Leave a Reply

Your email address will not be published. Required fields are marked *