https://github.com/dappcoderr/cryptoknight-contract
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.
https://github.com/dappcoderr/cryptoknight-contract
Last synced: 15 days ago
JSON representation
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.
- Host: GitHub
- URL: https://github.com/dappcoderr/cryptoknight-contract
- Owner: DappCoderr
- License: mit
- Created: 2022-08-03T13:41:02.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2025-05-02T08:28:05.000Z (9 months ago)
- Last Synced: 2025-06-16T14:51:14.901Z (8 months ago)
- Language: Cadence
- Homepage: https://crypto-knight-frontend.vercel.app/
- Size: 7.92 MB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# π‘οΈ CryptoKnight
**CryptoKnight** is an educational project designed to help developers learn [Cadence](https://developers.flow.com/cadence) β the resource-oriented smart contract language on the [Flow blockchain](https://www.flow.com/). 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](https://play.flow.com/). 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](https://developers.flow.com/tools/flow-cli/install)
2. **Clone this repository**:
```bash
git clone https://github.com/your-username/CryptoKnight.git
cd CryptoKnight
```
3. **Start the Flow emulator**:
```bash
flow emulator
```
4. **Deploy the contracts**:
```bash
flow project deploy
```
5. **Interact with the contracts**:
```bash
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:
```bash
flow keys generate
```
2. Go to the [Flow Testnet Faucet](https://faucet.flow.com/create-account) 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:
```bash
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](https://developers.flow.com/tools/flow-cli/deployment/deploy-project-contracts).
## βοΈ 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**](https://x.com/dappcoder_), 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! π§ββοΈβοΈ