Solana NFT Marketplace program with NFT Trading & Auction
Need to build up anchor development environment
anchor version 0.24.2
solana version 1.14.17
node version 18.17.0
- Prepare anchor development environments
- Prepare aroun 12 SOL in the deploy wallet keypair
- Confirm Network cluster in
Anchor.tomlfile : f.e.[programs.devnet],cluster = "devnet" - Confirm deploy authority wallet keypair location : f.e. `wallet = "/home/ubuntu/deploy-keypair.json"
- Configure solana cli with deploy authority keypair and deploying cluster : f.e.
solana config set -h - Build program with
anchor build - Copy and paste the result deploy scripts from Build terminal message : f.e.
solana program deploy /home/ubuntu/project/target/deploy/nut_marketplace.so
- Delete the program keypair in
/target/deploy/nut_marketplace-keypair.json - Build project with
anchor build. This will generate new keypair - Get the address of new keypair with
solana address --keypair ./target/deploy/nut_marketplace-keypair.json - Change program addresses in project code.
Anchor.toml,/program/nut_marketplace/src/lib.rs - Build program object again with
anchor build - Deploy newly built so file with
solana program deploy
Able to run all commands in /cli/command.ts file by running yarn ts-node xxx.
When you get this error
Error: Provider local is not available on browser.
You can run this command export BROWSER= once.
- Install
nodeandyarn - Install
ts-nodeas global command - Confirm the solana wallet preparation in
package.json:/home/fury/.config/solana/id.jsonin test case
- Initialize program with
initcommand - Should configure the marketplace fee with
update_feecommand - Should add at least one
treasurywallet withadd_treasurycommand for the fee distribution - Should Initialize user PDA with
init_usercommand for the first time usage
Initialize Program with creating Global PDA account as Contract Deployer.
Get global PDA info of program. This will show marketplace fee the treasury wallet distributions.
Admin able to update the Marketplace Fee with this command as Admin.
sol_feeis the fee in permyraid
Admin able to add the team treasury wallet distribution rate for the marketplace fee charge.
addressis the treasury walletrateis the wallet's distribution rate by permyraid
Admin able to remove the team treasury wallet.
addressis the treasury wallet
Initialize User Data PDA for Escrow Balance & Traded Volume. This command should be executed for the first time usage of each traders.
Get user PDA info for traders. This will show user escrow balance and traded volume info.
addressis the trader wallet address
Transfer NFT from Sender wallet or it's listed Escrow Account to the Recipient.
addressis the NFT mint addressrecipientis the recipient wallet address
List NFT for sale as Seller.
addressis the NFT mint addressprice_solis the listing price of NFT
Cancel Listing of NFT as Seller.
addressis the NFT mint address
Purchase the Listed NFT with Buy Now price as Buyer.
addressis the NFT mint address
Make offer for a particular Listed NFT as Buyer.
addressis the NFT mint addresspriceis the offering price. Should be in range ofx1 ~ x0.5of listed price
Cancel maden offer for a particular Listed NFT as Buyer.
addressis the NFT mint address
Accpet proper offer from a certain Buyer as Seller.
addressis the NFT mint addresbuyeris the Offer provider address
Create Auction for a particular NFT for funny trading as Seller.
addressis the NFT mint addressstart_priceis the bidding start pricemin_increaseis the minimum increasing amount for the higer biddingdurationis the auction period since started time by secondreserveif this is 1, then the auction is reserve to start from the first bid placed date. Default 0
Participate in auction with higher bidding as Buyer.
addressis the NFT mint addresspriceis the higher bidding price. Should be more than the latest bid + min_increase_amount
Claim NFT for winner as Buyer when auction is ended.
addressis the NFT mint address
Cancel auction as Seller if there is no bid until auction ended.
addressis the NFT mint address
Get nft Sell Data PDA info for a particular listed NFT status.
addressNFT mint address
Get Offer Data PDA info for a particular Offer status.
addressNFT mint addressbuyeris the offer provider address
Get Auction Data PDA info for a particular auction status.
addressNFT mint address
Get all listed NFTs info which is active for sale now.
Get all offers info for a particular NFT which is active for accept now.
Get all auctions info which is live now or not claimed ended auction.
For the FE side web3 integration, the scripts in lib directory can be use without no change.
The only thing the FE dev should change is providing web3 connection & the anchor program object from idl.
There is the code part for the keypair wallet based cli environement case in cli/scripts.
Should configure properly in BROWSER environment.
This script will fetch past Txs reacted with Our Marketplace Smartcontract. Then will parse an activity from each Txs so that use the info for DB sync up.
yarn be