├── .gitignore ├── .prettierrc ├── README.md ├── ReadApi ├── WrapperConnection.ts └── types.ts ├── example.env ├── metaplex ├── fetchNFTsByGroup.ts ├── fetchNFTsByOwner.ts ├── mintToCollection.ts ├── simpleProofVerification.ts └── transferNFT.ts ├── package.json ├── scripts ├── changelog.ts ├── createAndMint.ts ├── fetchNFTsByCollection.ts ├── fetchNFTsByOwner.ts ├── mintToCollection.ts ├── transferNFT.ts ├── verboseCreateAndMint.ts └── verifyCreator.ts ├── tsconfig.json ├── utils ├── compression.ts └── helpers.ts └── yarn.lock /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # public/robots* 4 | public/rss* 5 | public/sitemap* 6 | .contentlayer 7 | 8 | # dependencies 9 | /node_modules 10 | /.pnp 11 | .pnp.js 12 | test-ledger 13 | 14 | # testing 15 | /coverage 16 | 17 | # next.js 18 | /.next/ 19 | /out/ 20 | 21 | # production 22 | /build 23 | 24 | # misc 25 | .DS_Store 26 | *.pem 27 | 28 | # debug 29 | npm-debug.log* 30 | yarn-debug.log* 31 | yarn-error.log* 32 | .pnpm-debug.log* 33 | # local env files and key files 34 | .env* 35 | .env*.local 36 | .local_keys 37 | .local_keys2 38 | 39 | # vercel 40 | .vercel 41 | 42 | pnpm-lock.yaml 43 | yarn.lock 44 | package-lock.json -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "tabWidth": 2, 3 | "useTabs": false, 4 | "singleQuote": false, 5 | "printWidth": 100, 6 | "trailingComma": "all", 7 | "arrowParens": "avoid", 8 | "endOfLine": "auto", 9 | "proseWrap": "always" 10 | } 11 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # State Compression and Compressed NFTs 2 | 3 | At a high level, state compression is a technique in which off-chain data is secured by the Solana 4 | ledger, using a hashing algorithm to "fingerprint" the _off-chain_ data and storing it inside a 5 | special _on-chain_ Merkle tree, called a Concurrent Merkle Tree. 6 | 7 | With this technology, compressed NFTs can be created on-chain in a similar manner as before, but for 8 | a fraction of the cost as before. As a frame of reference of on-chain cost reduction, take a 1 9 | million NFT collection: 10 | 11 | - traditional NFTs (aka non-compressed): 12 | - 1 million NFTs ~= 12,000 SOL 13 | - compressed NFTs: 14 | - 1 million NFTs ~= 5 SOL 15 | 16 | ## Quick links to learn more 17 | 18 | - Solana Docs for [State Compression](https://docs.solana.com/learn/state-compression) 19 | - written guide 20 | [minting compressed NFTs](https://solana.com/developers/guides/javascript/compressed-nfts) (which 21 | is based on this repo) 22 | 23 | ## Tech stack of this repo 24 | 25 | - uses TypeScript and NodeJS 26 | - yarn (as the node package manager) 27 | 28 | ## Setup locally 29 | 30 | 1. Clone this repo to your local system 31 | 2. Install the packages via `yarn install` 32 | 3. Rename the `example.env` file to be named `.env` 33 | 4. Update the `RPC_URL` variable to be the cluster URL of a supporting RPC provider 34 | 35 | If you have the Solana CLI installed locally: update the `LOCAL_PAYER_JSON_ABSPATH` environment 36 | variable to be the **_absolute path_** of your local testing wallet keypair JSON file. 37 | 38 | ## Recommended flow to explore this repo 39 | 40 | After setting up locally, I recommend exploring the code of the following files (in order): 41 | 42 | 1. [`./scripts/verboseCreateAndMint.ts`](./scripts/verboseCreateAndMint.ts) 43 | 2. [`./scripts/fetchNFTsByOwner.ts`](./scripts/fetchNFTsByOwner.ts) 44 | 3. [`./scripts/transferNFT.ts`](./scripts/transferNFT.ts) 45 | 46 | After reviewing the code, then running each of these scripts in the same order. 47 | 48 | > **Note:** Running each of these scripts will save some bits of data to a `.local_keys` folder 49 | > within this repo for use by the other scripts later in this ordered list. Therefore, running them 50 | > in a different order will result in them not working as written. You have been warned :) 51 | 52 | ### Running the included Scripts 53 | 54 | Once you're setup locally, you will be able to run the scripts included within this repo: 55 | 56 | ``` 57 | yarn demo ./scripts/