Python Web3 Development #1 - How to Make DApps With Python

Tech With Tim · Beginner ·💻 AI-Assisted Coding ·2y ago

Key Takeaways

This video series demonstrates building decentralized applications using Python and the Cartesi framework, allowing developers to create Web3 applications without learning Solidity. It covers the basics of decentralized applications, blockchain development, and secure data transmission, as well as the limitations of traditional blockchain development and the benefits of using layer two solutions like Cartesi.

Full Transcript

in this series I'll show you how to write decentralized applications using normal programming languages that you already know like python that means you don't need to learn solidity you don't need to pick up a new language you don't need to be an expert blockchain developer and you can very quickly write decentralized applications that are web 3 that are running on a blockchain network like ethereum and you can use your existing web 2 knowledge to do that so whether you're a python developer JavaScript go C++ doesn't matter this video specifically in this series will be focused on python because I know many of my viewers know python but you can do the exact same thing in really any language so long as it runs on Linux now the way we're able to do this is by using a framework or Library known as cartei now cartei is the sponsor of this video and this series but don't worry they're completely free you don't need to pay for anything they don't even take any money from you and the reason why they sponsored this is they want me to show you how gamechanging this technology is and to try to get some more people into web 3 because they've completely removed the barrier of Entry which is learning solidity and picking up this whole new paradigm which can take a really long time so with that said let me give you a quick demo of exactly what we're going to build in this series then I'll talk more about exactly how this works and what you can expect for the rest of the videos all right so I got a quick demo running on my computer and I want to remind you that to build this I used no solidity on the right hand side of my screen I have a python back end that's right normal python code that you would be able to read and on the left side I have my front end which is written in JavaScript and react now we'll build this exact thing out step by step but I just want to show you how it works and give you a sense of the features we're going to build I know it seems a bit simple because this is going to be a rock paper scissors challenge game but I promise this is a really great introductory project and it will kind of lay the foundation and give you those core skills so you can extend this and make it a lot better A lot cooler and build some other decentralized apps so I'm signed in with metamask and I'm connected to kind of a demo demo hard hat node just running on my Local Host we don't have this deployed out but we'll talk about that later in the series now what we can do here is we can make challenges so you can see that I can click rock paper scissors and I can make a new challenge now I already have one active CU I just made one and it says my move is currently hidden Challenge number zero and we're waiting for someone to challenge us back to play Rock Paper Scissors against so what I'll do is I'll go to metamask I will change my account over here so let's connect to this one refresh and now you can see that we have a challenge this is the opponent the move is hidden and we can challenge them so I could choose maybe scissors and click on challenge okay and I'm going to go ahead and click confirm now notice the important thing is that one player made a challenge they submitted their move but I'm not able to see what their move is until I make my own move now we'll talk more about this in the series but this is a cool kind of feature we're adding here to show you how to securely transmit data in an asynchronous manner to the blockchain such that you can hide it from a third party so you can see that as I do this stuff we're getting some uh what do you call it kind of feedback here in the console or in our back end so just keep that in mind now if I update the challenge we have an active Challenge and both players have moved now that both players have moved what we can do is reveal our move and as soon as both players reveal their move then we will have a winner for the challenge now we're not revealing it until both players have made their original move so no one can cheat in this process so if I click on reveal move we'll go here and we'll send our transaction just give this a second here it should pop up in the console okay so it says adding notice this player has revealed their move of scissors so if we update the challenge now it says our move is scissors we're waiting on our opponent and if we go here and we switch back now to the opponent which is player six and we update the challenge so let's refresh the page here you can see it says the opponent move is scissors your move is is hidden if we want to see who wins then we can go ahead and reveal our move so let's do that give this a second for it to pop up in the terminal here okay so you can see it says this player has revealed their move of rock and if we update the challenges it says we won because we had Rock the opponent had scissors and there you go that is challenge zero then we could go ahead and make a new challenge if we want to so we can make a new one where we choose Rock okay we'll see if that comes in here give this a second okay challenge ID created update challenges we now have a new active Challenge and we can go through this whole process so anyways that was kind of the demo of the application just to give you a little sneak peek here you can see that if I go in this main.py file this is the whole back end that's running this application okay it's about 200 lines long there a few other files as well but this is all written in normal python no solidity code no complex stuff that you don't know only code that you've written before and that you've seen really really cool I can't wait to bring you guys along for this series let's now hop over and talk a little bit about the prerequisites and some more stuff that you need to know before we get started all right so before we go too much further let me just break down a few key terms that you're going to want to know before we go forward so first what is a decentralized application well this is really some kind of application that runs on typically a peer-to-peer blockchain Network think ethereum Bitcoin whatever that is decentralized decentralized means there's no Central Authority or someone controlling it it can't just go offline it can't just be deleted it can't be tampered with because of the security kind of features of a blockchain network so for example a bank right this is the best example we have of a centralized kind of entity if I were storing money with a bank at any point in time if the government doesn't like me if the bank doesn't like me they can freeze my assets they can take my money my account could be deleted there's a central figure or authority or multiple that have control of my account a decentralized application is the complete opposite once your code is hosted once it's live no one can go and tamper with that no one can change it no one can modify it it's there it exists it's trustworthy and that's kind of the major feature of a decentralized app we have trustless communication because of smart contracts and ways that we can interact with each other on these blockchain networks now when it comes to building these decentralized applications there's many different ways to do this and the first way would be to do this just directly on the blockchain network if you've ever ridden a solidity smart contract before for you just deploy that to ethereum and what this means is you're actually using a layer one solution or a layer one technology ethereum Bitcoin any base level blockchain Network that can operate independently of anything else is what's known as layer one now Layer Two is something that's on top of a Bas level blockchain Network it relies on the security features of that network but it aims to improve some of the speed scalability efficiency Etc of that base level Network so some something like ethereum can actually be incredibly slow and it can be incredibly expensive especially if you want to do a lot of operations you want to have a lot of code running you want to even just have a simple decentralized app like the one that we have if you're running that directly on ethereum it could be quite expensive so what we actually aim to do is take some of the transaction load and some of the computations off of the Bas level Network to a secondary Network known as our layer 2 solution right and then what we'll do is we'll utilize the main security features benefits of layer one to keep our application secure we kind of offloading some of the heavy expensive and timec consuming computation to Layer Two this is a gross oversimplification and I have some videos that go into this more in depth that I'll leave on the screen and in the description but when you think of layer one think of your base level Network and when you think of Layer Two think of on top of that Network which aims to make things faster cheaper Etc by kind of offloading some of that heavy computation but still relying on and utilizing the security benefits of layer one now a great example of a layer 2 solution you probably know is something like polygon this sits on top of ethereum and it increases the transactions per second now what we'll be using here is something known as cartei this works quite a bit differently than something like polygon but this is a layer 2 solution sits on top of a blockchain network and it really just takes all of our heavy computations and execution takes it offchain and then does it in a verifiable and provable way and reports all of the results on chain we'll get into the architecture later on but what you need to understand for now is that cartez uses something known as optimistic rollups I have an entire video that breaks down what those are so I'll leave that in the description but what this really means is that we utilize the blockchain for reporting all of our transactions or kind of state changes which we'll get into later we then do all of the heavy computation offchain in a verifiable manner and then we report it back onchain that way at any point in time we we can actually check what's gone on we can see a log of all of the different transactions but they're condensed they're compressed and we're taking all of that heavy work that usually costs a lot of gas and money and we're just taking it offchain so that we can do everything a lot more scalable a lot faster and just a lot more efficiently than if we did it directly on the ethereum main Network which as you know can be congested expensive and slow so this is in contrast if we just wrote a normal smart contract a smart contract is something that is deployed directly to the ethereum main Network and this means that anytime we want to do any work in that smart contract we have to utilize the ethereum chain which means we're paying a ton of gas fees we're paying validators we're paying all this kind of stuff and we're doing quite a bit of work and doing any computations on a blockchain storing any kind of data is very very expensive so that's why we take it offchain we'll talk more about this later don't worry now this all sounds great but there's still a lot of issues with traditional blockchain development which is how people have been doing things kind of up to now so if you want to write a smart contract which is really the code that facilitates kind of trustless interaction on the blockchain it's difficult you got to learn a new language and there's quite a few limitations to what you're actually able to do solidity is a good language but it's very difficult to understand for someone who's new and there's just quite a few limitations for example anytime you want to perform executions or computations on the blockchain you need to submit gas gas is essentially a payment to whatever the node is that's actually doing all of these computations now there is a gas limit this gas limit is not that large and that actually means that if you wanted to do something as simple as 1,000 Loops okay you want to add a number a thousand times you could very easily run out of gas you can actually not have enough gas in one transaction to complete the computation that you want to perform so you think of huge computations that require maybe a few minutes to run it's impossible to do those in one transaction you'd have to batch them into like 20 30 50 10,000 in different transactions which would be extremely costly now as well as that there's a lot of features that just don't exist on the blockchain network itself things like floating Point numbers very very difficult to implement and utilize on the network you want to get the number Pi next to Impossible again to actually have that on a blockchain network you want to use familiar tools you want to use math libraries physics libraries data structures and algorithms good luck building those in solidity and utilizing them on the blockchain network there's quite a few limitations when it comes to the coding side if you've ever worked in solidity you would have seen that before and that's why with a framework like cartei we're going outside of the main Network performing computations offchain and allowing ourselves to use anything that we've used before we can use our math libraries we can use floating Point values we can use regular lists or dictionaries objects classes methods anything that you've used in standard programming before you can go ahead and use it and we can still write code in a verifiable and trustable way where we're utilizing the main security features of the blockchain so that is kind of why traditional web 3 development really hasn't taken off yet because there's so many limitations with it and as soon as you start trying to build anything complex you realize damn this is going to be way way harder than it would have been if I did it in a centralized manner using kind of a normal server normal web app whatever so a lot of people just don't bother building these decentralized apps or if they can build it it takes a very long time and it's very very challenging so I'm really excited about the next kind of phase of web 3 where we have all of these great Frameworks and libraries that are making things easier like cartei and I'm going to show you in this series exactly how we use it and how it works I know it's going to impress you now just as a last few notes Here some basic prerequisites for the rest of the series because the next video we're actually going to get into some setup and code you should have some familiarity with python you should have a little bit knowledge of how blockchain networks actually work if you don't I will leave a link in the description to a series that can teach you everything you need to know if you have any understanding of ethereum's Json RPC API that's going to be helpful if that's a bunch of gibberish to you don't worry you'll still be able to follow along if you have any experience with Docker that's going to be helpful because we will be using Docker but again if you don't I'm still going to walk you through the process step by step now if at any point you're getting stuck you're having issues troubles you're frustrated I will leave some support channels in the description that you can reach out to these are directly with cartei like cte's Discord server where you can go in there and you can get support oneon-one help any issue you have you can ask them they'll help you out to the best of their ability and that's how we're going to make this series really easy for everyone to follow along with anyways I hope you guys are excited I know this video is kind of a lot of theory demos Etc this is a new thing so I just want to make sure I take my time walk you through it step by step in the next video we're going to get into a setup you're going to see exactly how this works how we write this decentralized app with normal coding how we interact with it how we get our environment ready to go and then the next few videos we'll actually be building this D we'll go through the different features and you'll slowly start to get the hang of it so by the time you're at the end of the series you fully understand how this works and you are ready to build daps in really any normal programming language you already [Music] know

