CryptoKnight is an educational project designed to help developers learn Cadence — the resource-oriented smart contract language on the Flow blockchain. By building and experimenting with a simple NFT-based battle game, you'll gain hands-on experience with core blockchain concepts like account storage, resource management, capabilities, and the Flow NFT standard.
Whether you're a complete beginner or a seasoned developer, CryptoKnight offers an engaging way to sharpen your Cadence skills and develop your own crypto games on Flow.
Here's a quick overview of the project structure:
.
├── cadence/ # Cadence smart contract code
│ ├── contracts/ # All main and standard contracts (e.g., CryptoKnight, NFT standards, MetadataViews, ViewResolver)
│ ├── scripts/ # Read-only Cadence scripts
│ ├── transactions/ # State-changing Cadence transactions
│
└── flow.json # Flow project config (like package.json)
You can try out and test Cadence code using the Flow Playground. It allows you to run contracts, transactions, and scripts in a sandbox environment.
-
Install the Flow CLI Follow instructions at Flow CLI Install Guide
-
Clone this repository:
git clone https://github.com/your-username/CryptoKnight.git cd CryptoKnight
-
Start the Flow emulator:
flow emulator
-
Deploy the contracts:
flow project deploy
-
Interact with the contracts:
flow transactions send ./cadence/transactions/setup_account.cdc flow transactions send ./cadence/transactions/mintKnight.cdc "Knight 1" 0 flow scripts execute ./cadence/scripts/checkCollection.cdc flow scripts execute ./cadence/scripts/getKnightIDs.cdc
-
Generate Flow account keys:
flow keys generate
-
Go to the Flow Testnet Faucet and create a new testnet account using your public key.
-
Update the
flow.json
file:- Add the new testnet address and private key under the
accounts
section. - Ensure the
deployments
section includestestnet
.
- Add the new testnet address and private key under the
-
Deploy and interact with contracts:
flow transactions send ./cadence/transactions/setup_account.cdc --network=testnet --signer testnet flow transactions send ./cadence/transactions/mintKnight.cdc --network=testnet --signer testnet "Sean" 1 flow scripts execute ./cadence/scripts/get_totalSupply.cdc --network=testnet
For more details, refer to the Flow CLI deployment guide.
There are two main ways you can use this repository:
Use this repo as a guided example while learning Cadence:
- Explore
/contracts
to study resource-oriented programming - Modify and experiment with
/transactions
and/scripts
to deepen your understanding. - Use the Flow Playground or CLI to test changes.
Use this as a starter template:
- Fork the repo
- Customize the
CryptoKnight.cdc
contract to suit your game mechanics. - Use or extend the React frontend in the
/web
directory to create your own dApp.
CryptoKnight is a Flow Developer Grant project built by DC, a Flow Dev Ambassador and smart contract engineer from India. Our mission is to make Cadence education accessible, engaging, and beginner-friendly — while empowering you to build your own blockchain applications across domains like Games, DeFi, RWAs, NFTs, DAOs, and more.
Let’s bring some fun to smart contract development on Flow! 🧙♂️⚔️