Modulo1 Cyfrin Updraft Blockchain Basics
Modulo1 Cyfrin Updraft Blockchain Basics
1. Welcome to Updraft
2. Best Practices
3. Meet the Instructors
4. zkSync Sponsorship
Bitcoin and Blockchain
You might be familiar with Bitcoin, which is one of the first protocols to utilize the
revolutionary blockchain technology. The Bitcoin Whitepaper, authored by the
pseudonymous Satoshi Nakamoto, described how Bitcoin could facilitate peer-to-peer
transactions within a decentralized network using cryptography. This gave rise to
censorship-resistant finance and presented Bitcoin as a superior digital store of value,
often referred to as digital gold. There is a fixed amount of Bitcoin, similar to the scarcity
of gold. You can learn more about this in the Bitcoin Whitepaper.
A few years after Bitcoin's creation, Vitalik Buterin and others founded Ethereum, which
builds upon the blockchain infrastructure, but with additional capabilities. With
Ethereum, you can create decentralized transactions, organizations, and agreements
without a centralized intermediary. This was achieved through the addition of smart
contracts.
Though the concept of smart contracts was originally conceived in 1994 by Nick Szabo,
Ethereum made it a reality.
Smart contracts are a set of instructions executed in a decentralized way without the
need for a centralized or third party intermediary.
Smart Contract functionality is the primary difference between blockchains like Ethereum
and Bitcoin. Technically Bitcoin does have smart contracts but they're intentionally turing
incomplete.
However, smart contracts face a significant limitation – they cannot interact with or
access data from the real world. This is known as the Oracle Problem.
Oracles serve this purpose. They are devices or services that provide data to blockchains
or run external computation. To maintain decentralization, it's necessary to use a
decentralized Oracle network rather than relying on a single source. This combination of
on-chain logic with off-chain data leads to hybrid smart contracts.
Note: Most of this course will assume we're working with an Ethereum or EVM
environment. The skills you learn here will be compatible with the vast majority of
blockchain architectures!
Chainlink
Chainlink is a popular decentralized Oracle network that enables smart contracts to
access external data and computation. Chainlink is also blockchain agnostic - so it's going
to work with any chain out there.
As blockchains grow, they face scaling issues. Layer 2, or L2, solutions have been
developed to address this. L2 solutions involve other blockchains hooking into the main
blockchain, essentially allowing it to scale. There are two primary types of L2 solutions:
Don't worry too much about this now. Once we understand how blockchains work 'under
the hood', we'll go further into Layer 2's then.
Terminology
You're going to hear some terms used in this course (and the community as a whole) a
little interchangeably. Maybe you haven't heard these terms before. I hope this offers a
bit of clarification.
Common Terms:
2. Oracle: Oracles in web3 are intermediaries that provide smart contracts with
external data. They act as bridges between blockchains and the outside world,
allowing smart contracts to execute based on real-world events and data. Example:
A weather oracle provides data for a smart contract that triggers crop insurance
payments based on rainfall data.
5. Smart Contract: In web3, a smart contract is a self-executing contract with the terms
of the agreement directly written into code. They run on blockchains and
automatically execute when predetermined conditions are met, without the need for
intermediaries. Example: A smart contract for an escrow service.
6. Hybrid Smart Contract: Hybrid smart contracts combine on-chain code (running on a
blockchain) with off-chain data and computations provided by oracles. This allows
the contracts to interact with data and systems outside their native blockchain.
Example: A smart contract for insurance that uses real-world data (like weather or
flight delays) provided by oracles.
Web3
Web3 is a term used to describe the new paradigm of the internet powered by blockchain
and smart contracts. Unlike the previous versions of the web, web3 is permissionless and
relies on decentralized networks rather than centralized servers. This ushers in an era of
censorship-resistant and transparent agreements and transactions, often called an
ownership economy.
Web2: The permissioned web, with dynamic content where companies run your
agreements on their servers.
User owned ecosystems where one owns a portion of the protocol they interact with
- instead of solely being the product
Wrap Up
We've taken a high-level view of the blockchain landscape, including its history and the
problems that smart contracts solve.
At this point you might be asking yourself what do these smart contracts really mean? or
what is meant by trust minimized agreements/unbreakable promises?
In my mind a technology is really only as good as the problem it solves. So next, we're
going to look at what the purpose of smart contracts is - what's the value proposition
exactly?
Let's take a closer look at the undeniable value of smart contracts in the next lesson.
5. What is a Blockchain?
1. Welcome to Updraft
Quick tip, we will be constantly using resources from the GitHub Repo
Hello and welcome! If you're interested in the world of Web3 development, then you're in
the right place. This is the most cutting edge and comprehensive course ever created.
With the massive demand for Solidity and Smart Contract developers, this course is a golden
opportunity to launch, advance, or switch to a career in Web3. As you navigate the course,
you will learn how to work with AI tools so that you can fast-track your learning journey and
become a proficient 10x developer.
Don't worry if you've never coded before, let me assure you that this course is designed for
learners at all levels. If you're an experienced Smart Contract engineer or familiar with
blockchain development, you're welcome to skip around and cherry-pick modules that
interest you. But most importantly, this course aims to turn you into a pioneering force
within Web3.
Who Am I?
My name is Patrick Collins, a seasoned Smart Contract engineer, security researcher, and
dedicated advocate for Web3. I co-founded Cyfrin, a Smart Contract Security firm, I'm an
average Web3 YouTuber and the co-creator of Cyfrin Updraft.
But beyond that, I love taking passionate smart contract developers, like you, into the
journey of Web3.
What to Expect
This is not your run-of-the-mill course. Instead, it's a culmination of all the knowledge we've
accumulated after years of working in this industry as a Smart Contract developers and
security researchers. Our track record guarantees you'll exit the other side, armed with the
knowledge necessary to make a significant impact in the cryptocurrency and blockchain
industry.
Beyond just teaching you to code, this course prepares you to maneuver DeFi, NFTs, DAOs,
Tokens, Upgradeable Smart Contracts and more. By the end, you'll have a clear path forward
and a wealth of economic opportunities at your disposal – all you need is the willingness to
take the steps.
Best Practices
Let's start by covering some of the best practices to help you get the absolute most out of
this course.
Use the GitHub repo as your Bible! it will have all the resources you'll need to succeed.
Contained within, you'll find a discussions tab. Any questions you have or hurdles you face
can be posted here!
Ask meaningful questions and interact with like-minded learners – this is just as important
as grasping the actual technologies.
Code along with me - As we progress through the course, it's a good idea to code along with
me. Actually doing the work and performing the actions is how you'll build familiarity with
these processes and how they'll really stick.
Watch for Updates - This space moves very quickly - as things are updated, I do my best to
catalogue them. In each video, at the bottom, there will be an "updates" section if there is
some information that differs from the video.
Move at your Pace - Adjust the pace of the course to meet your needs. The course is modular,
so if you want to skip to particular areas - absolutely do that.
Reflect on your Learnings - repetition is the mother of skill. The more you repeat these
development practices, the more they'll stick.
Complete the Optional Challenges - The GitHub Repo has links to fun challenges at the end of
each lesson - these are meant to test your skills and reward you with a fun way to show of
your progress as a smart contract developer!
With the above understanding in place, get ready. We're above to embark on a journey of
knowledge and opportunity.
Our first step will be understanding how the blockchain even works, what smart contracts
even are.
2. Best Practices
Introduction
Welcome to the Cyfrin Updraft. This platform offers a comprehensive learning experience by
combining video lessons, written content, and interactive discussions.
Resources
In the top right corner of the lesson view, you'll find a link to the GitHub resources 📂 page.
This guide contains all the code, information, and materials necessary for the course. On
GitHub, the discussions tab 💬 allows you to interact with fellow learners and the community,
where you can ask questions, share insights, and solve problems collaboratively.
Next to the video lesson, there is a written lesson tab 📝. This tab provides the course content
in text format, which is useful for reading along, copy-pasting code snippets or reviewing
updates.
If you're watching on YouTube, links to these resources are available in the video description.
However, watching this course on Cyphrin Updraft offers additional benefits like tracking
your progress and accessing written lessons, which will enhance your learning experience.
1. 🌐 Engage with the Community by using GitHub discussions and Discord for real-time
communication. Remember that asking questions and interacting with others can
greatly enhance your understanding and retention of the material.
2. Take Regular Breaks: Avoid cramming all the information in one go because your
brain needs time to process and absorb the knowledge.
3. ⏩ Adjust the Video Playback Speed: Use the speed controls in the video player to
match the pace of the lesson with your learning speed.
4. 📝 Use Subtitles if Needed: If English isn't your first language, take advantage of the
subtitle options available in the video settings.
5. 🔄 Follow a Modular Approach: The course is designed to be flexible. You can jump
between topics based on your interests and needs. Revisit lessons to reinforce your
knowledge and ensure thorough understanding.
6. 🎯 Utilize Quizzes and Coding Challenges: Cyfrin Updraft offers both quizzes and
coding challenges. You'll find quizzes at the end of each section and coding
challenges at the end of each GitHub repository section. These will let you earn NFTs
as badges of honor for your achievements.
Conclusion
By following these guidelines, you'll be well-equipped to make the most out of this course.
Engaging with the community, pacing your learning, and utilizing Cyfrin Updraft resources
will significantly enhance your learning experience.
In this lesson, we're going to break down blockchains, the process and the technology itself
using a widely-praised and accessible demo available here.
At its simplest, a hash is a unique, fixed-length string that serves to identify any piece of data.
When you input any kind of data into a hash function, it produces a hash. In this demo, the
hash algorithm we'll focus on is SHA-256.
If I add Patrick Collins to our SHA-256 algorithm, it will:
Ethereum, uses its own version of a hashing algorithm (Keccak256) that isn't exactly SHA-256
but belongs to the SHA family. This doesn't change things significantly here as we're primarily
concentrating on the concept of hashing.
In the application, whatever data you enter into the data section, undergoes processing by the
SHA-256 hash algorithm resulting in a unique hash.
For example, when I input my name as "Patrick Collins," the resulting hash uniquely represents
"Patrick Collins." The fascinating aspect is, no matter how much data is input, the length of the
generated hash string remains constant.
Understanding Blocks
Now that we've grasped the concept of hashing and fixed-length string, let's inspect the
structure of a blockchain. A collection of "blocks."
A block takes the same data input, but instead of a singular data field, a block is divided into
'block', 'nonce', and 'data.' All three are then run through the hash algorithm, producing the
hash for that block. As a result, even a minor change in the data leads to an entirely different
hash, hence, invalidating the block.
In essence, mining involves the computational trial and error process of finding an acceptable
value to produce a hash which typically follows a certain pattern, such as starting with four
zeros. The value found, which satisfies this criterion, is known as the 'nonce'.
The problem or criteria a miner has to solve will vary from blockchain to blockchain, but the
concept is the same.
What this means in practice is that any changes to data, in any block of the chain, will
invalidate every proceeding block, until they are recalculated, or re-mined.
Genesis Block: This is the first block in a blockchain.
Decentralized Distribution
Now, if a single entity were to control the blockchain, they could conceivably change any data
they want, and then re-mine, or re-validate subsequent blocks. This is bad.
The crux of blockchain's power lies in its decentralization or distributed nature. Under this
system, multiple entities or "peers" run the blockchain technology, each holding equal weight
and power. In the event of disparity between the blockchains run by different peers (due to
tampering or otherwise), the majority hash wins, as the majority of the network agrees on it.
Nodes that don't agree with the majority effectively fork the network, continuing on their own
with their own history.
Until now we've been considering the data passed in a block to be a random string of text, but
the reality is - this data can be anything. In the token and coinbase sections of this demo you
can see how each block is comprised of a number of transactions that all get hashed together.
Any edits to any of these transactions is going to invalidate the chain!
Wrap Up
To summarize, every transaction, block, and indeed the whole blockchain itself comes down to
understanding the concept of a hash. This unique fixed-length string that is intrinsically linked
with the original data. We've also underscored the importance of decentralization and
highlighted how the concept of immutability plays into the system's security.
In our next lesson we'll look more closely at private keys, wallets and signing transactions!