Original Description

In this series I will be showing you how to create web3 applications using Python. With the Cartesi framework, this method can be done using ANY coding language. So whether you develop using Python, Javascript, Go, or C++; this video is for you. About Cartesi: Cartesi is an app-specific rollup protocol with a virtual machine that runs Linux distributions, creating a richer and broader design space for DApp developers. Cartesi Rollups offer a modular scaling solution, deployable as L2, L3, or sovereign rollups, while maintaining strong base layer security guarantees. To learn more about Cartesi, visit https://cartesi.io/ Cartesi Discord: https://discord.gg/kusye4BjGk Cartesi Docs: https://docs.cartesi.io/ Blockchain for Beginners (Series): https://www.youtube.com/watch?v=8kEBwJt2YLM&list=PLzMcBGfZo4-msMNfRJT5cLSge23P5bqUx Learn about Rollups: https://www.youtube.com/watch?v=REj6fj7AxbI&list=PLzMcBGfZo4-msMNfRJT5cLSge23P5bqUx&index=6 DevAd Seed Grants ($$$$ for building with Cartesi): https://mugenbuilders.notion.site/DevAd-Seed-Grants-dc0a2420a08c49a983b919aa9246dcbc Main resource hub for builders to get started: https://github.com/Mugen-Builders Setup a call with Cartesi for FREE! https://calendly.com/d/4x2-2hx-scf/1-1-technical-with-mugen ⏳ Timestamps ⏳ 00:00 | Introduction 01:17 | Final Project Demo 05:08 | dApps 06:19 | Layer 1 & Layer 2 09:54 | Layer 1 Limitations 12:40 | Prerequisites & Support Resources 🔖 Tags 🔖 #techwithtim #ethereum #web3 Hashtags - How To Code In Web3 - How To Be A Web3 Developer - Coding In Web3 Without Solidity
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from Tech With Tim · Tech With Tim · 0 of 60

