Professional Documents
Culture Documents
"Cryptocurrencies like Bitcoin and Ethereum are powered by a technology called the blockchain. At its most basic, a blockchain is a list of
transactions that anyone can view and verify." - Coinbase
"Blockchain technology is an advanced database mechanism that allows transparent information sharing within a business network. A
blockchain database stores data in blocks that are linked together in a chain. The data is chronologically consistent because you cannot
delete or modify the chain without consensus from the network. As a result, you can use blockchain technology to create an unalterable or
immutable ledger for tracking orders, payments, accounts, and other transactions. The system has built-in mechanisms that prevent
unauthorized transaction entries and create consistency in the shared view of these transactions." - Amazon AWS
Why is Digital money so difficult to achieve?
Double Spend problem
Mitigate the risk of trust
Reconciliation issues
BLockchains Feature Trilemma:
Decentralized, Scalable, Secure
Types of Blockchains
● Public Blockchain networks
Security
● Data accuracy is required.
● Validated transactions are immutable & permanent.
Efficiency
● Near real time reconciliation
● Built in Auditing
● Auto Execution of state rules
Optional Activity:
Substrate:Run your Own Blockchain
run a local blockchain
Digital mitigation of trust
When communicating digitally how do we know who we are
communicating with?
What methods can be used to verify identity and state of something?
How do we secure messaging and communications?
How do you mitigate the risk of trust digitally?
Consensus
Proof-of-Work to start Migrated to Proof of Stake
What’s Gas?
Payment for computation and storage based on opp codes
Smart Contracts: Defined
Digital Contracts stored on Blockchain that can auto execute code
based on conditions
Contracts have all the characteristics of a blockchain
● Decentralized
● Immutable
● Cryptographic Primitives baked in
● Autonomy in the code
● Psudanomy in the users identity
● Transparency in the state and the history of the transactions
DAO’s & Oracles
DAO: Decentralized Autonomous Organizations
https://medium.com/@tom
mycooksey/the-progression-
of-the-web-web1-to-web3-
4f4733c99f2d
Web 2 stack
Application: Facebook, Email, Browser, youtube
TCP/IP SMTP HTTP STREAMING BROWSER
Web 3 stack
SubSocial(DC social network) Acala(Defi) Brave
Substrate Polkadot Consensus, XCM, Bridges
Defining the technology, tools and
how they work
PolkaDot Ecosystem
Polkadot
Polkadot as a protocol has 2 main goals
• Provide shared security among all connected parachains.
• Allow all connected chains to interoperate by using XCM.
• Cross-Consensus Message Format provides:
1. Asynchronous: XCM messages in no way assume that the sender will be blocking
on its completion.
2.Absolute: XCM messages are guaranteed to be delivered and interpreted
accurately, in order and in a timely fashion.
3.Asymmetric: XCM messages out of the box do not have results that let the sender
know that the message was received. Any results must be separately
communicated to the sender with an additional message.
4.Agnostic: XCM makes no assumptions about the nature of the Consensus Systems
between which the messages are being passed.
Polkadot Runtime & Ecosystem Networks
• Mainnet: Polkadot
• Canary network: Kusama
Test Networks:
• Westend:
• Canvas
• Rococo
Kusama: Introduction
Kusama is a scalable network of specialized blockchains built using
Substrate and nearly the same codebase as Polkadot. The network is
an experimental development environment for teams who want to
move fast and innovate on Kusama, or prepare for deployment on
Polkadot.
Overall, each of these networks serves a different purpose within the Polkadot ecosystem.
● Parathreads have a fixed fee for registration that would realistically be much lower than the
cost of acquiring a parachain slot.
● It will be possible for parachain to swap their parachain slot with a parathread so that the
parathread “upgrades” to a full parachain and the parachain becomes a parathread.
a. This allows for parachains to gracefully exit lease agreements and continue as parathreads
that only produce blocks when necessary
● Parathreads help ease the sharp stop of the parachain slot term by allowing parachains that are
still doing something useful to produce blocks, even if it is no longer economically viable to rent
a parachain slot.
● Parathreads are great for applications that do not frequently update state and therefore do not
need to continuously produce blocks.
● Like parachains, parathreads are secured under Polkadot’s shared security and can send and
receive messages over XCMP.
Common Good Parachains
"Common Good" parachains are parachain slots reserved for
functionality that benefits the ecosystem as a whole.
These types of parachain do not expire and can only be removed via
governance.
There are two types of common good parachains: system level chains
and public utility chains.
System Level Chains
System level chains move functionality from the Relay Chain into
parachains, minimizing the administrative use of the Relay Chain.
These chains must stay fully aligned with the Relay Chain, adopt it’s
native token (i.e DOT or KSM) as their native token and take messages
from the Relay Chains and system level; parachains at face value.
Both validators and nominators can stake their tokens on chain and
receive staking rewards at the end of each era.
The staking system pays out rewards equally to all validators regardless
of stake. Thus, having more stake in a validator does not influence the
amount of block rewards it receives.
Slashing
Slashing will happen if a validator misbehaves (e.g. goes offline, attacks
the network, or runs modified software) in the network.
Peter: Votes No with 10 DOT for a 128 week lock period => 10 x 6 = 60 Votes
Logan: Votes Yes with 20 DOT for a 4 week lock period => 20 x 1 = 20 Votes
Kevin: Votes Yes with 15 DOT for a 8 week lock period => 15 x 2 = 30 Votes
Even though combined both Logan and Kevin vote with more DOT than
Peter, the lock period for both of them is less than Peter, leading to their
voting power counting as less.
Council
An on-chain entity comprising several actors, each represented as an
on-chain account.
Key features:
● Decentralized control
● Transparency
● Funding for grants and projects
Decision-Making and Funding
Decisions regarding the use of the on-chain treasury are made through
a combination of on-chain voting and offline deliberation by the
Council.
● Slashing
● Transaction fees
● Staking inefficiency
● Parathreads
Benefits of On-Chain Treasury
● Decentralized control
● Transparency
● Funding for grants and projects
● Long-term sustainability
● Ecosystem development
Transaction fees
• A Weight fee
• Base weight
• Call(s) weight
• A Length fee
• A Tip (optional)
Polkadot has a shared state between the Relay Chain and all of the
connected parachains.
The shared state ensures that the trust assumptions when using
Polkadot parachains are only those of the Relay Chain validator set
and no other.
Cross-Consensus Messaging(XCM)
Cross-consensus communication
Cross-consensus communication relies on a message format- XCM that
is designed to provide a generalized and extensible set of instructions
for completing transactions across boundaries created by different
systems, transaction formats and transport protocols.
Interoperability and parachains
Parachains offer a promising solution for achieving interoperability
between different blockchain networks
By enabling communication and exchange between different
blockchain networks, parachains can help create a more cohesive and
connected ecosystem for decentralized applications and decentralized
finance (DeFi).
Interoperability and parachains
Parachains can achieve interoperability by connecting to the relay
chain, through a process called "parachain bonding".
This allows the parachain to interact with the main chain and access its
security and network resources, while still maintaining its own
independent functionality.
Polkadot Address
● l2uxb9baJaiHhCvMzijnCYbkiXpGQ24jhj4AmhNvrMEzWuoV
● EVH78gP5ATklKjHonVpxM8c1W6rWPKn5cAS14fXn4Ry5NxK
● 2q5qF1LqDpINWGC1JJaCzmPQMGPZPKQ76f2XqzxMBjwmadxW
● 5DyfSpLWSoSpFfur35gn4PmbrupchiWbdEKgcQPaJGDULHGd
● jRaQ6PPzcqNnckcLStwqrTjEvpKnJUP2Jw65Ut36LQQUycd
● 4dFhts6694CTKKV4btQdnzB3yzxrNcjUVaztvJXmX8eYeXox
Derivation Paths
● Derivation paths allow for the creation and management of multiple accounts
using the same seed
● Soft vs. Hard Derivation
○ Hard derivation uses "//" after the mnemonic phrase
■ e.g. "caution juice atom organ advance problem want pledge someone senior holiday very//0"
○ Soft derivation uses "/" after the mnemonic phrase
■ e.g. "caution juice atom organ advance problem want pledge someone senior holiday very/0"
● Password derivation uses "///" after the mnemonic phrase and requires a
password in addition to the mnemonic phrase and derivation path to access
the account
● Things to remember
○ Use well-defined sequences or write down derivation paths for easy recreation
○ Use password derivation for added security
○ Unless there is a specific need for a soft derivation, it is recommended to use hard
derivation for added security
Address Generation Tools in Polkadot
● Toolkit
○ Polkadot JS Apps Suite
○ Polkadot CLI
● Create private-public key pairs to generate unique addresses
● Note: it’s good to use
BUILDING
Substrate
• Substrate is the primary blockchain SDK used by developers to
create the parachains that make up the Polkadot network. It allows
to create specialized blockchains for any use case.
• Flexible
• Open
• Interoperable
Substrate Future-proof:
Substrate is built to be upgradeable,composable and adaptable.
• Some of the most important activities that are handled by outer node are:
- Storage
- Peer-to-peer networking
- Consensus
- Remote procedure calls
• Performing these task often requires the outer node to query the runtime for information or to provide
information to the runtime which is handled by calling specialized runtime APIs
Substrate Runtime
• Runtime is responsible for handling the changes to the blockchain’s
state transition function and everything that happens on-chain. It
determines whether a transaction is valid or invalid
• Runtime controls how transactions are included in blocks and how
blocks are returned to the outer node for communicating with
other nodes
• It is the core component of the node for building Substrate
blockchains
Runtime
The substrate runtime is designed to compile to WebAssembly (wasm )
byte code which enables:
Now what?
● You can get started with a pre-configured node and start a solo chain with no code.
● You can use Substrate to build a custom solo chain that runs independent of any other
blockchains.
● You can couple your Substrate chain to a relay chain like Polkadot or Kusama.
Substrate: Setting up a LOCAL dev
environment
To set up Substrate for blockchain development, you will need to follow these basic steps:
1. Install the latest version of Rust, a programming language that Substrate is built on. You can install Rust by following the instructions on the Rust website
(https://www.rust-lang.org/tools/install).
2. Install Substrate by running:
3. Create a new Substrate project by running the following command: This will create a new directory with the default Substrate node template.
Substrate: Setting up a LOCAL dev
environment
4. We then build the node using cargo from the project directory.
This starts a local dev chain that can be leveraged for testing and
ideation.
Substrate Playground: Online IDE
Provides an online dev environment for quick ideation and skills building
that provides to templates to start with:
● Node template: A “skeleton blockchain” with essential capabilities,
including P2P networking, consensus, finality, account, transaction and
sudo governance modules. Runtime modules:
○ pallet_balances
○ pallet_transaction_payment
○ pallet_sudo
○ pallet_template
● Front End template: A modular UI built with ReactJS to act as a front-
end to the Substrate Node Template. It contains all necessary
components to interact with the Node Template runtime. Components
include:
○ Pallet interactor
○ Events
○ Balances
○ Upgrade runtime
Substrate Playground: Online IDE
Substrate Node Template
Substrate Playground: Online IDE
Substrate Playground:Existing Sessions
Intro to PolkadotJS
Polkadot JS is a collection of tools for interacting with the Polkadot
network
It allows developers to build applications that can read and write to
the Polkadot blockchain
Key Features of Polkadot JS
● Support for multiple blockchain runtime environments (e.g.
Substrate, Ethereum)
● Interoperability with other blockchains on the Polkadot network
● A user-friendly API for building decentralized applications
Apps UI
The Polkadot-JS UI, also known as the Apps UI, is a hosted application
that loads in your browser.
Polkadot-JS Apps has many capabilities that go beyond basic wallet
functions such as account creation and sending or receiving
transactions.
The UI has a standard DNS hosted version, which always has the latest
features, and an IPFS version that is less frequently updated but is
more decentralized.
Extension
The Polkadot-JS extension is a simple tool for managing accounts in a
browser extension and allowing the signing of extrinsics using these
accounts.
The Polkadot-JS extension is not made for users to interact with on-
chain functions as one would find through a wallet app. The
extension acts as a robust key-store and thus acts as an account
manager for Substrate-based accounts. It also allows for the signing
of transactions with those accounts.
Polkadot JS Resources
● Official documentation: https://polkadot.js.org/
● GitHub repository: https://github.com/polkadot-js/api
● Join the community on Discord: https://discord.gg/6FpUKcK
FRAME
Runtime Storage
The FRAME storage data structures can be used to read or write any
value that can be encoded by the SCALE codec. The storage module
provides the following types of storage structures:
- Storage value: to store any single value such as u64
- StorageMap: to store a single key value mapping
- StorageDoubleMap: to store values in a storage map with two keys
- StorageNMap: to store value in a map with any arbitrary number of
keys
Weights
• A convention used in Substrate-based blockchains to measure and
manage the time it takes to validate a block
• The maximum block weight should be equivalent to one-third of the
target block time with an allocation of:
- one third for the block construction
- one third for network propagation
- one third for import and verification
Pallet coupling
In Substrate, tight pallet coupling and loose pallet coupling are used to
describe how a pallet can call functions in another pallet.