Build your First NFT Dapp
With Shyft's API you can create applications to mint NFTs.
Last updated
Was this helpful?
With Shyft's API you can create applications to mint NFTs.
Last updated
Was this helpful?
In this tutorial we will build a simple dapp that allows you to create an NFT on Solana blockchain, using Shyft APIs. At the end of this tutorial your newly minted NFT will be available in your own wallet.
To get started first thing first, let's install a browser extension of Phantom Wallet from below links:
Once installed, open Phantom in your browser, and follow the on-screen steps to create a new wallet. Refer to this , if you need help. Now, you have a public-private key pair that serves as an identity on blockchain.
Steps for mac:
Alright, now we are all set to create our first NFT minting dapp. We will use ReactJs to build a simple front end to allow you to interactively create a NFT. We will use VS Code to walk through the tutorial.
This creates the boilerplate code for your dapp, and file structure looks like below:
Let's create a new form for accepting all the details(parameters) we will require to create a new NFT. We have created a new component for the form, but you can also put this code directly under App.js
This is a simple form with takes in the following parameters:
Choose an image file that you want to mint as an NFT
Select the network (testnet, devnet, mainnet-beta)
Your phantom wallet's public key
NFT Name
NFT symbol
NFT description
External_Url, this can be link to any website that you want to put in. This will be visible in the phantom wallet account for navigation.
Number of editions of one particular NFT that can be minted. can be set to zero, if you want to create an one-of-a-kind NFT.
Royalty percentage of the NFT creator. Can be any value between 0 - 100.
Attributes associated to the NFT. It's a json array string, don't forget to Stringify as done in below code snippet.
Once we have the data, we are ready to make the API call. For this tutorial, we have used the axios
package to make the API call, but you can use any other methods including JavaScript's very own fetch.
axios
will allow your react application to make http request to Shyft's
server and create your NFT.
Now, let's create a function for making the API call using the data we have collected using the form we created in this tutorial.
The API Endpoint used:
Now you are all set to mint your first NFT. Please note that this API does not require the private key, instead it uses the public key to sign the transaction required for the create operation.
Head over to the terminal and start the react app, by running:
npm run start
Your basic app will look like this:
All you have to do is enter the information in the fields and hit submit button.
Response :
Once we receive the encoded_transaction
in the response, the last and final step is to sign the transaction. We can sign encoded_transaction
in two ways, either using the wallet from the frontend, or by using the wallet's private key
from the backend.
To check, if the NFT is created on the blockchain.
Paste the mint
value (the on-chain address of your token) returned in the response in the search bar, you should get the details of the created NFT.
Details of the transaction can be checked by pasting txnId
from the response in the previous search bar on Solana explorer.
By now, NFT has already been received in your wallet!!
Go to Your Collectibles
tab of your phantom wallet, and you should see the newly created NFT.
I hope you enjoyed this tutorial and are excited to dive deep into web3 awesomeness. Stay tuned for more such tutorials. If you want the complete code for this project with good looking UI, please checkout/fork and play with the code at this Repository.:
x-api-key
is an authentication parameter, which gives you access to SHYFT APIs. You can get your own API Key from the . Just signup with your email id and you can get it for free.
We need to include the obtained from the SHYFT website in the header section of this API call. For details about this API and the parameters used, read the API Documentation .
Link to complete App.js
file, after making the above changes: .
As soon as you hit submit the request is sent to the Shyft server, and you have successfully created a new NFT transaction. Now, all you need to do is sign this transaction using your wallet and voila! Your newly created NFT will be added to your wallet.
You can read more about signing transactions on Solana , or you can use our online dev tool for signing this encoded transaction available in the below link.
Once successfully signed, your NFT will be created and added to your wallet.
Go to , select the network. (Devenet for this tutorial)
Feel free to check out our other tutorials on and on as well.
Join our
Thank you for your time. We hope you have a great time building dApps with . Happy hacking.