This project implements an NFT minting, vaulting, and swapping system on the Solana blockchain using the Anchor framework. The program allows users to mint NFTs, lock them in a vault, and swap SOL for NFTs.
- Mint a collection of NFTs
- Lock NFTs in a vault with a rental system
- Claim rent from locked NFTs (returned to the protocol)
- Swap SOL for NFTs
- Node.js v18.18.0 or higher
- Rust v1.77.2 or higher
- Anchor CLI 0.30.0 or higher
- Solana CLI 1.18.9 or higher
-
Clone the repository:
git clone https://github.com/SudhanPlayz/NFT-Vault.git cd NFT-Vault
-
Install dependencies:
npm install
-
Build the Anchor program:
anchor build
-
Start a local Solana test validator:
solana-test-validator
-
Deploy the program:
anchor deploy
Execute the test suite:
anchor test
The program consists of several instructions:
initialize_vault
: Set up the vault to store NFTsmint_nft
: Create a new NFTlock_nft
: Lock an NFT in the vaultunlock_nft
: Retrieve an NFT from the vaultclaim_rent
: Claim accumulated rent from locked NFTsswap_sol_for_nft
: Exchange SOL for an NFT from the vault
Vault
: Stores information about locked NFTs and accumulated rentNFTData
: Contains metadata for minted NFTs
The program defines custom error codes:
NFTNotFound
: Thrown when trying to unlock an NFT that's not in the vaultNoNFTsAvailable
: Thrown when trying to swap SOL for an NFT when the vault is empty
To modify the program:
- Edit the Rust code in
programs/nft-vault/src/lib.rs
- Update tests in
tests/nft-vault.ts
as needed - Run
anchor build
to compile changes - Run
anchor test
to ensure everything works correctly