Build your first NFT marketplace
This is about NFT marketplaces and how you can build them with SHYFT Marketplace APIs
Last updated
This is about NFT marketplaces and how you can build them with SHYFT Marketplace APIs
Last updated
Welcome to the first episode of the marketplace series.
If you have already gone through this part of the series, Click here for the next part of the series.
NFT Marketplace, like a regular marketplace, is a digital platform where we can store, list, and sell Non-Fungible Tokens (or NFTs). Users need a Crypto Wallet to connect to the marketplace, trade, and showcase their most desirable NFTs. These tokens can be of any type, such as pictures, Digital Art, Music, writings, or anything else, and generally, they are available for trading, purchase, or even auctions starting at a certain price.
SHYFTâs Marketplace API holds the upper hand over other regular marketplace APIs in certain aspects:
No backend infrastructure is needed: A few API calls in the front end are good to take your product to market and scale without hassle.
Set any currency: Choose SOL or any SPL token(USDC, mSol, RAY, or create your own) as the marketplace currency.
Super fast reads for better UX: Cached NFTs and metadata allow lightning-fast reads, ensuring your users a smooth experience.
Marketplace Stats: Access your marketplaceâs detailed stats in real-time, manually tracking sales is no longer required.
Auctions and Bidding: Instantly enable on-chain auctions and bidding on NFTs.
Royalty Distribution: Our APIs honor the original creators by making sure they get their royalty.
This is a series of Tutorial Blogs that will show how you can create and set up a simple NFT marketplace within minutes using SHYFT APIs. You can also check out our sample project on NFTs and marketplace which we have built using SHYFTâs Marketplace APIs.
Read The SHYFT Marketplace APIs Documentation here.
Shyft creates escrow-less marketplaces, where the NFTs remain in a user's wallet until the sale is complete. There are a few important concepts to understand and efficiently use these APIs.
authority: The account which has the permission to update the marketplace properties and execute a withdrawal from the marketplace treasury. By default, the marketplace creator is the authority.
Creator: The account which pays the gas fee for executing the marketplace creation instruction.
Fee Recipient: The destination account address, that will receive the funds whenever they are withdrawn from the marketplace treasury.
Fee Payer: An account that is used to pay for Solana fees for the seller and buyer if the marketplace chooses to execute the sale in the background.
Transaction Fee: The percentage of every sales transaction amount that will be deposited in the marketplace treasury. By default, all the Shyft-created marketplaces have a 2% transaction fee.
Treasury: The marketplace treasury is an on-chain account where all the transaction fee received by the marketplace gets deposited and remains there until withdrawn.
Currency Address: The SPL token that is used as the currency in the marketplace. SOL is the default currency, if not provided while marketplace setup.
Currency Symbol: The on-chain symbol of the SPL token currency of the marketplace.
Listing: Before an NFT can be sold and bought by a user, it has to be listed for sale in the marketplace at a certain price. Listing represents an NFT on sale.
List State: An on-chain address where all the transactions that happen on an NFT listing are stored. This is unique for each NFT listing created. Generated at the time of list creation.
xxx_wallet: In the following doc, there are API input parameters ending with the wallet. These are essentially the accounts that pay the gas fee of the API's operation.
x-api-key
is an authentication parameter, which gives you access to SHYFT APIs. You can get your own API Key from the SHYFT website. Just signup with your email id here and you can get it for free.
We will need the Phantom wallet browser extension, you can download it from the link below.
Once done, set up your Phantom wallet account. On-screen tips are available which will guide you to set up and get started. You can also find a detailed guide related to this here.
Once you have collected your own x-api-key
from the SHYFT Website, we can start creating an NFT marketplace using SHYFT APIs.
The API endpoint for the create request
The Request Header
The Request Parameters (body)
network (Required Parameter) : Selects the Solana blockchain network instance, can be devnet
,testnet
or mainnet-beta
.
creator_wallet (Required Parameter) : The Wallet Address used for creating the marketplace. This wallet will be responsible for paying the gas fees during the create marketplace transaction.
authority_address : Wallet address for the wallet which will have all the master controls over the marketplace. This wallet will have access to all the critical operations of the marketplace such as the authority to update the wallet, withdraw units from the treasury, etc. By default i.e. if left blank, the value of this field will be the creator_wallet.
currency_address : The address of the SPL Token which will be used for the marketplace transaction. If no token address is provided, the default value for this field is SOL.
fee_payer : An account that is used to pay for Solana fees for the seller and buyer if the marketplace chooses to execute the sale in the background. By default, it is the value of the creator address.
fee_recipient : The destination wallet address that will receive the funds whenever they are withdrawn from the marketplace treasury.
transaction_fee : This is the percentage, not a number. This indicates the percentage of the sale amount for each sale transaction, which is deposited in the marketplace treasury. By default, its value is 2%.
We can directly execute this API call using JavaScript or any programming language, or we can create and use a form to collect all the values required for executing this API call. Once this API request is successfully executed, we should have a response that should look somewhat like this.
Note: This is a sample response, the actual one may have different values, but the fields will be the same.
Note: One marketplace owner cannot own two marketplaces with the same currency and wallet address.
Once we successfully execute the API call and get the response successfully, we should receive an encoded_transaction
in response. Now, this encoded_transaction
needs to be signed using the user wallet, or the user's private key.
Learn how to sign encoded transactions here.
or
Use this deployed website to easily sign with a wallet or a private key in your front end:
https://shyft-insider.vercel.app/
Once signed successfully, the NFT marketplace will be created and will be ready to use. You can also modify an existing marketplace using SHYFT APIs if you have the update authority i.e. the authority_address
while creating the marketplace is your wallet address.
Only the wallet, which was set as the update authority (authority_address)
during the marketplace creation has the authority to update the marketplace. Parameters that can be updated in an existing marketplace:
authority_wallet: The wallet id that has the update authority to the marketplace can be updated, by passing in the new authority wallet in the new_authority_wallet
field.
transaction_fee: The transaction fee (percentage) set for each transaction in the marketplace, can be set to a new value.
fee_payer: The existing fee_payer for the marketplace background transaction can be assigned to a new wallet.
fee_recipient: The existing fee_recipient for the marketplace can be assigned to a new wallet.
Endpoint for updating an NFT marketplace.
Parameters:
The parameters are similar to the ones used in the create marketplace API. This API also returns an encoded_transaction
similar to the create marketplace API, and the transaction needs to be signed using the user wallet.
So, That's pretty much everything about this blog, which shows us how to create a simple NFT marketplace on the Solana blockchain using SHYFT APIs.
In the next episode, we will see how to list, buy and perform transactions on the marketplace we just created in this episode. Happy Hacking and stay tuned. đ
Tool for Signing Transaction on Solana
Join our Discord
If you liked this, you can also read our tutorials on How to get your user's token balances? or How to sign transactions on Solana.