NFTs on Solana
How do NFTs work on Solana?
Solana NFTs use the Metaplex Standard to add metadata information to regular SPL Tokens.
You can think of SPL Tokens as equivalent to Ethereum's ERC-20 tokens. The Metaplex protocol is responsible for adjoining extra data onto these ERC-20-like tokens, effectively making them NFTs. If their max supply is set to 1, then it can be seen as an ERC-721 token. For higher or unlimited supplies the NFT can be compared to an ERC-1155 token. But in the end, they're the same thing!
What do I need in order to mint an NFT?
A Cryptum API key is the only requirement to create your brand new NFT for Solana. However, you probably want to add images, titles, symbols, attributes, etc. to your token. This information should be hosted in a service like Pinata or arweave, and not on the token itself.
For this example, we'll suppose you already managed to upload a JSON object to Pinata according to the Metaplex standard:
name
string
Name of the asset.
symbol
string
Symbol of the asset.
uri
string
URI to the external JSON representing the asset
creators
array
public key of each creator
update_authority
string
public key of the metadata owner
primary_sale_happened
boolean
flag describing whether the primary sale of the token happened
seller_fee_basis_points
number
royalties percentage awarded to creators
description
string
Description of the asset.
image
string
URI pointing to asset image.
animation_url
string
URI pointing to asset animation.
external_url
string
URI pointing to an external url defining the asset, the game's main site, etc.
attributes
array
Array of attributes defining the characteristics of the asset.
Make sure to check the latest specifications in the official Metaplex documentation here.
Creating NFTs Programmatically with Cryptum SDK
Step 1
The first prerequisite you will need is the creation of an account and a Project (API Key) on Cryptum Dashboard.
PS: Our dashboard is almost ready! To generate an API Key, contact [email protected]
Step 2
With a valid Cryptum API Key, you can then instantiate the SDK as follows:
const CryptumSdk = require('cryptum-sdk')
const sdk = new CryptumSdk({
environment: 'testnet', // 'testnet', 'mainnet'
apiKey: "YOUR-API-KEY-HERE",
})
Step 3
Towned to create the NFTs:
const wallet = await sdk.wallet.generateWallet({
protocol: 'SOLANA',
mnemonic: 'lorem ipsum dolor sit amet consectetur adipiscing.....',
derivation: { account: 0, address: 0 }
})
Step 4
Call sdk.nft.create
function passing your wallet, the desired supply, and the URI to create NFT with limited supply and a master edition.
// Creating NFT with master edition and max supply of 10 copies
const { hash } = await sdk.nft.create({
protocol: 'SOLANA',
wallet,
name: 'NFT',
symbol: 'NFT',
uri: 'https://....',
maxSupply: '10',
creators: [{ address: 'Er...4h', share: 10, verified: true }], // optional
royaltiesFee: 10, // optional
collection: null // optional
})
To create NFT without limited supply and master edition do this:
// Creating NFT without master edition and no max supply
const { hash } = await sdk.nft.create({
protocol: 'SOLANA',
wallet,
name: 'NFT',
symbol: 'NFT',
uri: 'https://....',
amount: '100000'
})
There you go! The hash
variable now holds the token address, which you can inspect in an explorer such as this one or this other one.
Minting NFTs
To mint more NFTs on Solana you have to pass the wallet with the token's mint authority, the token address, destination address and the amount.
The amount
must be 1 or null
if this NFT has a master edition.
const { hash } = await sdk.nft.mint({
wallet,
protocol: 'SOLANA',
token: 'TOKEN_ADDRESS',
destination: 'Hvm.....9Gxe',
amount: '11'
})
Transferring NFTs
To transfer NFTs in Solana, just pass the token address, token address, the destination address and the amount:
const { hash } = await sdk.nft.transfer({
wallet: wallets.solana,
protocol: 'SOLANA',
token: 'TOKEN_ADDRESS',
amount: '2',
destination: 'DohbPo7UF.....94hmj2ohr'
})
Burning NFTs
To burn NFTs on Solana you have to pass the wallet that owns the NFT, the token address and the amount:
const { hash } = await sdk.nft.burn({
protocol: 'SOLANA',
wallet,
token: 'EzqZ...qnCNd',
amount: '100',
})
If you want to check the full Solana NFTs doc, go to:
Last updated