LAB: Create a User, Project And Collection


Toggle full transcript

Hello and welcome back. In this lab, we're going to take the next step and create a user project and collection within ImmutableX.


This will then pave the way for us to be able to mint our first NFT on ImmutableX. The first thing we need to do is to register our user within ImmutableX.


ImmutableX has the concept of users that correspond 1 to 1 with their wallet. So all we need to do, again, we've got a helpful


command here that does a lot of the work for us. And what this does is it takes the wallet that we previously


generated and that we put in our .env file. Up the top here is the owner account and essentially passes that to the ImmutableX user registration API.


If you want to see the code behind that, you can go to src/onboarding/1-user-registration.ts And you can see the


code that actually interacts with the ImmutableX API. You can see here we create an ImmutableX client. We set up a signer on that client using the wallet from our private key


connected to our Alchemy provider. We then check whether or not that user already exists within ImmutableX.


And if it doesn't, we call the user.register() IMX API call. And then as you can see here, the user has been successfully created


in this instance. The second step is to register an email address with the ImmutableX Developer Hub.


This is necessary in order to give you the permission to be able to create a project. So in order to do this, all we need to do is click through to the ImmutableX developer hub that


will guide you through a process of signing up and answering some questions. In this case, I've already registered an account and


I'm already logged in. Feel free to pause the video at this point while you perform the registration process. Once you've registered an account, you just need to take


note of the email address that you've actually used to register because you're going to need that.


So the next step then is to create our ImmutableX project that is going to house our NFT collection. In ImmutableX, a project is an administration


grouping that is associated with your wallet. Once you create a project, then that wallet will be able to create one


or more collections within that project. Each collection is associated 1 to 1 with an IMX compatible ERC-721 smart contract that is deployed to the underlying


Ethereum blockchain. When you mint NFTs on ImmutableX, these NFTs are minted within the context of the collection that's associated with your smart


contract. To create a project, we go back to our .env file and we scroll down to the project's details section.


Now you can come up with a project name and a company name. But the key thing here is that you just need to make sure that the email address that


you've registered is headed into the project email field. So


I'm just going to fill in a project name of Makerversity Lab and a company name of Makerversity in this instance.


And then, again, we've got a helpful command that you can run here. In


this case, If you want to see the code behind this command, you can go to src/onboarding/2-create-project.ts.


It's very similar to the previous user registration one, except the API call that is being made is user.createProject() instead of the previous one.


And we can see here that it's called this API. We got 201 CREATED back and a message of created


project with ID 1579. So we can now follow this instruction here and actually copy this value here and update


our .env and you'll see that there's a line waiting for us to fill that in and then we can save that. The next step


then, is to create a collection within our project. So before we create this collection, there's some values in the


EMV file that you might want to change. So you can change the collection name. In this case, I'm just going to call it Makerveristy Lab


NFTs. And if you want, you can change the description, the icon and the image URL. I'm just going to keep those the same in this case


and save that file again to create the collection. We've got a helpful command that you can run.


So if we copy that one there and execute it, we can see that again, there's a script here that we can have a look at if we're interested in this


case. It's 3-create-collection.ts. And again, the structure of this script is very similar to the previous two, except that the API call


is user.createCollection(). We can see here that that API call has succeeded and we've


dumped out the response that that API has given us. So we can see we've actually created this collection on ImmutableX, which is very exciting.


And that takes us to the end of this lab. In this lab we've basically set up all of the behind the scenes registrations on ImmutableX that we need to do to get to the point where we can actually mint an NFT.


So we've registered a user corresponding to our wallet. We've registered our email address in the Emacs developer hub.


We've created a project on ImmutableX and then we've created a collection that corresponds to the smart contract that we deployed to


Ethereum. I'll see you in the next lab and can start actually minting some NFTs.