Tezos Blockchain Developer Course – Python Web3 Development
Key Takeaways
This comprehensive Tezos blockchain development course covers the ecosystem, smart contracts, and applications, with a focus on Python Web3 development and Tezos blockchain technology.
Full Transcript
if you're interested in blockchain development this in-depth course will teach you about the tasos ecosystem and how to develop distributed applications for it the only prerequisite for it is a little python knowledge this course was made possible through a grant from the tasos foundation back in 2022 in this module we will do a quick overview of the different applications the blockchain like tesos already makes possible the first type of application is to help the building of communities around brands or teams and to make it possible to own an internal and unique piece of History nfts make it possible for fans or customers to own and collect a token specific to their favorite team or to their favorite brand then marketplaces exchanges or Dows make it possible to build communities around them and help give fans a sense of belonging tesos is used for this in all kinds of fields for example fashion soccer Formula 1 Esports or even Spring Water another application of tesos is in the field of games where it can be used to add new features that help extend the life of games and provide a better experience for gamers it can be used to eternally preserve a player's achievements it can also be used to create multi-game challenges and it also lets users collect and trade in game assets tesos is also used a lot in the field of art it helps give artists A much wider and International audience and it brings new ways for artists to make a living thanks to direct sales or royalties it also enables the production and sale of new forms of art such as generative art a very strong field for blockchains is decentralized finance that brings new Financial products and make them available to anyone some examples on tesos include projects like lug a stable coin ped to the Euro or real estate tokenization projects that make it easy to own a piece of a property and decentralized lending markets that make it easy to borrow different types of tokens tesos can also help people develop initiatives around causes for example around protecting the environment it can be used to raise funds for nature preservation and to build communities around nature awareness these are only a few examples of what's possible with tasos and it is only the beginning by following this course and learning to develop your own smart contracts you will be able to invent your own applications in one of these fields or in other fields in this short module we'll do a quick overview of what you will learn during this course we'll start by showing you the different key components of a blockchain and it's ecosystem so we'll talk about accounts about wallets about blogs Etc so that you can understand all of these different elements and their names then you will practice by creating an account and performing a fut transactions calling smart contracts Etc in The Next Step we'll have a video that shows you all the different steps that a transaction takes from the moment you decide for example to purchase an nft to the moment that this transaction is final on the blockchain so that will help you understand what really happens internally and how things work in the blockchain then we'll focus on the heart of this course which is for you to learn to develop your own smart contracts using the smart P language one of the several languages that are available to write smart contracts on tesos while you learn to write your smart contracts you will also learn how to develop your own test scenarios for your smart contract to make sure that everything works and to avoid the main bugs you will practice all this on a variety of concrete exercises an example this will be a very practice oriented training and we ask you to play along and really try to solve each exercise because we really believe that this is by practicing that you really learn the best so you will learn smart contract Concepts from the very basic types like basic numbers and strings all the way to very Advanced smart contract Concepts such as inter contract calls or upgradable contracts and you'll realize that smart contracts are usually small projects so it's not very hard to write smart contracts but the hard part is to avoid flaws so to help you with that we will spend quite a bit of time teaching you how to detect protect flaws how to avoid them and how to fix them because a flaw in a smart contract can mean potentially losing Millions you will be creating smart contracts in all kinds of areas you will create nft smart contract marketplaces auctions yield farming smart contracts you will learn to build oracles decentralized autonomous organizations or will play with Randomness through a lottery smart contract then you will work on decentralized finance contracts so will talk about how flash loans work how fungible tokens can be created and how to exchange currencies using liquidity pools and take advantage of Arbitrage opportunities Etc so this will give you a good idea of what real smart contracts look like and put you on a path to write your own there are very few prerequisites for this course and what you really need is some basic experience with programming we don't expect you to be a very good developer but you do need some programming experience to be able to follow this course what you don't need is specific knowledge about python it may be helpful if you already know python because smart py is based on python but you'll be okay if you're not familiar with python and you also don't need prior blockchain experience we'll teach you the basics that you will need for this course in this module will give an overview of tesos and its different components and get an idea of what a blockchain is tesos is a public open-source blockchain protocol this means anybody can read the code of all the elements of the blockchain and anybody can access the data of the blockchain and even join the blockchain by setting up their own node we also say that tesos is a smart contracts platform this means it's a kind of blockchain where you can deploy and execute smart contracts when one of the key aspects of tesos is that it relies on an energy efficient proof of stake consensus algorithm that makes it very environmentally friendly compared to some other blockchains tesos has a self amending governance that makes it easy for the protocol to evolve without the need for hard Forks Community itself decides through rules defined by the protocol on evolutions of the protocols that we call amendments tesos has been designed to facilate code safety through a number of design choices and application of formal verification to the protocol so let's talk quickly about the history of tizzel when creating tizzel the creators wanted to address the weakness of the first blockchains there was a weakness in the governance the way that blockchain could evolve and how the community to decide and how to evolve the protocol it appears that the first blockchains didn't evolve as much as they could because they liked a governance mechanism another weakness was the high energy consumption of blockchains due to the use of proof of work as a consensus algorithm finally there were a number of security issues with existing blockchains that the creators of tesos wanted to address the first step in the creation of tesos was the publication of a white paper in 2014 that described its principles from 2014 to 2017 a prototype of the tsos protocol was developed then in July 2017 232 million USD were raised in Bitcoins and E to help develop the ecosystem and the tesos main net was launched in July 2018 after it's launched between 2018 and so far 20123 the tesos protocol was upgraded 14 times through the on chain governance system so when we talk about tesos we're talking about the tesos blockchain or the tesos network if we talk about the underlying cryptocurrency we will talk about the tees and when you talk about mounts you talk about how many Tes you have or for example Alice transfers tentes to Bob the ticker used when you want to check the conversion rates between different cryptocurrencies on exchanges is xtz and T has a logo that you can see here now we will describe the different key elements of tesos we'll talk about accounts transactions smart contracts the blockchain itself and its blocks we'll also talk about wallets nodes and Bakers tesos is based on a system of accounts where every account has its own balance in t but there are two types of accounts on tesos implicit accounts are the accounts directly held by users they have addresses that start with TZ then a digit typically tz1 but also tz2 or tz3 are possible then we have originated accounts those are smart contracts that are a special kind of account that also holds data and code originated account addresses start with KT usually kt1 we'll talk a lot about transactions a transaction is a transfer of TZ from one account to another or it can be a call to a Smart contract and it can be both you can call a smart contract while transferring TZ to the account of that smart contract and transactions are digitally signed by the caller to authenticate that they are the ones really wanting to do that transaction but transactions are one of many types of operations that can be applied on the blockchain we can have other types of operations such as creating accounts deploying smart contracts voting for an amendment to the protocol Etc smart contracts are a special type of account that like every account has a balance of TZ and an address but it also has some data that we call the storage of this smart contract and it has some executable code so a piece of code in the melon language that is executed whenever someone calls the smart contract so when you call a smart contract you may send some test to the smart contract and pass parameters for the code and the code will be executed and it may change the data the storage of the smart contract or generate new transactions and new operations that will be executed after the end of the execution once you deploy a smart contract its code is immutable you cannot change it anymore so that people who call the smart contract can know for sure what code will be executed we can take a small example of a smart contract let's imagine that we have a contract that tracks the ownership of tickets for a conert each ticket will have an owner and the owner of a ticket can transfer it to someone else or change the ownership of a ticket so in the storage we will store all of the different tickets and for each ticket we could have a row a seat number and the address of the current owner and then in the code of the smart contract you could have a entry point a function that can update the owner of a given ticket so you indicate the row the seat and what new owner you want then we will fetch the corresponding data from the storage verify that the caller is actually the current owner of the ticket and then replace this owner with a new owner the tesos blockchain stores its data in a chain of blocks of data so that's why you call it a blockchain and the blockchain is is maintained by a decentralized network of nodes every 15 seconds at the moment at least a new block is added to the chain and each block will contain a sequence of operations and since we have a sequence of blocks the blockchain a blockchain is basically a very long sequence of operations split into blocks that are generated every 15 seconds and the state of the blockchain is the result of the execution of all the operations for example let's say that after the block number 1427 Bob's account has a balance of a th000 t if in Block 1428 Alice adds the transaction Alice transfers 100 T to Bob and this transaction is validated then in the state of the tizel blockchain after block 1428 Bob's balance will be 1100 T in the blog we have two parts we have the header that that contains the block number or the level basically how many blocks we have since the beginning of the blockchain then we have the hash of the previous block a timestamp and we also have the hash of all of the data in the block and the data consists in the list of all the operations of the Block in a certain order the fact that we store the hash of the previous block means that we are creating a chain of block each block references the previous Block in the chain that's why we call it the blockchain and you can check what a block looks like at this address that uses a block Explorer to analyze the block that has this number this level so here we can see this block we can even move to the next block or the previous block we can see the Tim stamp Etc and most of all we can see all the operations in that block so different transactions and in particular smart contract calls to interact with the blockchain we will use a wallet it's a piece of software or Hardware device that keeps your private Keys safe we saw earlier that transactions need to be signed so to sign your transaction you will need your private key that you will sign using your wallet so whenever you want to transfer some TZ or call a smart contract you will need to create a transaction and then sign it with your wallet the wallet doesn't store your TZ or any other asset it only stores the key keys to control these assets if you ever lose your private Keys you basically lose all access to your assets so make sure you keep your private Keys really safe as an example if we have this transaction transfer 100 test from Alice to Bob this transaction has to be signed by Alice using her wallet for it to be valid on tsos we have a number of wallets that you can use for example Temple kukai Umami and more under the hood the tesos network consists of hundreds of nodes run by the community each node is a computer that runs the tesos protocol and communicates with other nodes together these nodes form a peer-to-peer decentralized Network that we call the gossip Network these nodes share the responsibility of maintaining the blockchain and all the operations and blocks are propagated through this network of nodes and when your wallet interacts with a blockchain in practice is communicates with one of the nodes in this network all of the nodes execute every single transaction in every block and store the associated mate data update the state but only one entity can create the next block and decide which operations to include but as we want to keep tesos decentralized the responsibility of creating the next block has to be shared so the hard part of the design of a blockchain is to decide who gets to create this next block and do it in a fair way and then making sure that this block is valid and legitimate on tesos the entities that create new blocks are called Bakers anyone as long as they have at least 6,000 T at the moment can volunteer to be a baker and the baker for each block is randomly selected to make it fair the chance to be selected is proportional to the amount they staged that's what we call proof of stake and proof of stake is eco-friendly because we just need to pick randomly proportionally to some value this cost a lot less energy than proof of work where you need to do a lot of computations to determine who the next minor will be for example as it's done on Bitcoin in proof of work the chance of selection is actually proportional to how much energy and computational resources you waste when a new block is proposed by a baker it has to be validated so we have to check that it includes the correct hashes of the pre block and its own that all operations have a valid signature that the execution of transactions don't fail due to some limits or errors that the maximum size of a block is not exceeded Etc a block is officially added to the chain once it receives enough attestations from other Bakers the baker of a block is rewarded they receive 10 new T and and sometimes a bonus they also receive the fees of all the transactions in the block each transaction comes with some fees that the user can change a kind of a tip that is transferred to the Baker and to maximize their gains Bakers select among all of the transactions the most profitable ones so the ones that have the highest fees compared to their execution time if you're not a baker you can delegate your test to a baker and get a share of the rewards that the baker gets and there's also some test that I use as rewards for the bakers that attest the validity of the blocks if a baker propagates fake data in particular if a baker creates two blocks instead of one when it's their turn they lose some of their stake we say that their stake is slashed but if you delicated your test to a baker you have no risk of being slashed you cannot be punished so this was a key overview of the different elements of tzel we talked about accounts that can be either user accounts or smart contract accounts we described what transactions are our transfer of Tes or calls to Smart contracts we described what a smart contract is a special type of account with not only a balance but also storage and some code that can be executed we describe the blockchain as a sequence of operations grouped in into blocks we talked about interacting with the blockchain through a wallet that keeps your private Keys safe and is used to sign all the transactions you want to send to the blockchain we describe the blockchain itself as a peer-to-peer network of nodes that each execute the tesos protocol and execute every single transaction in the blocks they receive and finally we talked about bakers that share the responsibility of creating new blocks in this video you will learn how to set up your own Wallet create your private keys and then with that you will then be able to get some test create and sign transactions call Smart contracts Etc so using a wallet means creating an account and the first step to create an account is to generate a pair of keys most importantly you will generate your private key that is what you will use to digitally signed all of your transactions and prove your identity a private key has a corresponding public key that you make available to everyone so that they can verify your signatures and verify your identity so you sign your transactions with your private key and other people or software can verify that the transactions are signed by you by matching the signature with your public key so a wallet can generate a private key as a random sequence of bytes if it's extremely important that you never lose your private key but as a sequence of bites is hard to write down or remember the wallet will first generate a seed phrase It's a sequence of random English words that represent a random value but that are easy for you to write down and keep safely for example on a piece of paper then the wallet uses this sequence as a seed for the random generator to produce the private key it then stores this private key local encrypt it using a password of your choice and will'll then use it to sign your transactions on tles there are a number of different wallets available some of the main ones include Kai Umami temple in this presentation we'll be using the kai wallet it is available on kai. apppp but for our test we'll be using the ghostnet test Network so we will be using ghost net. kai. so the Tes will will manipulate with this wallet will be fake TZ in a sense not TZ from the main Network so if you go to ghost net. ci. apppp this is what you will see as the wallet will be directly in your browser you have two ways to create a wallet you can collect with one of several social networks for example Google Facebook Reddit Etc in which case it will use your o o cred credentials as a way to safeguard your keys that's the easiest way to do it if you simply connect for example click continue with Google your wallet will be instantly created and available we will use a way that is slightly longer you click on create new wallet here and then it will generate this seat phrase composed of a sequence of English word and the idea here is that you should write down these words on a piece of paper to keep them safe I avoid storing them in a file because this file could be accessed if anyone ever gets access to your computer so it's safer to Simply use a piece of paper and keep that piece of paper safe and make maybe copies of it that you keep safely because if you ever lose them then you're at risk of completely losing access to your private key therefore to your assets once you have written down these words you can click next and then it will check did you indeed save these words and it will tell you okay did you write down the second work the one that was between traffic and sustain and so on our piece of paper we see yes indeed we had the word Arrow then it asks what's the third word one that was between arrow and midnight and so that was sustain Etc then we have pause and we're done so it checked that we really did store or passphrase then it asks you to provide a password so that they can store an encrypted version of your key store file so that's a password that you remember so that your wallet can locally save your private key and public keyan Etc and then decrypt it anytime you provide your password so whenever you will need to sign a transaction it will use your password to decrypt the key and then sign the transaction with the key so you input a password confirm your password and then click next then your wallet is ready and you have here your public account address so that starts with tz1 and then something's based on the hash of your public key you can also download the encrypted key store file so that you can import it into this wallet or another wallet and it will be as safe as the password you pick to encrypt it so here you copy your public account address we download our file and then we can now open our wallet in the wallet we can see the balance of our account we can see our address here and of course we have no activity because we just created the account for real wallet on the main net you could get TZ using one of several providers and for example convert from dollars or euros and buy some Tes and then have them into your account through coinbase or other places for a test account on ghostnet there's an easier way to get some test you go to this website that we call a faucet and from this website you will be able to request some test so let's give it a try so this is a tesos costet foret that is a website that can give free fake Tes on a ghostnet account you can paste your address here and then select how many Tes you would like let's say A th000 tes and then you can request you need to wait a bit the more test you request the longer the competition will be because the challenge needs to be solved some proof of work and if you request a th000 t it can take a while so we'll maybe request a bit less let's say we only need 200 T and after a couple minutes all the proof of cor challenges are solved and then 200 T are transferred to our account another way would have been to connect our wallet to automatically obtain the tz1 address but that would be the same result then we can check on the Block explorer that indeed our tz1 address has 200 T we can also go back to our wallet and we can see here that the 200 Tes are there after reling the page and we can see that we received them from this address it may take a little bit of time before we see it because we need a couple blocks to be validated but eventually we see the 200 test there from this you can already sign some transactions for example if you want to try to send a few test back to the facet we can take this address that's the address that sent us some test and you can send some Tes let's say two Tes to the address which just copied then we can preview the transaction we can see that there's a fee of 369 micr Tes and we can use our password to decrit our private key and sign a transaction and send it to the blockchain so we confirm and we can now see this transaction has been confirmed and we now have almost 198 T again you can see the same thing in the block chain Explorer and we see this transaction where we send two Tes to this address and that's said your wallet is set up in this module I will give you an overview of the tesos layer one architecture and we will do that by following the path of a transaction from the moment it is created to the moment it is integrated forever in the tesos blockchain imagine you want to buy an nft a unique digital artwork on tesos The Cutting Edge blockchain platform you use adap a decentralized application that lets you browse and bid for nfts when you find the one you love you click on the buy button but what happens next how does your transaction get processed and recorded on the blockchain let's take a look behind the scenes tesos is powered by a network of nodes computers that run the tesos software and communicate with each other through a peer-to-peer Network these modes are operated by the tesos community a diverse and Global Group of enthusiasts developers and organizations your transaction will travel through this network undergo various checks and validations and eventually be included in a block by a baker a special node that creates new blocks once your block is added to the tsos blockchain your transaction is final and irreversible but how does this work exactly the T you use an nft Marketplace has a user interface a web page that you can access from your browser it lets you interact with the blockchain and the smart contract the programs that run on blockchain and Define the rules and logic of the nft marketplace when you click on the buy button the DB creates a transaction a message that tells the smart contract to transfer the nft to you and the TZ the native cryptocurrency of tezos to the seller the transaction is sent to your wallet a piece of software or a Hardware device that connects to your browser and the blockchain your wallet securely stores your private Keys the secret codes that prove your identity and ownership of your T and nfts your wallet is your gateway to the blockchain and the protector of your assets before asking you to confirm the transaction the wallet needs to test it check that it's valid and figure out how much it will cost you to do that it sends the transaction to one of the nodes of the network and asks this node to simulate what would happen if you sent it for real this node has a copy of the blockchain the history of all the transactions that have ever happened on tesos it also has the context the current state of the blockchain which includes the balance of every account and the code and data of every smart contract the node simulates your transaction by running the code of the corresponding smart contract it checks that the code doesn't cause errors for example that the nft you want to buy is indeed for sale at the price you indicate and that you have enough Tes on your account to pay for it it then computes the amount of resources running this code will consume on one side the amount of gas an estimation of how much Computing time your transaction requires on the other side the amount of storage how much extra data will need to be stored the node computes the cost for this gas and storage adds some fees then calculates how much you will need to spend to get a baker to add your transaction to a block all the this information like a quote for your order is sent back to the wallet the wallet then displays that information for you to check and lets you decide how much extra fee you want to add this extra fee is like a tip you pay to the baker to increase the chances that a baker will pick your transaction and add it to the blockchain once you check everything and agree to sign the transaction the wallet uses your secret private key to digitally sign your transaction using cryptography then sends it to a node from then on all you can do is wait and see if your transaction gets added to the chain the node sends a hash of the operation back to the wallet so that the wallet can keep track of it and ask for updates on its status before sharing your transaction with the whole network the node needs to check that it's legitimate to protect against attx that would saturate the network it checks that the signature is valid that the fees are not too low and that you have enough Tes on your account to pay for everything the node then stores your transaction in its M Pool a memory space that stores all the transactions that are waiting to get included in a block the mol also stores other types of operations that the nodes has received such as block attestations or votes for amendments to the protocol the Noe also sends your transaction to its neighbors which in turn check that your transaction is legitimate add it to their own M Pools and send it to their neighbors propagating it through the whole network every node needs to do these checks itself to make sure some bad nodes don't propagate malicious transactions while all this takes place one lucky Baker is getting ready to take charge of creating the next block it is lucky because it has randomly being assigned the first pot in the list of bakers that are responsible for making sure a block is created the next Baker in that list will wait a little longer ready to take over in case the first Baker doesn't do its job in time this time our first Baker is up and running and is ready to do its job and get rewarded for it it is carefully listening to all the transactions that arrive in the men poool of its node when it's time to create the block it sorts these transactions to decide which ones will end up in this block before it selects transactions it needs to pick the other types of operations such as attestations of the previous blocks or votes the baker is trying to make money by collecting all the fees so it selects transactions that have the highest fees compared to their cost in gas and storage but before adding them to the new block it does its own checks to make sure they are valid especially when they are executed in that specific order it adds the good ones to a new block until it's full or it runs out of transactions it wants to include it then executes all the transactions by applying them to the context produced by the produ block the storage of contracts and balances of accounts are updated in the context after each transaction as the validity of the next transactions depend on them once the block is full the baker comput is hash and sends the block with all its transactions to its node the node sends it to its neighbors and the block propagates through the network the node adds this block to the end of its copy of the blockchain in an unconfirmed state for now it also executes all the transactions and updates its own context other nodes do exactly the same as they receive the block a subset of the Bakers have been randomly selected to form a consensus committee for this block when the node that one of these Bakers is attached to receives the block this Baker starts checking all the operations it contains to make sure everything is valid if it's all good it creates a pre- attestation message along with a hash of the block and sends it to the node other Bakers from the consensus committee do the same and create their own pre attestation these are propagated through the whole network the same Bakers then start receiving all these prorations check them and count them once enough are received a quorum is reached and the baker considers that this block is attested we creates an attestation message and send it to its node nodes propagate them and add them to their me pool as these attestations will be added to the next block while all this is happening your wallet is still checking with with its node what the status of your transaction is when the block that contains your transaction reaches this node the wallet will update the status of the transaction and show it to you when another block arrives and is added at the end of the chain after the block that contains your transaction this new block contains attestations for that previous one having another block added in front of it brings it closer to a final State once a second block arrives and is added to the chain then your block is definitely final you can now be 100% sure that your transaction is permanently part of the tizel blockchain the wallet shows that the transaction is final tells the DB about it and the DB confirms to you that you now own this amazing nft congratulations you have just experienced the power and beauty of tesos in this module we'll talk about some of the reasons why it's a good idea to develop your DS on tesos there are many benefits that come with developing on tesos one of the key benefits of tesos is the unchain automated governance anyone who holds 6,000 TZ or more can vote for protocol amendments proposal there's already been 14 successful upgrades of the protocol since the beginning of tesos this onchain government makes tesos very Innovative with frequent new capabilities that are added to the network and the system reduces the need for hard work there's always a single official branch of the network another benefit of tesos is that it's energy efficient thanks to its use of proof of stake it was one of the first blockchains that uses proof of stake as part of its consensus mechanism tesos is focused on scaling with a lot of work going on right now scaling with smart rollups data availability layer and more and that is done without compromising decentralization or security a lot of work has been done to make sure that the security of tesos is of top quality and the tesos ecosystem itself is very decentralized and benefits from a friendly and diverse community that focuses on long-term Innovation and it has a great ecosystem from blockchain Enthusiast artists but also multinational companies it also benefits from great tooling and funding opportunities to help developers build their projects in 2017 a large amount was raised to fund the development of the tesos Network and this amount is managed by the tesos foundation the mission of the tesos foundation is to grow the tesos ecosystem through a system of grants in areas such as developer experience Education and Training security and privacy and and re users application for more information about how to apply for Grants and what the foundation does visit tesos foundation in this module you will learn how to write your first smart contract on tesos using smart pie it will be a very basic smart contract but a useful one what is a smart contract it's a type of account that like any account on tesos has an address and has a balance in TZ but on top of that it will have some executable code the program of the smart contract that says what it can do and it will have its own storage some data that the smart contract can store to interact with the smart contract we will use used two new types of transactions the first one consists in deploying the smart contract it means putting it out on the blockchain once it deployed its code cannot be changed we say that it is immutable the second type of transaction is to call a smart contract you call it like a function with some parameters that you pass and you may send to the contract as you call it now let's look at our first smart contract this is the smallest useful smart contract we can think of all it does is to store value on the blockchain forever or at least as long as the blockchain exists so here we will store this value in the blockchain forever when we deploy the smart contract and that's all it does we can see that to create a smart contract we have to create a class we give it a name and we said that it inherits from sp. contract here SP stands for smart p and that's the name we gave to the smart by Library when we imported we need to create this class inside a module that we call Main like this and inside the class we create a Constructor that is named in it with two underscores before and after and within this Constructor we can initialize the storage with an attribute that we decide to call value and the attributes are stored in self. data Dot and the name of the attribute so here the contract doesn't execute anything on blockchain WE simply Define its initial value of the storage that will be stored forever once it's deployed it won't be doing anything else if we want to test the smart contract in the smart P IDE we will need to add tests and you always want to add test to any contract you write and in smart P you can add them in the same file as the contract itself here we create a test by adding this test function with the ad test decorator and within this test we create a scenario that basically will contain the sequence of tests calls to Smart contract Etc we give it a name by calling the function test scenario and we declare what module it uses so here it will be using the main module then we create an instance of our store value contract like this we store it in a variable and then we add it to the scenario when we run the test it will simulate deploying the smart contract and show us the output one thing you should keep in mind especially if you're not a python developer is that every time in your code that you create a block the content of this block should be indented compared to the parent so for example here we have a class and inside the class we create a block that's the content of the class all the content of this block should be indented here it's indented by four spaces it could be more it could be tabulations but it has to be the same number for the whole block and then here we can see that inside the Constructor we create another block with a content of the Constructor and again it is indented by four spaces as soon as we reduce the number of indentation so for example here when we have this decorator it indicates that we Clos the previous opened block so here we close this block we also close this one and close this one let's test our contract inside the smart P IDE in this online IDE you can write your contract and an editor and then on the side panel you will be able to test it and see the output so here I put our original smart contract we see that if I just run it nothing happens because I needed a test for anything to happen so I'll add our test now I can run it and I can see that on the side panel I have this origination that is simulated and I Can See For example the address of my contract and I can see the storage value so here we can see that originated a contract that has this value and will store it in the blockchain we can check a few things for example we can see what the code of the smart contract in melon looks like it doesn't really do anything we can also check the content of the storage or the size of the storage Etc we could even deploy the contract directly from the smart by ID now it's your turn write your first smart contract you can name it store value it should store the value 42 and of course you need to add a test scenario and run it to simulate the deployment of this contract once you're done validate it on open Tel let's pause the video and give it a try before we continue so far our smart contract wasn't really doing anything except storing a value if we want the smart contract to do something we need to add entry points they are like methods or functions that we can add to our smart contract when you call an entry point they cannot do much they can only read the parameters that you pass to the function the current value of the storage of the smart contract a few special values like the balance of the contract or the amount that the color sent to the contract or the address of that color and a few more it will also have access to a global table of constants that all smart contracts have access to it also cannot do much it can only have two effects the first one is to modify the content of its own storage and the second one is to generate new transactions such as transfer t or CS to other smart contracts that will be executed at the end of the execution of the entry point itself and that's it now let's see how we can add an entry point to a Smart contract so we here created a contract called flipcoin that will store the curent ins side of a coin and then we will have a flip entry point that can be used to switch this side from 0o to one and then from 1 to zero Etc we can see here how we created an enter point we created a function with a s sp. entry point decorator and then inside that function well we change the value of the side attribute of our storage to one minus this value so if you start with zero you get 1 - 0 equal 1 and then if you call it again it goes back to 1 - 1 = 0 Etc every time you call it it will flip the value of the coin to add test to our entry point we can simply add calls to this entry point in our test function so after we added the contract to the scenario we can call contract. Flip so that's the name of our Tre Point as many time as we like let's give it a try in the smartp IDE so here we have our contract and N test let's run it we can see again the origination with the initial value of side set to zero and then we have here our first call to our flip entry point and if we click on show details we can see that the new value of the storage is now one then we have the second call and here we can see that the value is zero and then one again Etc now the issue with this is that if we make a change to this contract we don't want to have to check again and click on show details Etc to see that all the value of the storage are still correct we would like to automate this and have Smart P tell us immediately if what we get is what we expected we can do that by automating those tests so to check the outcome automatically all we have to do is add this to our scenario after or before a call to an entry point scenario. verify and then some conditions so here for example we can check that the value of this field from the storage of our contract is equal to a specific value let's give it a try here after flip we can write scenario dot verify construct. data. side equals so after the first flip it should be equal to one then I can add it here should be equals to zero again and then to one again let's give it a try all good we get the same output if we had here written one then smart P would tell us hey this comparision is incorrect as an error so of course here that's just because the test is invalid but we put zero and then we run it and then we can make some changes and make sure that we never break this condition now it's your turn write your own smart contract call it count the calls and the goal of the smart contract is to count how many times we will call it so we will have a attribute NB calls in the storage that you initialize with zero and then every time we call the contract it should increment by one so to do so you will create an entry point make call and then increment by one the value of NB calls and then of course add a test scenario and run it let's give it a try and when you're done you can validate it on open tizel so please pause the video and give it a try let's take a look at the solution we created a class come the calls that inates from sp. contract we have a Constructor that initializes the value NB calls to zero then we create an entry point make call and every time we call it NB calls will be incremented by one you could also write NB call equals and equals + one but this is a shorthand operator that makes it easier to increment in our test we instant shed the cond the calls contract in the contract variable we can verify immediately that the value is zero we can use H2 to display a title that says what we're going to do next we call the entry point make call verify that the value is one then call it again verify that the value is two let's check if it works and it's all good we start with zero then we make the first call it's now one second call is not two everything is good and again I had change it to three it would let me know that this condition is invalid testing a smart contract is really important smart contracts manipulate tokens and other digital assets that can have very large economic values we can talk about millions of dollars in some cases or tens of millions of dollars in a single smart contract and the environment where you execute the code is what we call adversarial that means other people can attack it anyone in the world could look at your contract try to find a bug and if there's a bug someone will try to attack it and try to either steal some funds in it or make them stuck in the contract and people have very strong incentive to exploit bugs that you may leave in the contract and since once you deploy the contract it cannot be changed anymore it's immutable then bugs cannot be fixed as soon as you see them so that makes it even more dangerous there are unfortunately many examples of cases where people lost millions of dollars collectively as a consequence of small bugs in smart contract so it's very important when you write a smart contract to spend a lot of time testing it proofreading it Etc in general it's actually relatively simple to write a smart contract smart contracts are small projects compared to to other types of software projects but it's actually quite hard to make sure there are no bugs in those smart contracts so testing them and avoiding bugs is the hardest part in later modules we will study different flaws and best practice on how to avoid typical kinds of bugs in this module you will learn how to add entry points to your smart contracts so that you can create contracts that do something so far our smart contract wasn't really doing anything except storing a value if we want the smart contract to do something we need to add entry points they are like methods or functions that we can add to our smart contract when you call an entry point they cannot do much they can only read the parameters that you pass to the function the current value of the storage of the smart contract a few special values like the balance of the contract or the amount that the caller sent to the contract or the address of that color and a few more it will also have access to a global table of constants that all smart contracts have access to it also cannot do much it can only have two effects the first one is to modify the content of its own storage and the second one is to generate new transactions such as transfer t or calls to other smart contracts that will be executed at the end of the execution of the entry point itself and that's it now let's see how we can add an entry point to a Smart contract so we here created a contract called flipcoin that will store the current side of a coin and then we will have a flip entry point that can be used to switch this side from 0er to one and then from one to zero Etc we can see here how we created an entry point we created a function with a sp. entrypoint decorator and then inside that function well we change the value of the side attribute of our our storage to one minus this value so if you start with zero you get 1 - 0 = 1 and then if you call it again it goes back to 1 - 1al 0 Etc every time you call it it will flip the value of the coin to add test to our entry point we can simply add calls to this entry point in our test function so after we added the contract to the scenario we can call contract. Flip so that's the name of our Treo as many time as we like let's give it a try in the smart P IDE so here we have our contract and N test let's run it we can see again the origination with the initial value of side set to zero and then we have here our first call to our flip entry point and if we click on show details we can see that the new value of the storage is now one then we have the second call and here we can see that the value is zero and then one again Etc now the issue with this is that if we make a change to this contract we don't want to have to check again and click on show details Etc to see that all the value of the storage are still correct we would like to automate this and have Smart P tell us immediately if what we get is what we expected we can do that by automating those tests so to check the outcome automatically all we have to do is add this to our scenario after or before a call to an entry point scenario. verify and then some conditions so here for example we can check that the value of this field from the storage of our contract is equal to a specific value let's give it a try here after flip we can write scenario dot verify construct. dat. side equals so after the first flip it should be equal to one then I can add it here it should be equals to zero again and then to one again let's give it a try all good we get the same output if we had here written one then smart P would tell us hey this uh comparison is incorrect as an error so of course here that's just because the test is invalid but we put zero and then we run it and then we can make some changes and make sure that we never break these conditions now it's your turn write your own smart contract call it count the calls and the goal of the smart contract is to count how many times we will call it so we will have a attribute NB calls in the storage that you initialize with zero and then every time we call the contract it should increment by one so to do so you will create an entry point make call and then increment by one the value of n calls and then of course add a test scenario and run it let's give it a try and when you're done you can validate it on open tsos so please pause the video and give it a try let's take a look at the solution we created a class come the calls and inates from sp. contract we have a Constructor that initializes the value NB calls to zero then we create an entry point make call and eve
Original Description
This comprehensive Tezos blockchain development course will teach you about its ecosystem, smart contracts, and the technology’s applications. Tezos provided a grant to make this course possible.
Learn how to develop distributed applications on Tezos, from setting up wallets to understanding and managing smart contracts effectively. The course covers various tools and techniques essential for Tezos developers and highlights the community-driven innovations that support the platform's growth.
🔗 Tezos website: https://tezos.com/
This course was created by Mathias Hiron.
⭐️ Contnets ⭐️
00:00:00 Tezos Makes It Possible
00:02:35 Course Overview
00:05:54 Tezos Overview
00:19:57 Setting Up A Wallet
00:28:07 Path Pf A Transaction
00:36:45 Why Develop On Tezos?
00:38:53 Your First Smart Contract
00:51:43 Entrypoints
00:59:19 Deploy Your First Contract
01:05:51 Types And Type Inference
01:24:03 Strings
01:28:16 A Brief History Of Smart Contracts
01:29:04 Verifications
01:46:23 Multiple Values & Parameters
01:58:29 Manipulating Addresses
02:08:35 Code Your Own NFT Contract
02:18:52 Tez & Trust
02:45:06 Options
02:58:51 Blockchains & Time
03:10:40 Arithmetic & Yield Farming
03:56:03 Records
04:08:53 Maps, Big Maps & Gas
04:37:01 Michelson
04:59:25 Local Setup
05:08:46 dApps
05:19:52 Inter-Contract Calls
05:56:14 Lists & Loops
06:19:47 Views
06:40:31 Custom Types
06:43:20 Set, Membership Contract
06:52:49 Variants
07:03:26 Variants With Parameters
07:21:05 FA2
07:36:22 Oracles
08:11:46 Flaws & Best Practices
08:26:49 Micropayments Contract
08:48:17 Geocaching
09:15:27 Randomness
09:42:46 Reentrancy Flaws
09:58:10 Flawed Auction
10:21:07 DeFi: Flash Loans
10:38:56 DeFi: Fungible Tokens
10:52:52 DeFi: Trading Tokens
11:14:48 DeFi: Arbitrage
11:24:01 DeFi: Manipulating Prices
11:36:04 Events
11:39:59 Upgradable Contracts
11:59:14 Upgradable Contracts: Lambdas
12:06:59 Upgradable Contracts: Recap
12:09:40 Multisig, DAO
🎉 Thanks to our Champion and Sponsor supporters:
👾 da
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from freeCodeCamp.org · freeCodeCamp.org · 0 of 60
← Previous
Next →
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
React: Production Server Setup Part 2 - Live Coding with Jesse
freeCodeCamp.org
cookies vs localStorage vs sessionStorage - Beau teaches JavaScript
freeCodeCamp.org
Browser history tutorial - Beau teaches JavaScript
freeCodeCamp.org
Graph Data Structure Intro (inc. adjacency list, adjacency matrix, incidence matrix)
freeCodeCamp.org
React: Parameterized Routing with Next.js - Live Coding with Jesse
freeCodeCamp.org
React: Dealing with jQuery Issues - Live Coding with Jesse
freeCodeCamp.org
setInterval and setTimeout: timing events - Beau teaches JavaScript
freeCodeCamp.org
Browser and Device Testing - Live Coding with Jesse
freeCodeCamp.org
Last Minute Updates - Live Coding with Jesse
freeCodeCamp.org
Post Launch Updates - Live Coding with Jesse
freeCodeCamp.org
React: Setting Up Google Analytics - Live Coding with Jesse
freeCodeCamp.org
React: Masonry Layout - Live Coding with Jesse
freeCodeCamp.org
Load Balancing Digital Ocean Droplets - Live Coding with Jesse
freeCodeCamp.org
try, catch, finally, throw - error handling in JavaScript
freeCodeCamp.org
Load Balancing: SSL Passthrough Setup - Live Coding with Jesse
freeCodeCamp.org
Graphs: breadth-first search - Beau teaches JavaScript
freeCodeCamp.org
React: Masonry Layout Part 2 - Live Coding with Jesse
freeCodeCamp.org
React: WordPress API Live Search - Live Coding with Jesse
freeCodeCamp.org
Creating WordPress Custom Post Types - Live Coding With Jesse
freeCodeCamp.org
Dates - Beau teaches JavaScript
freeCodeCamp.org
Miscellaneous Front End Updates - Live Coding with Jesse
freeCodeCamp.org
Merging a Pull Request from GitHub - Live Coding with Jesse
freeCodeCamp.org
React + Prettier + Standard JS - Live Coding with Jesse
freeCodeCamp.org
React: Sortable Responsive Table - Live Coding with Jesse
freeCodeCamp.org
Geolocation Sorting by Distance - Live Coding with Jesse
freeCodeCamp.org
Tradeoff Matrix - Agile Software Development
freeCodeCamp.org
The Definition of Ready - Agile Software Development
freeCodeCamp.org
Getting first React job without experience - Ask Preethi
freeCodeCamp.org
React: Google Analytics Click Tracking - Live Coding with Jesse
freeCodeCamp.org
Submitting a PR to an Open Source Project - Live Coding with Jesse
freeCodeCamp.org
Should I go back to school to get CS degree? - Ask Preethi
freeCodeCamp.org
Hero Section CSS Changes - Live Coding with Jesse
freeCodeCamp.org
Working Agreement - Agile Software Development
freeCodeCamp.org
A day at Pennybox with Co-Founder Reji Eapen
freeCodeCamp.org
React: Sorting and Filtering Data - Live Coding with Jesse
freeCodeCamp.org
React: Sorting and Filtering Data Part 2 - Live Coding with Jesse
freeCodeCamp.org
React: Building a New UI - Live Coding with Jesse
freeCodeCamp.org
Definition of Done - Agile Software Development
freeCodeCamp.org
Getting started with jQuery (tutorial) - Beau teaches JavaScript
freeCodeCamp.org
Making a React Blog with WordPress Content - Live Coding with Jesse
freeCodeCamp.org
React, NextJS, CSS - Live Coding with Jesse
freeCodeCamp.org
jQuery events - Beau teaches JavaScript
freeCodeCamp.org
React/NextJS Routing and WordPress API Custom Types - Live Coding with Jesse
freeCodeCamp.org
React: Working with API Data - Live Coding with Jesse
freeCodeCamp.org
React: Refactoring Components - Live Streaming with Jesse
freeCodeCamp.org
jQuery effects - Beau teaches JavaScript
freeCodeCamp.org
More React Refactoring - Live Coding with Jesse
freeCodeCamp.org
animate in jQuery - Beau teaches JavaScript
freeCodeCamp.org
"Finishing" My React Site - Live Coding with Jesse
freeCodeCamp.org
Starting a New React Project (P2D1) - Live Coding with Jesse
freeCodeCamp.org
React Project 2 Day 2: Learning Material UI - Live Coding with Jesse
freeCodeCamp.org
The Agile Manifesto - Agile Software Development
freeCodeCamp.org
jQuery: get and set with http, text, val, and attr - Beau teaches JavaScript
freeCodeCamp.org
React Project 2 Day 3 - Live Coding with Jesse
freeCodeCamp.org
The INVEST approach to product backlog items
freeCodeCamp.org
React Project 2 Day 4 - Live Coding with Jesse
freeCodeCamp.org
Chickens and Pigs - Agile Software Development
freeCodeCamp.org
React Project 2 Day 5 - Live Coding with Jesse
freeCodeCamp.org
jQuery: add and remove DOM elements - Beau teaches JavaScript
freeCodeCamp.org
React Project 2 Day 6 - Live Coding with Jesse
freeCodeCamp.org
More on: LLM Foundations
View skill →Related AI Lessons
Chapters (50)
Tezos Makes It Possible
2:35
Course Overview
5:54
Tezos Overview
19:57
Setting Up A Wallet
28:07
Path Pf A Transaction
36:45
Why Develop On Tezos?
38:53
Your First Smart Contract
51:43
Entrypoints
59:19
Deploy Your First Contract
1:05:51
Types And Type Inference
1:24:03
Strings
1:28:16
A Brief History Of Smart Contracts
1:29:04
Verifications
1:46:23
Multiple Values & Parameters
1:58:29
Manipulating Addresses
2:08:35
Code Your Own NFT Contract
2:18:52
Tez & Trust
2:45:06
Options
2:58:51
Blockchains & Time
3:10:40
Arithmetic & Yield Farming
3:56:03
Records
4:08:53
Maps, Big Maps & Gas
4:37:01
Michelson
4:59:25
Local Setup
5:08:46
dApps
5:19:52
Inter-Contract Calls
5:56:14
Lists & Loops
6:19:47
Views
6:40:31
Custom Types
6:43:20
Set, Membership Contract
6:52:49
Variants
7:03:26
Variants With Parameters
7:21:05
FA2
7:36:22
Oracles
8:11:46
Flaws & Best Practices
8:26:49
Micropayments Contract
8:48:17
Geocaching
9:15:27
Randomness
9:42:46
Reentrancy Flaws
9:58:10
Flawed Auction
10:21:07
DeFi: Flash Loans
10:38:56
DeFi: Fungible Tokens
10:52:52
DeFi: Trading Tokens
11:14:48
DeFi: Arbitrage
11:24:01
DeFi: Manipulating Prices
11:36:04
Events
11:39:59
Upgradable Contracts
11:59:14
Upgradable Contracts: Lambdas
12:06:59
Upgradable Contracts: Recap
12:09:40
Multisig, DAO
🎓
Tutor Explanation
DeepCamp AI