👋 Welcome! This demo app is designed to help you learn to build on Flow.
- Kitty Items: CryptoKitties Sample App is a complete NFT marketplace built with Cadence, Flow's resource-oriented smart contract programming language.
- Learn how to deploy contracts, mint NFTs, and integrate user wallets with the Flow Client Library (FCL).
Check out the live demo of Kitty Items, deployed on the Flow Testnet.
Looking for a step by step guide? Follow the Kitty Items tutorial in the Flow documentation.
🛠 This project requires NodeJS v16.x
or above. See: Node installation instructions
🛠 This project requires flow-cli v0.32.1
or above. See: Flow CLI installation instructions
git clone --depth=1 https://github.com/onflow/kitty-items.git
- Run
npm install
in the root of the project.
You'll need to run the following command in the web project:
From the ./web
directory run npm install -D @next/swc-darwin-arm64
-
Run
npm run dev:emulator
- Local development uses the Flow Emulator and the FCL Development Wallet to simulate the blockchain and an FCL-compatible wallet.
-
In another terminal, from the root of the project run
flow dev-wallet
Thats it! 🏁
Run npm run dev:testnet
and follow the prompt to begin developing on testnet.
Above is a basic diagram of the parts of this project contained in each folder, and how each part interacts with the others.
1. Web App (Static website) | kitty-items/web
A true dapp, client-only web app. This is a complete web application built with React that demonstrates how to build a static website that can be deployed to an environment like IPFS and connects directly to the Flow blockchain using @onflow/fcl
. No servers required. @onflow/fcl
handles authentication and authorization of Flow accounts, signing transactions, and querying data using using Cadence scripts.
2. Look Ma, a Web Server! | kitty-items/api
We love decentralization, but servers are still very useful, and this one's no exception. The code in this project demonstrates how to connect to Flow using Flow JavaScript SDK from a Node JS backend. It's also chalk-full of handy patterns you'll probably want to use for more complex and feature-rich blockchain applications, like storing and querying events using a SQL database (Postgres). The API demonstrates how to send transactions to the Flow blockchain, specifically for minting Kitty Items (non-fungible tokens).
3. Cadence Code | kitty-items/cadence
Cadence smart contracts, scripts & transactions for your viewing pleasure. This folder contains all of the blockchain logic for the marketplace application. Here you will find examples of fungible token and non-fungible token (NFT) smart contract implementations, as well as the scripts and transactions that interact with them. It also contains examples of how to test your Cadence code.
Items are hats for your cats, but under the hood they're non-fungible tokens (NFTs) stored on the Flow blockchain.
Items can be purchased from the marketplace with fungible tokens. In the future you'll be able to add them to Ethereum CryptoKitties with ownership validated by an oracle.
- Chat with the team on the Flow Discord server
- Ask questions on the Flow community forum
You'll need to run the following command in the web project:
From the ./web
directory run npm install -D @next/swc-darwin-arm64
If you're running on another non-intel based system, the issue and troubleshooting steps are detailed here: vercel/next.js#30468
- The
api
andweb
projects depend onsqlite3
. If you changenode
versions on your system, you'll need to cd into theweb
andapi
directory and runnpm rebuild
to rebuild you dependencies for the new version.
- You can see what processes have been started, and if they are online using
pm2 list
- You can tail logs for individual processes using
pm2 logs [process name]
. eg.,pm2 logs api
orpm2 logs web
- You can tail all logs in the same terminal using
pm2 logs
- In the event of problems, you may want to start over. To reset the project, perform these steps:
- Run
pm2 delete all
to stop and delete all processes - Delete database files in
./api
. (kitty-items-db-*.sqlite
)
- Run
- Kitty Items uses the following ports. Make sure they are not in use by another process
8080
: Flow emulator3569
: Flow emulator3000
: Kitty Items API3001
: Kitty Items web app8701
: FCL dev-wallet
- The Kitty Items Marketplace on testnet is universal. Every instance of Kitty Items deployed on Testnet points to the same marketplace (
NFTStorefront
) contract. So, you may see other listing s showing up in your Kitty items instance, but you will not see items in your marketplace page that were added before you deployed your instance of Kitty Items.
🚀 Happy Hacking!