This project enables users to stake their NFTs (Non-Fungible Tokens) on the Solana blockchain, including traditional NFTs, PNFTs (Pre-Tokenized NFTs), and CNFTs (Compressed NFTs). The staking system allows users to earn rewards by staking their NFTs into a pool, and rewards are distributed periodically.
This repository contains both the smart contract and the frontend/backend components necessary to interact with the staking system.
- Project Overview
- Features
- Tech Stack
- Smart Contract
- Frontend
- Backend
- How to Run
- How to Contribute
- License
This repository contains a full-stack solution for Solana-based NFT staking:
- Smart Contract: Written in Rust using the Anchor framework, allowing users to stake and unstake NFTs, and claim rewards.
- Frontend: A React.js app that allows users to connect their Solana wallet (via Phantom, Sollet, etc.) and interact with the staking contract.
- Backend: A simple Node.js backend using Express.js for managing rewards and interacting with the Solana blockchain.
The project supports different types of NFTs:
- NFT: Standard Solana NFTs (minted on Solana using Metaplex).
- PNFT: Pre-Tokenized NFTs, designed for faster interaction with the blockchain.
- CNFT: Compressed NFTs, designed for more efficient storage.
- Stake NFTs: Users can stake their NFTs into a staking pool.
- Reward System: NFTs staked will earn rewards over time.
- Multiple NFT Types Supported: Supports standard NFTs, PNFTs, and CNFTs.
- Unstake NFTs: Users can unstake their NFTs at any time.
- Reward Claiming: Rewards are calculated based on the duration the NFTs are staked.
- Transaction History: Users can view transaction history of staking and reward claims.
- Multi-Wallet Support: Supports wallets like Phantom, Sollet, and others for user interaction.
- Solana Blockchain: The smart contract is deployed on the Solana blockchain.
- Rust & Anchor Framework: Used to write and deploy the smart contract.
- React.js: For building the frontend of the application.
- Node.js & Express.js: Backend server to handle interactions with the Solana blockchain and provide API endpoints.
- Metaplex: For working with Solana NFTs (including CNFTs and PNFTs).
- Phantom Wallet: Solana wallet extension for connecting users' wallets.
The smart contract is written in Rust using the Anchor framework and is responsible for the staking logic, reward distribution, and NFT management.
- Stake NFTs: The contract allows users to stake Solana NFTs, including PNFTs and CNFTs.
- Rewards Calculation: It calculates and stores rewards for staked NFTs.
- Unstake NFTs: Users can unstake their NFTs and claim rewards.
- Ownership Verification: Ensures that only the owner of a specific NFT can stake it.
- Clone the repository.
- Navigate to the
smart-contract
directory. - Install Anchor and Rust dependencies:
anchor install rustup install nightly
- Build and deploy the smart contract to the Solana devnet:
anchor build anchor deploy --provider.cluster devnet
- Interact with the deployed contract using the provided frontend and backend.
The frontend is built using React.js and provides a user-friendly interface to interact with the staking smart contract.
- Wallet Integration: Users can connect their Solana wallets (e.g., Phantom, Sollet) to the frontend to manage their NFTs.
- Stake NFTs: Interface to select and stake NFTs.
- Claim Rewards: Users can claim rewards earned by staking.
- Unstake NFTs: Users can unstake their NFTs and view transaction history.
- Clone the repository.
- Install dependencies:
npm install
- Start the frontend development server:
npm start
- Open http://localhost:3000 in your browser to interact with the dApp.
The backend is built using Node.js and Express.js. It handles requests from the frontend, interacts with the Solana blockchain to manage staking and rewards, and stores staking data in a database.
- API for Staking and Unstaking NFTs: Provides API endpoints for staking and unstaking NFTs.
- Reward Calculation: Calculates rewards based on the duration of NFT staking.
- Transaction History: Stores and retrieves the user's staking transaction history.
- Clone the repository.
- Install dependencies:
npm install
- Configure your Solana cluster and wallet in the
.env
file. - Start the backend server:
npm start
- The backend server will run on http://localhost:5000.
- Install Node.js (v14 or above)
- Install Solana CLI
- Install Anchor Framework
- Create a Solana wallet (e.g., Phantom) and fund it with test SOL for development.
- Clone the repository.
- Set up the Solana environment by running the following commands:
solana config set --url devnet solana airdrop 2
- Run the smart contract:
anchor build anchor deploy --provider.cluster devnet
- Run the backend:
cd backend npm install npm start
- Run the frontend:
cd frontend npm install npm start
- Open http://localhost:3000 to access the frontend.
- Fork the repository.
- Create a new branch:
git checkout -b feature-branch
. - Make your changes.
- Commit your changes:
git commit -am 'Add new feature'
. - Push to the branch:
git push origin feature-branch
. - Open a Pull Request.
For any questions, feel free to contact me:
- Telegram: @Immutal0
- Twitter: @Immutal0_