BlockPetz is a showcase project demonstrating the capabilities of the Metaplex "Core". It's a web application where users can mint, feed, and burn their virtual pets, called BlockPetz. It's a great starting point for developers interested in building NFT projects on the Solana blockchain using the latest Metaplex spec for digital assets.
To install and run the development environment for this project, follow these steps:
- Install the project dependencies:
pnpm install
# or
npm install --legacy-peer-deps
-
Copy the
.env.example
file to a new file named.env.local
and fill in the necessary environment variables. -
Start the development server:
pnpm run dev
This will start the development server on http://localhost:3000
. You can open
this URL in your web browser to view the application.
The important source code to highlight in this project is in the hooks that handle minting, burning, and feeding:
- Minting: The
useHandleMint
hook in src/hooks/use-handle-mint.ts is used to handle the minting of BlockPetz. - Fetching Assets: The
useAssetsByOwner
hook in src/hooks/use-assets-by-owner.ts is used to handle the fetching all BlockPetz that owned by a wallet. - Burning: The
useHandleBurn
hook in src/hooks/use-handle-burn.ts is used to handle the burning of BlockPetz. - Feeding: The
useHandleFeed
hook in src/hooks/use-handle-feed.ts is used to handle the feeding of BlockPetz. This feature is particularly interesting as it demonstrates how attributes of an NFT can be updated on-chain, opening up a whole new range of possibilities such as NFT-based gaming.
Each of these hooks makes use of the Metaplex "Core" capabilities.
pnpm dlx @biomejs/biome format ./src --write
pnpm dlx @biomejs/biome lint ./src
pnpm dlx @biomejs/biome check --apply-unsafe ./src