How to create an NFT on Solana? A complete step-by-step guide
From pixelated art selling for millions to NBA video highlights selling for thousands of dollars, NFTs have created a lot of buzz in 2021. Are you a beginner who wants to create some NFT projects? In today’s guide, we will discuss everything about creating an NFT on the Solana blockchain.
So, Why Choose Solana to Begin with?
Well, if you know about Ethereum crypto, Solana is almost a similar one. Both ETH and Solana allow people to build on top of their blockchain platform by using smart contracts. So, why should you choose Solana over Ethereum? Because it is much more scalable with faster block times and low transaction fees.
Before we get into the details of the mining process, let’s discuss what is NFT crypto in the first place.
NFT: A Gist
A non-fungible token is basically a group of data saved on a blockchain that certifies any digital asset to be one-of-a-kind and interchangeable. To create an NFT, you must build a token that represents a file, photo, video, or whatever you want. So, how does an NFT expert use the Solana blockchain to develop tokens? Let’s get into the step-by-step details.
Learn how to work with Solana
Before we start talking about the list, make sure that you have all the required tools installed on your system. To help a first-timer like you get a grasp on Solana, here are the three easy steps to follow:
1.Setting Up a Solana Wallet : A wallet is where you will store all your tokens and NFTs. There are many different ways to create a wallet but we will talk about the command lines in today’s blog.
First of all, install the Solana Tool Suite you need to create your wallet. Once installed, open the terminal (on Linux/Mac) or Command Prompt (on Windows).
Now in the terminal/Command Prompt, move to the desktop and create a folder to store your NFT crypto data by giving the below-mentioned command:
solana-keygen new — outfile SolanaWallet/my-keypair.json
Finally, create the wallet and secure it with a password. Voila! Your new Solana wallet is ready. At this point, you will receive a public address that will be a long string of numbers and letters. Save this PUB KEY as later you have to use it several times.
Now that, you have a wallet, you will need some SOL, the currency of Solana blockchain (just like Ethereum’s ETH). You can get some free SOL on the devnet, the playground version of Solana. When you are going live on the real deal, you will be using the mainnet.
To get one free SOL on the devnet, you have to give the command like:
Boom! Now you have 1 SOL in your wallet on the devnet. If you want a better way to use your wallet, you can also use Solana Explorer. Visit the website, go to the top right corner change the button to devnet from mainnet, paste in YOUR_ADDRESS and your account will get 1 SOL!
You can also use the Phantom Wallet, a Chrome/Brave extension that makes it quite easy to interact with Solana Dapps. However, once you are ready with your wallet, let’s move on to the next step of your NFT crypto creation.
2.Creating Your Own Token : Now the process of creating your own token might sound a bit complex but relax, you can do it! At first, you need to set your configuration to use the devnet:
Next, you need to point to the location of your keypair.json file on your desktop:
solana config set — keypair SolanaWallet/my-keypair.json
The final step is creating your token with just this one command:
Boom! You have created your token successfully. Your token is a string of numbers and letters just like your public address.
So, how to store your new token in your wallet? Well, you need to create an account:
spl-token create-account YOUR_TOKEN
Once you have an account in your wallet to accept all the tokens, it’s time for you to mind some tokens!
spl-token mint YOUR_TOKEN 420
That’s how you can add 420 new tokens and sell or send them to whoever you want. Do you want to add more tokens? Run all the above-mentioned commands again and create as many tokens as you want!
The Final Thoughts
Hope you found this NFT learn session quite helpful to understand how the Solana blockchain works. You can easily create multiple tokens, import wallets, and transfer all your tokens between the wallets.
If you want to learn more about minting NFT on the Solana blockchain, you can always opt for a crypto trading certification before getting started with your projects.
Create your NFT app on Solana in 10 minutes¶
While ETH was reaching new heights in terms of traffic, price, and dApps development, new blockchains have arisen to tackle some of Ethereum’s main problems. One of them is Solana, currently the 6th largest blockchain in terms of market valuation.
Ethereum’s main problems are, of course, transaction speed and enormous transaction fees. Solana did manage to solve these perfectly, allowing up to 65,000 transactions per second and reducing transaction costs to $0.00025 per transaction. Going further, Solana has its own programming language that lets us create dApps, NFTs, and more. Overall, it’s a pretty solid competitor to Ethereum.
Why is Solana worth trying?¶
As with every blockchain, there are a few things that make Solana unique. Let’s look at some of Solana’s technical features, which are also called the 8 innovations of Solana.
Proof-of-History
In order to make communication cost and latency more efficient in conjunction with Proof-of-Stake, Solana integrates the concept known as a Proof-of-History. It’s a clock before consensus is reached, i.e. before agreeing on a blockchain state. It uses a recursive verifiable delay function to hash incoming events and transactions. It massively reduces overhead, thereby allowing scalability.
Sealevel
“A hyper parallelized transaction processing engine designed to scale horizontally across GPUs and SSD”. All other blockchains are single-threaded. Solana changed this status quo and became the first blockchain that is able to support parallel transaction execution in a single shard. It means that the blockchain will only become faster with time, allowing, once again, massive scalability.
Gulf Stream
Solana found a way to manage a mempool size of 100,000. Other blockchains use “gossip protocols” to propagate their mempools, and since gossip protocol, as its name states, achieves its purpose by exchanging information between nodes, it gets overwhelmed. Gulf Stream pushes transactions caching and forwarding to the edge of the network. This makes it possible for validators to execute transactions ahead of time.
60,000 Transactions Per Second (TPS)
Currently, Visa / Mastercard can process up to 65,000 TPS, which sets the bar for the cryptocurrencies pretty high (if they ever wish to replace it). In comparison, Bitcoin can process up to 7 TPS, which is super low. Solana, on the other hand, due to the technical solutions listed above can process up to 60,000 TPS!
If you’re curious and want a deeper explanation, you can find the perfect one here, written by Anatoly Yakovenko, a Co-Founder of Solana.
Solana Faucet, aka “Give me free funds!”¶
Moving forward into the development phase. As always, the first step when creating NFTs on any blockchain is to acquire the funds needed for transaction fees. Usually, we use a faucet service in order to get test funds. Solana is no different! After typing “Solana Faucet” on Google, we can see the following page:
Compared to Tezos, getting test funds on Solana is very simple. But first things first.
Solana Wallet
In order to sign and execute transactions, we need some sort of wallet. Unfortunately, since Solana is not compatible with Ethereum, we can’t use Metamask, as it supports only Ethereum-based currencies. That’s not a problem, though! Solana has a similar app named Phantom, which is a web browser extension as well as a mobile app wallet, so it’s super convenient to use. It looks like this:
If you want to change the network, you have to go to the settings page at the bottom and change the network to the desired one, which in our case is devnet.
Important: in order to create NFTs, you have to be on devnet, and NOT on testnet; otherwise it won’t work, since Rarible SDK doesn’t support testnet.
After that, click on “Deposit”, copy your wallet address, and paste it into the Solana Faucet. After approximately 0.002 seconds, we should have our test funds available. Ahh, the beauty of Solana. ☀️
Creating NFTs on Solana blockchain using Rarible SDK¶
In order to create NFTs on Solana, we will use the exemplary app provided by Rarible. You can get it here:
The exemplary app is located on the packages/example in the repo below:
In order to kickstart the project, you have to follow instructions disclaimed on Readme, which basically limits to running:
command from the root folder (not the packages/example folder).
Exemplary Application
The coolest aspect of the exemplary application is that it showcases all the possibilities the SDK provides. It’s also a fast way to validate what you can achieve with the Rarible SDK (which is a lot ).
Connect Wallet
In order to create NFTs, we have to connect a wallet first, which in Solana’s case is either Phantom or Solflare. As I stated earlier, I’m going with Phantom. What’s important here is to set the environment for “development”, that will allow you to use your wallet. After connecting, you should see the current status as “connected”.
Deploying Collection
In order to successfully deploy a collection, you have to pass a Metadata URI, which is a JSON with collection properties, usually stored on IPFS. It looks like this:
You can find an explanation about all the available options for Metadata URI here. All fields are mandatory — properties and image may be empty. Name , symbol , and description are used to describe your token, seller_fee_basis_points is a royalties percentage, i.e. the percent of each following sale that will go to the creator. Image and properties are used for additional assets, and creators tell how the royalties should be distributed
When it comes to uploading documents to IPFS, you can do it as you want. If you’re interested in doing it from the code level, check one of our previous article, but you can also use Pinata for that purpose. After getting your Metadata URI, which is a link to JSON stored on IPFS, and which looks like this:
Paste it to the adequate field. The Phantom window should pop up, as it’s shown below. Notice the predicted amount of SOL that will be subtracted from your account as a transaction fee.
If you see “transaction may fail to confirm”, it means that either you don’t have enough funds, or you’re connected to the wrong chain.
After a successful collection creation, you should see information about the created collection:
The most important information here is the collection address. With that, you can always fetch any related information from the Rarible API (see an article about that). After obtaining the collection id, we’re able to create an NFT by going to the “Mint Token” page.
Minting a Token
As you can see, there are two steps involved in that process. The first one is passing a collection ID, and the second one is sending a transaction. What’s super cool about the exemplary app is that, on the right side of the screen, there are always code snippets included. You’re able to examine how it actually happens at the code level! Below, you can see an example of token minting.
After the collection ID correctness check, we’re prompted to send a transaction. In order to do that, we have to pass a Metadata URI, which, again, is a JSON with properties that we’ll store on IPFS.
If you’ve passed the correct information, you should see the following screen:
This means that the NFT was successfully created .
How to see an NFT’s content
After the NFT creation, we can check what it contains using the Rarible API with the getItemById endpoint. An exemplary API call looks like this:
As a response, we can see all the details of the NFT:
And voila. Freshly minted NFT on Solana ready to trade, hold, or whatever you want to do with that.
Summary¶
In this article, we’ve learned how you can take advantage of the Rarible SDK and API to create and see an NFT on Solana. The most important thing to remember while developing is to set your Phantom network to devnet, and the environment to “development” on Rarible SDK. If you remember that, everything else should flow as smooth as butter.
How To Create NFT on Solana With IPFS
In case you slept through all of 2021, NFTs (non-fungible tokens) are hot. They have evolved from “random jpegs” to self-contained applications, access tokens, communities, and more. With increased creativity and expanding support across multiple blockchains, NFTs don’t look to be going away any time soon.
While Ethereum might be the first blockchain one thinks of when talking about NFTs, there are plenty of other chains out there to consider. I previously wrote about creating NFTs on the Flow blockchain, but an increasingly popular choice is Solana. Solana recently overtook Ethereum in total transaction volume in November of 2021, and Rarity Sniper (a tool for creating rarity rankings on NFT collections) moved to support Solana in 2021 after initially supporting Ethereum only.
With that as our background, let’s take a look at how to create an NFT collection on Solana using Pinata and IPFS. This is an especially interesting tutorial because Solana has been closely linked to Arweave, but many projects prefer IPFS for its rapid content access and reliability. Metaplex, a project built to make creating NFT projects on Solana easier is has IPFS support baked in, and this includes the ability to use Pinata to store content and serve that content through a dedicated IPFS gateway.
Setting Up The Development Environment
To begin, make sure you sign up for a Pinata account. You can test with a free account, but for a mainnet NFT launch, you may want to consider the Professional Plan with a Dedicated IPFS Gateway.
Once you’ve signed up for an account, you really just need to make sure you have the following installed (each is linked to the installed instructions of you need to install them):
- Node.js version 16.13.0 or newer is recommended
- Git version 2.32.0 or newer
- Yarn version 1.22.17 or newer
- ts-node version 10.4.0 or newer
- solana cli
For what it’s worth, we will be following much of the instructions on Metaplex’s website with some modifications that allow us to upload content to IPFS through Pinata.
Preparing The Assets
This tutorial is not going to go through the process of generating assets for your NFT project. That’s a totally separate endeavor that has to happen before the contract can be deployed to Solana. So, assuming you have the art created, we’ll walk through how to prep this for upload to IPFS through Metaplex.
The first step is to create a folder for your NFT project assets. From the command line, that will look like this:
Exit fullscreen mode
Inside that folder, create another folder called assets. In the assets folder, you will add all of your images. It’s important that each of your images be labeled in a base 0 index format. That means the first image would be 0.png and the second would be 1.png and so on.
Once your images are in the folder, you will need to create the metadata for these images. If you have any experience with Ethereum NFT metadata, you’ll feel right at home with Solana NFT metadata. The structure is nearly identical. Let’s took a look at a basic JSON metadata file structure for NFTs on Solana:
Exit fullscreen mode
Just like with the Ethereum metadata standard, the Solana metadata standard has a name, image, and description. Additionally, you can include attributes (just like with ETH), a symbol, and collection details. In Ethereum projects, the token symbol is generally assigned at contract deployment and not in the metadata. Another difference is the properties portion of the Solana metadata. This is required and it allows you to include an array of files for your NFTs. You have to have at least one file in that array which points to the same asset as the image property, but you can include other files that make up your entire NFT. This is a really interesting concept that should be explored further, but for the sake of this post, we will only be operating with single asset NFTs.
Ok, so we know we have images in the folder. We know those images need to be named in a specific way. And we know that we need JSON metadata files. How are we now going to get those JSON files created and added to the assets folder. You could do this manually, but with a 10,000 NFT project, that would be nearly impossible.
Let’s write a script to create the metadata files.
From your command line, make sure you are in the nft-project folder. We will create a new file called metadata-generator.js by running this command: touch metadata-generator.js .
In your code editor, open that new file. It’s empty, but we’ll fill it in now. We need to loop through all of the images in our assets folder and create a unique JSON file for each. We need to name and save that JSON file in the same assets folder. To do this, we will make use of the Node.js fs which is built into Node.js.
In your metadata-generator.js file add this code:
Exit fullscreen mode
To run your script and generate the metadata, you should run this command from the root your project folder: node metadata-generator.js .
When the script is finished, you’ll have an assets folder that has images and JSON files together.
Using Metaplex
Metaplex is a tool that makes launching an NFT project on Solana much easier. Rather than having to write your own smart contract like you would have to do with Ethereum, Metaplex has pre-written contracts that projects can plug into. To make this work, Metaplex has to be able to access the files associated with the NFTs, then it needs to be able to upload those files and associated them with each token to be minted.
Metaplex has support for IPFS through a few services, but we’ll be focusing on using Pinata.
We will be following the standard Metaplex Candy Machine guide found here. The first step is going to be to clone Metaplex. Run the following command in your terminal:
Exit fullscreen mode
We are cloning the directory into the home directory so that we don’t have to remember where the project was cloned. Inside the new metaplex repo is code to support the JavaScript CLI we will be making use of. So, we need to install dependencies for that CLI code.
yarn install —cwd
Now, let’s make sure the install worked. Remember, we installed ts-node? We’re going to use that now to run a command for the metaplex cli.
Exit fullscreen mode
This should print out a version if everything was installed properly. Now, we need to make sure the Solana CLI is working. Run this command to get the version number:
Exit fullscreen mode
If that works, you’re good to go. If not, double check that you have installed the Solana CLI Toolkit. Next, we’re going to use that CLI to create devnet wallet. The Solana devnet is where we can experiment without fear of incurring any real financial impact.
Run this command to create your new devnet wallet and store the keys:
Exit fullscreen mode
Now, we can set the default keypair for our Solana CLI interactions:
Exit fullscreen mode
Finally, let’s let the CLI know that we intent to interact with the devnet:
Exit fullscreen mode
To confirm this all worked as expected, we can fetch the configuration for Solana like this:
Exit fullscreen mode
This should print out the configuration information. If so, you’re ready to get airdropped some SOL!
This is, of course, devnet SOL, but it’s still necessary to interact with the devnet. Run this command:
Exit fullscreen mode
When that is complete, you can run this command to verify your devnet wallet has the SOL:
Exit fullscreen mode
You should see that your devnet wallet has 2 SOL.
With all of the initial Solana and Metaplex installation and configuration done, we will move on to configuring out NFT drop.
Drop Configuration
This is the most important part of the entire drop, so you should read about it in full here. Metaplex uses a tool called Candy Machine for NFT drops like this, and it’s important to make sure your project is configured properly.
In the root of your project, create a JSON file called config.json . Then, enter a configuration like this:
Exit fullscreen mode
This may feel like a lot, but this is actually just the minimum configuration required. There’s a lot more you can add. Don’t worry, though. We’re keeping it simple. You only need to change five things in this file. The first change is to set the storage property to point to pinata.
Then, you need to decide if you are going to use a Pinata Dedicated Gateway or not. Doing so will give you and anyone who loads your NFTs the best possible performance. But, while recommended it’s not required. If you do decide to get a Dedicated Gateway, you’ll need to upgrade to the Professional Plan in Pinata.
Next, you need to get a JWT for Pinata API access. To do so, click the dropdown menu in the top-right, click API Keys, then generate a new API Key. You can either select specific endpoints the key should have access to (pinFileToIPFS) or you can make it an admin key which has full access. This is up to your security preferences, but the key must have access to pinFileToIPFS. You can read more about scoped API keys here.
When you’ve created your key a modal will display your API Key, API Secret, and your JWT. We only need the JWT, so copy that and paste it into the pinataJwt configuration file property’s value.
If you created a Dedicated Gateway, you can paste in your Dedicated Gateway’s URL in the pinataGateway section of the config file. If you did not upgrade and do not have a Dedicated Gateway, you should update that property to look like this:
Exit fullscreen mode
Finally, you just need to set the number of items in your NFT collection for the number property and the price in SOL for the price property.
That’s all you need. Now, there’s a lot more you can do, but I want to point out something that a lot of projects probably want to do, and that’s hide the NFT assets until after a reveal date. This is possible with Metaplex and Candy Machine with hidden settings. You can read about that here. We won’t be doing that in this tutorial. The NFT project in this tutorial will represent a mint with immediate reveal.
The final thing you’ll want to change in the config file is the solTreasuryAccount. This should probably point to your devnet wallet address, but it can be any Solana wallet address. To get your devnet wallet address, you can run this in the command line:
Exit fullscreen mode
We’re about ready to upload some assets and create our NFT contract!
Uploading To Pinata and Solana
We’ve finished all the prep work. It’s time to upload. Fortunately, this is really simple.
In the root of the project directory, run this command in the command line:
Exit fullscreen mode
This command will take your config file parse it so that Metaplex knows how to upload your files and how to get the NFT mint info onto Solana. You’ll see in your command line each upload of your asset folder’s metadata and your asset folders images. Depending on how many files you are uploading this process could take a long time.
When the process is done, you’ll need to do one more thing. You’ll need to verify the upload. This helps you know if everything is ready to go and if your NFTs can be minted. You just need to run this command:
Exit fullscreen mode
If all goes well, you should see a message that includes Ready to deploy!. This means your project is ready to go.
Your NFT drop is ready for minting! But what do we do now? You probably want to create a website to allow for minting. Fortunately, the Metaplex code base has us covered.
Creating a Minting App
Remember, we cloned the the full repository for Metaplex? We cloned that into our home directory. So, from your command line, let’s change to our home directory and into the metaplex project, directly into the sample React app:
Exit fullscreen mode
You’ll need to install the dependencies like this:
yarn install
Then, open the project in your code editor. You’ll see a .env file in that folder. You should update it to look like this:
Exit fullscreen mode
Remember, we used the Candy Machine ID to look up our project on the Solana Explorer? We are going to paste that same ID where is says YOUR CANDY MACHINE ID.
Now, you can run the app with:
Exit fullscreen mode
When the app load, you should see:
You will be able to choose a Solana wallet to connect with. Regardless of which wallet you choose, you’ll need to make sure it has some devnet SOL in it. Remember when we airdropped ourselves some devnet SOL? We can also do that with another address. Connect your wallet, make sure you’re on devnet, then copy the wallet address. From the command line run:
Exit fullscreen mode
Once this is complete, you should have SOL in your browser-based wallet and can now mint one of your new NFTs. To do so, just click the Mint button:
You’ll need to confirm the transaction. When you do so, the minting process should only take a few seconds. Once it’s complete, your new NFT should show up in your wallet’s NFT collection.
The image you see of your NFT is being loaded from Pinata. Depending on if you provided a Dedicated Gateway URL in your config file, the NFT is loading through your custom gateway or a public IPFS gateway. Note: If you provided a Dedicated Gateway URL in the config, your NFT asset will not only load quicker but will be cached so that all subsequent loads are instant. You can see this in the example below using Phantom Wallet. The two NFTs that are stuck loading are using a public IPFS gateway. The two that load almost instantly are loaded through a Dedicated Gateway.
Wrapping Up
The benefits of using IPFS for the storage of NFT assets are well-documented. IPFS offers quick retrieval (especially when using a Pinata Dedicated Gateway), IPFS offers content addressability, and IPFS is portable. Ownership of NFTs can transfer in both the token sense and the media sense.
However, it has not always been easy to use IPFS with Solana NFT projects. Hopefully, this tutorial helps change that. Hopefully, it can lead to more creative projects.
Happy pinning, and happy drop days!
Solana Dev 101 — How to Mint an NFT on Solana
GM! In this blog we are going to dig into the world of Non-Fungible Tokens (NFTs) on Solana. By the end of this post you should have a clear understanding of the process and be able to create your own NFTs on Solana using JavaScript.
If you have any questions, don't hesitate to join the Helius Discord or tag Helius on Twitter for assistance.
Prerequisites:
Before we start, make sure you have Node.js and npm installed on your machine. You can download them here.
Step 1: Setup
First, we need to install the necessary dependencies. Run the following commands in your terminal to install the Solana JavaScript API and Metaplex JavaScript library:
Step 2: Importing Dependencies
Next, we can create a new file called mintNFTs.js and we can start off by importing the required dependencies:
Step 3: Create a Wallet , Initialise a Connection, and Create a Metaplex Instance
We need to create a Solana wallet which will be used to mint and hold the NFT. To achieve this we will use the Solana CLI tools, you can run the following command in the terminal to get a new wallet. This wallet will be saved as a JSON file containing the seed phrase.
You can import this into a browser wallet extension such as Phantom or Backpack.
⚠️WARNING ⚠️ : Make sure not to share your private key with anyone.
Now, we initialize a connection to the Solana cluster. We will be using Helius to connect to a mainnet cluster as this will be faster than the public RPC which is highly rate limited and does not have archival capabilities. ( https://api.mainnet-beta.solana.com ). If you would also like to use a faster and more premium RPC service instead of the standard RPC you can create a free Helius account here.
We will then create a wallet key pair from the seed phrase of the wallet that we just created.
In the above code we create an instance of the Metaplex SDK, a toolkit for interacting with the Metaplex protocol. We then configure the instance with a connection to a Solana cluster, the user's wallet, and a storage provider. .use(bundlrStorage()) configures the instance to use Bundlr as the storage provider, which is where the metadata and assets of the NFTs will be stored.
Step 4: Create and Upload the NFT Metadata
In this step we delve into the creation and uploading of the NFT metadata and image through the createMetadata() function.
One of the core parts of an NFT is the image, in this example we will be using this image of the Helius Logo! Make sure to add the image that you want to use to the directory where you have created the mintNFT.js file.
This function starts by reading the image file specified by imageName using fs , then converts it into a format suitable for Metaplex with toMetaplexFile(). We then upload the metadata using the metaplex.nfts().uploadMetadata() function. The metadata contains important details about our NFT, including its name , a description , the image we prepared, and a set of attributes that provide additional details about the NFT. There is a lot more data you can include in your NFT, you can read more about the Metaplex NFT standard here.
After the metadata is successfully uploaded the function will return the URI of the metadata which points to the online location of the data.
Step 5: Minting the NFT
Now we move forward with minting the NFT by creating a function called createNFT(). Initially, we invoke the createMetadata() function with "./heliusLogo.png" as the argument (path to the image file). Next, we mint the NFT by calling metaplex.nfts().create(). This function takes in an object with several properties such as the metadata URI, the name of the NFT, a seller fee (set here at 5%), and an array of creators, where each creator object includes the address and a share percentage of the amount of royalties that wallet should get. After successfully creating the NFT, the function will log the mint address of the NFT. This mint address is a unique identifier for the NFT on the blockchain. You can copy this address and look up the NFT on a block explorer such as XRAY.
Running this code with "node mintNFT.js" created the NFT that can be seen here.
Conclusion
Congrats! You have just created an NFT. I hope this tutorial was helpful in getting you started with NFTs on Solana. NFTs are a fundamental aspect of the Solana ecosystem so understanding how they are structured and how to create them is a great skill to have.