Polkadot-SDK

Our starting template for this tutorial uses the Polkadot SDK.

This is the same technology stack used to build and power the Polkadot Network.

To better understand what you will be doing in this tutorial, we need to start with a high level overview of blockchains.

Blockchain

Blockchains are the foundation of building Web3 technologies.

Web3 is a promise toward a world with less trust, and more truth.

Through blockchain technology, we are able to develop and deploy software that are decentralized, open, permissionless, censorship resistant, and independently verifiable.

The main purpose of a blockchain node is to come to consensus with other nodes on the decentralized network.

Deep Dive

If you want to learn more about blockchains, check out the following video from the Polkadot Blockchain Academy:

Runtime

At the heart of a blockchain is a state transition function (STF).

This is the logic of the blockchain, and defines all the ways a blockchain is allowed to manipulate the blockchain state.

In the polkadot-sdk we refer to this logic as the blockchain's runtime.

All nodes on a blockchain network have and use the same runtime, allowing them to come to consensus about changes to a blockchain.

Deep Dive

To learn more about the runtime, and its role inside of the polkadot-sdk, check out this video from the Polkadot Blockchain Academy:

FRAME

The polkadot-sdk provides a developer framework called FRAME.

FRAME is an opinionated framework on how one should quickly and easily build and maintain a blockchain's runtime.

NOTE: It is important to clarify that FRAME is not the only way you can develop a runtime for the polkadot-sdk, but it is the one that the Polkadot Network uses and is most supported by the ecosystem.

You can see in our project, nearly all of our dependencies come from a single crate named frame.

This crate is really just a convenience wrapper around other smaller crates, all exposed through frame::deps.

For our tutorial, most of the types and traits we need access to are automatically brought into scope through frame::prelude::*, however once in a while, we will need to import something more specific from frame::primitives or frame::traits.

Pallets

FRAME's key decision is to break apart the blockchain runtime into separate logical pieces that can choose to interact with one another.

These logical pieces are called Pallets.

TODO: Add images.

You can think of different Pallets as different applications or functions that your blockchain exposes.

You can also think of Pallets very similar to traditional blockchain smart contracts, however Pallets are more powerful and execute much faster than smart contracts.

Deep Dive

To learn more about FRAME and Pallets, check out this video from the Polkadot Blockchain Academy:

NFTs

Non-Fungible Tokens (NFTs) are a type of token which can be created and traded on a blockchain.

As their name indicated, each NFT is totally unique, and therefore non-fungible with one another.

NFTs can be used for many things, for example:

  • Representing real world assets
    • Ownership Rights
    • Access Rights
  • Digital assets
    • Music
    • Images
    • Skins
    • Characters
  • and much more...
#![allow(unused)]
#![cfg_attr(not(feature = "std"), no_std)]

fn main() {
mod impls;
mod tests;

/* 🚧 TODO 🚧: Learn about the Polkadot SDK and FRAME. */
use frame::prelude::*;
pub use pallet::*;

#[frame::pallet(dev_mode)]
pub mod pallet {
	use super::*;

	#[pallet::pallet]
	pub struct Pallet<T>(core::marker::PhantomData<T>);

	#[pallet::config]
	pub trait Config: frame_system::Config {
		type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
	}

	#[pallet::event]
	#[pallet::generate_deposit(pub(super) fn deposit_event)]
	pub enum Event<T: Config> {
		Created { owner: T::AccountId },
	}

	#[pallet::error]
	pub enum Error<T> {}

	#[pallet::call]
	impl<T: Config> Pallet<T> {
		pub fn create_kitty(origin: OriginFor<T>) -> DispatchResult {
			let who = ensure_signed(origin)?;
			Self::mint(who)?;
			Ok(())
		}
	}
}
}
diff --git a/src/lib.rs b/src/lib.rs
index ae8a09b..df435c8 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -3,6 +3,7 @@
 mod impls;
 mod tests;
 
+/* 🚧 TODO 🚧: Learn about the Polkadot SDK and FRAME. */
 use frame::prelude::*;
 pub use pallet::*;