Ayush a3b87a4948 update: tokens native, formatter, trigger action on project changes (#81) 1 year ago
..
programs 39a2518210 revert cnft example cargo.toml 1 year ago
tests a3b87a4948 update: tokens native, formatter, trigger action on project changes (#81) 1 year ago
.gitignore feaf2a1eb7 move folder 2 years ago
Anchor.toml feaf2a1eb7 move folder 2 years ago
Cargo.toml 56dafe4b4a add resolver = "2" to fix compile warning 1 year ago
README.md feaf2a1eb7 move folder 2 years ago
package.json f116e3891a update to @coral-xyz/spl-token 0.30.0 1 year ago
pnpm-lock.yaml a3b87a4948 update: tokens native, formatter, trigger action on project changes (#81) 1 year ago
tsconfig.json a3b87a4948 update: tokens native, formatter, trigger action on project changes (#81) 1 year ago

README.md

Solana Program cNFT Transfer example

This repo contains example code of how you can work with Metaplex compressed NFTs inside of Solana Anchor programs.

The basic idea is to allow for transfering cNFTs that are owned by a PDA account. So our program will have a vault (this PDA) that you can send cNFTs to manually and then withdraw them using the program instructions.

There are two instructions: one simple transfer that can withdraw one cNFT, and one instructions that can withdraw two cNFTs at the same time.

This program can be used as an inspiration on how to work with cNFTs in Solana programs.

Components

The Anchor program can be found in the programs folder and tests some clientside tests. There are also some typescript node scripts in tests/scripts to run them individually (plus there is one called withdrawWithLookup.ts which demonstrates the use of the program with account lookup tables).

Deployment

The program is deployed on devnet at CNftyK7T8udPwYRzZUMWzbh79rKrz9a5GwV2wv7iEHpk. You can deploy it yourself by changing the respective values in lib.rs and Anchor.toml.

Limitations

This is just an example implementation. It is missing all logic wheter a transfer should be performed or not (everyone can withdraw any cNFT in the vault). Furthermore it is not optimized for using lowest possible compute. It is intended as a proof of concept and reference implemention only.

Further resources

A video about the creation of this code which also contains further explanations has been publised on Solandy's YouTube channel: https://youtu.be/qzr-q_E7H0M