← Previous Next →
1 A* Path Finding Algorithm(Visualization)
A* Path Finding Algorithm(Visualization)
Tech With Tim
2 Python Programming Tutorial #1 - Variables and Data Types
Python Programming Tutorial #1 - Variables and Data Types
Tech With Tim
3 Python Programming Tutorial #2 - Basic Operators and Input
Python Programming Tutorial #2 - Basic Operators and Input
Tech With Tim
4 Python Programming Tutorial #3 - Conditions
Python Programming Tutorial #3 - Conditions
Tech With Tim
5 Python Programming Tutorial #4 - IF/ELIF/ELSE
Python Programming Tutorial #4 - IF/ELIF/ELSE
Tech With Tim
6 Python Programming Tutorial #5 - Chained Conditionals and Nested Statements
Python Programming Tutorial #5 - Chained Conditionals and Nested Statements
Tech With Tim
7 Python Programming Tutorial #6 - For Loops
Python Programming Tutorial #6 - For Loops
Tech With Tim
8 Python Programming Tutorial #7 - While Loops
Python Programming Tutorial #7 - While Loops
Tech With Tim
9 Python Programming Tutorial #8 - Lists and Tuples
Python Programming Tutorial #8 - Lists and Tuples
Tech With Tim
10 Python Programming Tutorial #9 - Iteration by Item (For Loops Continued...)
Python Programming Tutorial #9 - Iteration by Item (For Loops Continued...)
Tech With Tim
11 Python Programming Tutorial #10 - String Methods
Python Programming Tutorial #10 - String Methods
Tech With Tim
12 How to Overclock a NVIDIA GPU
How to Overclock a NVIDIA GPU
Tech With Tim
13 Python Programming Tutorial #11 - Slice Operator
Python Programming Tutorial #11 - Slice Operator
Tech With Tim
14 Python Programming Tutorial #12 - Functions
Python Programming Tutorial #12 - Functions
Tech With Tim
15 Python Programming Tutorial #13 - How to Read a Text File
Python Programming Tutorial #13 - How to Read a Text File
Tech With Tim
16 Python Programming Tutorial #14 - Writing to a Text File
Python Programming Tutorial #14 - Writing to a Text File
Tech With Tim
17 Python Programming Tutorial #15 - Using .count() and .find()
Python Programming Tutorial #15 - Using .count() and .find()
Tech With Tim
18 Python Programming Tutorial #16 - Introduction to Modular Programming
Python Programming Tutorial #16 - Introduction to Modular Programming
Tech With Tim
19 Python Programming Tutorial #17 - Optional Parameters
Python Programming Tutorial #17 - Optional Parameters
Tech With Tim
20 Python Programming Tutorial #18 - Try and Except (Python Error Handling)
Python Programming Tutorial #18 - Try and Except (Python Error Handling)
Tech With Tim
21 Python Programming Tutorial #19 - Global vs Local Variables
Python Programming Tutorial #19 - Global vs Local Variables
Tech With Tim
22 Python Programming Tutorial #20 - Classes and Objects
Python Programming Tutorial #20 - Classes and Objects
Tech With Tim
23 Cool VBS Script to Prank Your Friends!
Cool VBS Script to Prank Your Friends!
Tech With Tim
24 How to Overclock an AMD GPU
How to Overclock an AMD GPU
Tech With Tim
25 Best GPU'S For Mining Ethereum (2018)
Best GPU'S For Mining Ethereum (2018)
Tech With Tim
26 Recursion and Memoization Tutorial Python
Recursion and Memoization Tutorial Python
Tech With Tim
27 Ethereum Mining Rig - Hardware Guide
Ethereum Mining Rig - Hardware Guide
Tech With Tim
28 Pygame Tutorial #1 - Basic Movement and Key Presses
Pygame Tutorial #1 - Basic Movement and Key Presses
Tech With Tim
29 How to Install Pygame (Windows 8/10)
How to Install Pygame (Windows 8/10)
Tech With Tim
30 How to Trade Your Cryptocurrency (Bitcoin, Ethereum etc.) For Cash!
How to Trade Your Cryptocurrency (Bitcoin, Ethereum etc.) For Cash!
Tech With Tim
31 How to Mine Ethereum 2018 - WORKING (Super-Easy)
How to Mine Ethereum 2018 - WORKING (Super-Easy)
Tech With Tim
32 Microphone Comparison - $10 Mic vs $150 Mic (Blue Yeti USB)
Microphone Comparison - $10 Mic vs $150 Mic (Blue Yeti USB)
Tech With Tim
33 Pygame Tutorial #2 - Jumping and Boundaries
Pygame Tutorial #2 - Jumping and Boundaries
Tech With Tim
34 Pygame Tutorial #3 - Character Animation & Sprites
Pygame Tutorial #3 - Character Animation & Sprites
Tech With Tim
35 Pygame Tutorial #4 - Optimization & OOP
Pygame Tutorial #4 - Optimization & OOP
Tech With Tim
36 OBS Studio Tutorial - Best OBS Settings
OBS Studio Tutorial - Best OBS Settings
Tech With Tim
37 Linear Search Algorithm - Python Example and Code
Linear Search Algorithm - Python Example and Code
Tech With Tim
38 Make Any Mic Sound AMAZING! (WITH OBS)
Make Any Mic Sound AMAZING! (WITH OBS)
Tech With Tim
39 Binary Search Algorithm - Python Example & Code
Binary Search Algorithm - Python Example & Code
Tech With Tim
40 Pygame Tutorial #5 - Projectiles
Pygame Tutorial #5 - Projectiles
Tech With Tim
41 Pygame Game - Mini Golf
Pygame Game - Mini Golf
Tech With Tim
42 Pygame Tutorial - Projectile Motion (Part 1)
Pygame Tutorial - Projectile Motion (Part 1)
Tech With Tim
43 Pygame Tutorial - Projectile Motion (Part 2)
Pygame Tutorial - Projectile Motion (Part 2)
Tech With Tim
44 Pygame Tutorial #6 - Enemies
Pygame Tutorial #6 - Enemies
Tech With Tim
45 Pygame Tutorial #7 - Collision and Hit Boxes
Pygame Tutorial #7 - Collision and Hit Boxes
Tech With Tim
46 Pygame Tutorial #8 - Scoring and Health Bars
Pygame Tutorial #8 - Scoring and Health Bars
Tech With Tim
47 Cloud Mining vs. Hardware Mining - 2018
Cloud Mining vs. Hardware Mining - 2018
Tech With Tim
48 How to Install Pygame on Mac OSX (Fast-Simple)
How to Install Pygame on Mac OSX (Fast-Simple)
Tech With Tim
49 Pygame Tutorial #9 - Sound Effects, Music & More Collision
Pygame Tutorial #9 - Sound Effects, Music & More Collision
Tech With Tim
50 Pygame Tutorial #10 - Finishing Touches & Next Steps
Pygame Tutorial #10 - Finishing Touches & Next Steps
Tech With Tim
51 How to Fade Your Screen in Pygame [CODE IN DESCRIPTION]
How to Fade Your Screen in Pygame [CODE IN DESCRIPTION]
Tech With Tim
52 How to Create a Button in Pygame [CODE IN DESCRIPTION]
How to Create a Button in Pygame [CODE IN DESCRIPTION]
Tech With Tim
53 Pygame Side-Scroller Tutorial #1 - Scrolling Background/Character Movement
Pygame Side-Scroller Tutorial #1 - Scrolling Background/Character Movement
Tech With Tim
54 Pygame Side-Scroller Tutorial #2 - Random Object Generation
Pygame Side-Scroller Tutorial #2 - Random Object Generation
Tech With Tim
55 Pygame Side-Scroller Tutorial #3 - Collision
Pygame Side-Scroller Tutorial #3 - Collision
Tech With Tim
56 Pygame Side-Scroller Tutorial #4 - Scoring and End Screen
Pygame Side-Scroller Tutorial #4 - Scoring and End Screen
Tech With Tim
57 How to Create A Message Box in Python - Tkinter
How to Create A Message Box in Python - Tkinter
Tech With Tim
58 Is Ethereum Mining Still Profitable - Is It Worth It (April 2018)
Is Ethereum Mining Still Profitable - Is It Worth It (April 2018)
Tech With Tim
59 How to Run MAC OSX on a WINDOWS PC (Clover Boot-loader)
How to Run MAC OSX on a WINDOWS PC (Clover Boot-loader)
Tech With Tim
60 Programming Problem #1 - Alphabet Soup (Beginner/Novice)
Programming Problem #1 - Alphabet Soup (Beginner/Novice)
Tech With Tim

This video series teaches viewers how to build decentralized applications using Python and the Cartesi framework, covering the basics of Web3 development and blockchain technology. Viewers will learn how to create secure and scalable applications without needing to learn Solidity.

Key Takeaways
  1. Build a rock paper scissors challenge game using Python and JavaScript
  2. Connect to a demo Ethereum node using Metamask
  3. Transmit data securely to the blockchain in an asynchronous manner
  4. Reveal moves and determine a winner after both players have made their moves
  5. Use Cartesi framework to build decentralized application without learning Solidity
💡 The Cartesi framework allows developers to build decentralized applications using familiar tools and libraries, without needing to learn Solidity or complex blockchain development.

Related Reads

Chapters (6)

| Introduction
1:17 | Final Project Demo
5:08 | dApps
6:19 | Layer 1 & Layer 2
9:54 | Layer 1 Limitations
12:40 | Prerequisites & Support Resources
Up next
$2.7M With Claude Ai Dropshipping Full Guide (Just Copy Me)
Austin Rabin
Watch →