- Brief introduction of the instructor and Allfeat labs.
- Briefly talk about the agenda and learning objectives for the day.
1 - For beginers that were not here last year at the rust bundle
- Introduction to Rust: Its significance and real-world applications. ( live talking session)
- Understanding Rust syntax.
- Setting up the Rust environment.
- Variables, data types, control flow, and functions in Rust.
- Understanding ownership, borrowing, and lifetime.
- Structs and enums.
2 - For people that were here last year at the rust bundle/already know well rust
You can find 5 more exercices inside the rust advanced exercices
folder. There is also a bonus exercice with a little command line interface application to create for those who want to go further :)
- Brief overview of Blockchain technology.
- Understanding Smart Contracts.
Blockchain is a decentralized and distributed digital ledger that records transactions across many computers in such a way that the registered transactions cannot be altered retroactively. This technology aims to increase security and transparency in all business sectors.
Transaction
: Each transaction made is known as a block in the blockchain.Block
: Every time a block is completed, it gives way to the next block in the blockchain.Verification
: The transaction within the block needs to be verified by the majority of the participants in the system.Hash Function
: Each block contains a unique code known as a hash. It also contains the hash of the previous block in the chain.Immutable
: The information recorded in the blocks can never be altered.
A smart contract is a self-executing contract with the terms of the agreement between parties being directly written into lines of code. They automate transactions and remove the need for intermediaries.
Agreement
: Parties involved in a transaction agree to terms and conditions.Coding
: The agreement is coded into a smart contract.Blockchain
: The contract is stored on the blockchain.Execution
: When predetermined conditions are met, the contract executes automatically.Validation
: The blockchain validates the transaction.Record
: The result is recorded onto the blockchain.
The decentralization, security, and transparency of the blockchain combined with the automation of smart contracts create a powerful tech combination. Blockchain provides a trustworthy environment for smart contracts, and smart contracts bring programmable automation and efficiency to blockchain systems. They are particularly powerful in applications like DeFi (Decentralized Finance), supply chain management, voting systems, and any application where trust, transparency, and immutability are key.
- Role of Substrate in the Polkadot ecosystem.
- Introduction to ink!.
Substrate is a modular and extensible blockchain framework that allows developers to build their own blockchains for different applications. It is developed by Parity Technologies and used as the foundational layer for the Polkadot network, but it can also be used standalone.
Key Features of Substrate:
Modular
: Substrate's modularity allows developers to choose what components they need for their blockchain, promoting innovation and variety.Runtime
Upgradeability: Substrate chains can upgrade their runtime without a hard fork, reducing disruption and enabling easy feature additions and bug fixes.Interoperability
: When built with Polkadot, Substrate chains can communicate with each other and external blockchains.
ink! is a Rust-based eDSL (embedded Domain Specific Language) for writing smart contracts on Substrate-based blockchains. ink! allows developers to write secure and efficient smart contracts with all the benefits of the Rust language.
Key Features of ink!:
Integration
: As a Rust-based eDSL, ink! allows you to use the power of Rust’s toolset, including its compiler and type checking.Efficiency
: ink! contracts are compiled to WebAssembly (Wasm), providing great execution speed and efficient use of resources.Security
: With Rust’s strict compiler, ink! contracts provide a high level of security and robustness.
Substrate provides the base layer for creating blockchains, while ink! provides the toolset for writing smart contracts to be deployed on those blockchains. They work together to offer a comprehensive framework for decentralized application (dApp) development.
Here's a simple process:
- Create Blockchain with Substrate: Utilize Substrate's modules (called pallets) to create the specific functionalities your blockchain needs.
- Write Smart Contracts with ink!: Use ink! to write the business logic of your dApp as a smart contract.
- Deploy Contracts: Deploy the ink! smart contracts onto your Substrate-based blockchain.
- Interact with Contracts: Users can interact with the smart contracts, invoking its functions and changing its state.
In summary, Substrate and ink! are both critical elements of the Polkadot ecosystem, providing developers with the flexibility and tools they need to build innovative and unique blockchain solutions.
- Install Ink! eSDL (Embedded Domain Specific Language) and clone the substrate-node-template here
- Install the Substrate SDK here
- Basics of ink! with example of todo list smart contract
- Writing a simple ink! smart contract on live code session
- Deploying and interacting with the contract on a local Substrate node
- Interactive session: Students write, deploy, and interact with their own ink! smart contracts
Write a smart contract to handle the roles of a forum application. The contract should have the following features:
- One user is SuperAdmin role and can set any user to any role ( the SuperAdmin user is set upon contract initialization ).
- Users can be set to Admin role, which lets your add/remove moderators.
- Users can be set to Moderator role, which lets them add/remove posts.
- A method
get_role
that returns the role of the caller. - Use the
AccountId
of ink! framework to differentiate users inside your storage. - Don't mind the posts part, just handle the roles.
- Review of the day's work.
- Discussion on the challenges faced and how they were overcome.
- Open forum for questions and sharing of experiences.
- Introduction to further resources for learning and possible next steps.