LAB: Mint Your First NFT

Transcript

Toggle full transcript
00:00

Hello and welcome back. In this lab, we're going to finally be able to mint our first

00:10

NFT on ImmutableX because we've laid the groundwork in the previous labs. The next step is actually quite simple. If you go to the Minting assets section of the Readme.md file,

00:20

then you'll see a description here of what needs to happen. Now, first and foremost, we need to go to our .env file.

00:30

And scroll down to the token ID section. This TOKEN_ID parameter will be used to determine which token

00:40

we mint. ImmutableX uses integer token IDs. Typically you would start with token one and then mint, token two, three, four, etc..

00:50

The key thing is that when you mint a token, you just need it to be unique. Otherwise the operation will fail. We've included a command that you can run to do the actual mint.

01:00

So in this case I'm going to mint token number one. And then the command is here. We basically do npm run mint.

01:10

Then we pass the dash dash, which tells NPM that we're about to pass some command line arguments to the underlying command. And then we pass a -w and have a wallet address.

01:20

The wallet address here will be the wallet that receives the minted NFT on ImmutableX.

01:30

Now to keep things simple, we can use the wallet address of the wallet that we've already created. So if we go to the top of our dot and they file, we can grab our owner

01:40

account address and put that in the clipboard and then we can run. npm run mint -- -w

01:50

and paste in our wallet address. We can see here that this is running the source onboarding slash five dash

02:00

mint script. And while we wait for that to execute, we can have a look at this script. The script is very similar to the other scripts that we've been looking at.

02:10

We retrieve our wallet from the command line -w argument, we grab our token ID from the environment which we added to our .env

02:20

file. We create our immutableX client. We create a payload that represents the token that we're trying to mint. This consists of the contract address, which is the address of the smart

02:30

contract that we deployed to the underlying Ethereum blockchain.

02:40

It includes the key of the wallet that we want to receive the NFT. And it contains the tokens or in this case token that we actually

02:50

want to mint, which consists of two arguments the id of the token and the blueprint.

03:00

The blueprint is data that gets provided at ImmutableX Minting time that is then passed through to Ethereum if you ever withdraw

03:10

the NFT. So it can then used by your smart contract to construct any token metadata on the Ethereum blockchain. The blueprint is also accessible via the IMX API.

03:20

Finally, we call the minter.mintV2() API call with our payload, which actually creates the NFT.

03:30

And we can see at the bottom here that we've output the result from that API call and it's given us the token ID, the contract address and the ImmutableX transaction ID as per the readme.md File.

03:40

Once you have minted your NFT, you can actually view it on the ImmutableX marketplace.

03:50

So we've got a URL template here that you can construct with your token ID. So in this case it was 1 and the contract

04:00

address that you've been using, which should also be in the output from the API. So if we copy this URL here and we

04:10

go to our web browser, then we should be able to visit that and see our NFT.

04:20

And you'll notice that the owner address here should equate to the owner address that you put in, which we can see here,

04:30

it does. And the name of the collection should match the name of the collection that we previously configured in our .env file,

04:40

which we can see it does. Now, something to keep in mind is that ImmutableX caches the metadata for the NFTs and it can take a while for

04:50

that case to update sometimes up to a couple of minutes. So in this case, we see that there's no image preview and the name and description

05:00

of this NFT are not present. However, if you wait until the metadata has been cached and

05:10

you refresh the page like you see here, then that metadata will update and look something like this. So there we go. An exciting milestone.

05:20

We've minted our first NFT on ImmutableX. Congratulations. In the next few chapters of this course, we're now going to expand on this knowledge and start exploring the other skills that you need

05:30

to be able to use this NFT minting capability for a real world scenario.