Skip to content

This repository is built for learners who want to learn and build a smart contract on a Flow chain, and it has basics to advance sample smart contracts written in cadence.

License

Notifications You must be signed in to change notification settings

DappCoderr/CryptoKnight-Contract

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🛡️ CryptoKnight

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.


🗂️ Project Structure

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)

🚀 Getting Started

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.

🛠️ To Run Locally:

  1. Install the Flow CLI Follow instructions at Flow CLI Install Guide

  2. Clone this repository:

    git clone https://github.com/your-username/CryptoKnight.git
    cd CryptoKnight
  3. Start the Flow emulator:

    flow emulator
  4. Deploy the contracts:

    flow project deploy
  5. 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

🌐 To Use on Testnet:

  1. Generate Flow account keys:

    flow keys generate
  2. Go to the Flow Testnet Faucet and create a new testnet account using your public key.

  3. Update the flow.json file:

    • Add the new testnet address and private key under the accounts section.
    • Ensure the deployments section includes testnet.
  4. 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.

⚙️ How to Use This Repository

There are two main ways you can use this repository:

1. Learn Cadence

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.

2. Build Your Own Game

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.

👤 Created By

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! 🧙‍♂️⚔️

About

This repository is built for learners who want to learn and build a smart contract on a Flow chain, and it has basics to advance sample smart contracts written in cadence.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published