StarkNet 🛠️ Basecamp Session 1:Fundamentals
ETHGlobal·Mon, Oct 9, 2023, 12:00 AM
Join David Barreto of StarkNet for a workshop titled "Basecamp Session 1:Fundamentals" in preparation for ETHGlobal New York. Hack with some of the most skilled web3 developers, designers and product builders from all around the globe for a weekend-long adventure to advance the Ethereum ecosystem, ETHGlobal New York 2023. ----------------- Follow us: https://twitter.com/ETHGlobal​ Check us out: https://ethglobal.co​m Email us at: hello@ethglobal.com
Transcript
foreign [Music] this is a session one one of seven uh okay my name is David Barretto I'm one of the developers Advocates from stockware focus on this target of course you can see here my socials my Twitter my blog as well and I'm here with also man meet and Omar we're also developer Advocates from stockware so in this cohort of Basecamp Code 4 we're gonna have seven sessions in seven weeks each session lasts for two hours what we expect and roughly is that out of those two hours 90 minutes will be the presentation of some light coding uh we have 20 minutes for questions uh which you don't have to wait for the end or just whatever question you have use a q a and then meet and Omar will do their best to try to answer them if if any of you don't know the answer you want to discuss it please um interrupt me we have a discussion live as well uh we will share in the Q a for you guys after the session in an email so you have that as a reference uh we will have 10 minutes break as well and just so you know the last session of Basecamp Code 4 is going to happen May 24th so it's going to be kind of like two months in the future uh we have some homework but it's optional if you want to do or not just take basically as a way to learn everything about strong enough and Cairo is up to you how much you want to get out of that um so we don't have any formal aggravation we're going to be reviewing the code uh we're just here to support you that's why the Discord is important if you get stuck with homework go to Discord try to get support from your peers we will also get to hang out there uh to help you guys as well uh David there's a question regarding the slides can we show the link oh yeah yes that's a good point yeah okay let me uh file share publish answer so it stays there in the chat as well okay yes please I that should be working is it working for you Omar I'm making you open it or anyone in the chat can I mean let me know if you can open the slides okay cool people are able to look at the slides so as I mentioned we're gonna have seven sessions for a base camp so today is about fundamentals just the getting started about you know everything about starnet Cairo hopefully to have a basic environment instead of in our machines and to deploy an example a smart contract to stunning so you get to interact with a network as well session two next week is going to be a deep dive so basically it's like a part two of this saying talk today session three is actually about Cairo One going through the syntax and if any of you have been on at stuck there for a while you will know that Cairo zero is a very different language from Cairo one so we want to take some time to go through all the details about the syntax session 4 is about testing and how to test Chiro One and smart contract then Session 5 is about the star net architecture we will see some architecture today at a foundational level but then session five we're going to go deeper into it session six we're gonna look at cairo's architecture because Cairo has a very specific CPU architecture that we're going to discuss there and the final session is going to be about Starks the ZK proves that underpins stagnet okay so some things that that you should know uh is that after each session you will receive an email that's gonna have a link to the recording it's gonna be linked to a YouTube video a video that's going to be unlisted so you will need the link to to see it we can also share uh the Q a from the session that's why uh we're trying to push people to have any questions use the Q a because that way we can share with you after you have as a reference we're also going to send a feedback form because we want to hear from you guys how do we improve Basecamp sessions only basically how to improve from next session for next week so please give us your feedback uh we're gonna tell you what's gonna be the homework in the email and also a form so you can submit your homework in this case any GitHub repo or your stagnant address where you actually deploy it use the Q a system to ask questions inside the chat and use Discord to get help from peers so if you provide your Discord username when you register to Basecamp you should already been added to a private channel on Discord and the stagnet on the yeah the starting channel the stock will sit in Discord server uh if you didn't it's because there are some issues either you were not part of the Discord server so try to first of all get into the Discord uh for stockware and then we will add you some people we were unable to actually add you because there's some rules about security about the Bots that we cannot bypass so I'm sorry that's one of you and if that's your case please use this session to ask all the questions you have so for today's agenda we are going to cover why Cairo uh why stagnet so Cairo the programming language starting this the layer 2 with with kairis is used we can also see a basic view of the stagnant architecture we're going to do some also basic view of car one I'm going to discuss some of the tooling that you have available as a developer we're gonna have a little break and then um we're gonna do some live session setting up a basic data environment from scratch so I'll be using this case a VM with Ubuntu so you can see the whole process from start to finish and we also have that documented I'll show the links to where that is being documented any interesting questions Omar might need to discuss now life you can vote on your favorite question that q a as well so that gives us more visibility right we lost some admit [Laughter] uh so this is some especially here which disco server channels is dedicated to the bootstrap The Bootcamp thank you uh it's called bootcamp sorry Basecamp coupon um yeah that's inside of the stagnet Discord server all right uh let's get started so why wait Cairo so I like to start this with actually a story so imagine you are the head of a space Exploration Agency in a small country and your task is to send as a spacecraft a small one like a robot to to our planet let's say Mars so of course you have to do a bunch of calculations and maybe the most important one is one is the right launch window and the in the best trajectory so you use the least amount of fuel so you know the rocket is the smallest as possible and it takes the least amount of time so those competitions are very complex to perform requires a lot of companion power so probably you will go to your engineer and say hey could you arriving in the algorithm and some very high performing language like Ross for example so we can get those results we can just know those two variables the best launch window and the best trajectory so sure enough they create the algorithm uh but it's very complex because so complex actually requires a super computer to be executed in any reasonable amount of time but you have the issue that you don't have a supercomputer because you know you're in a small country you don't have access to other resources but there is a rival country that has been willing to help you out they actually has they have one and they have offered to execute your code and give you the answer but then you have the issue that sure you can provide the code to them to the arrival country they executed in their super computer and they will give you back the answer right so they give you those two variables the launch window and the trajectory but then you have a problem like how did you know that that is the right answer that is actually the result of executing your programming exactly the way you write it I didn't know that the super computer didn't malfunctioned like one bit flop doing the calculation or maybe there was some kind of sabotage maybe it's even a small change in how the competitions perform could be a disaster for your space exploration so you don't have a way to meaningfully to be convinced that result is actually the what the the algorithm that you wrote or your team wrote actually was supposed to find so not even when any situational language you cannot have that certain thing not even Ross not c not any language but with Cairo you actually can because characters are as approval language that when you execute it the tribute scenario this this time you write the algorithm in Cairo instead of rust you provide that code to the supercomputer of the Revel country but now then because it's it's been used uh with Cairo not only did we give you the result back and they also will give you a cryptographic proof that verifies or will let you verify the validity of the computation but the Integrity of the computation so now you can take that proof and you can use any regular computer and just verify the proof and the verification will keep letting you know in in non-certain terms or in a mathematical certainty way that the result that you're getting is actually what was supposed to came out of the execution of your program this is called computational integrity so now if the execution is intentionally or unintentionally modified the proof will be invalid and you will know it right away right so there's no chance someone's going to sabotage your your program or that there was some malfunction and you didn't know you will know right away so with this with Cairo and the fact that you get cryptographic proofs out of execution a regular computer in this case a laptop is able to keep a super computer honest and that is a superpower that only languages specialize like Cairo especially for validity proofs I can provide okay uh just a sec trying to make the Q a visible for me as well maybe just one question here we have a channel for in Discord for this cohorts uh we do we do someone actually provided report that's the name excellent ah thank you very much shipping I saw the dude okay yeah uh if if you provided your Discord username when you register you should be you should be in the channel already unless you were not part of the Discord server so if you're if you are not try to join the Discord server for stagnet and then we will review the list again and add the new people dot enter the server later David if you take this could you could you please add me so I can also take a look at the questions and and be able to answer them on Zoom to add you to Discord uh just a q a I have to Discord I don't know oh I know you can just open the window yeah it's opening no problem David and yeah perfect perfect okay so we have of course confused what we're trying to answer them and let you know what can we answer like let me just try to answer a couple of them maybe you can type the answer as well so they have it as a reference but let me just see interview the audience uh let me see all the questions at least the one have been voted that have not been answered already uh so let's keep the intro so what do I have to do to graduate can attend all the sessions 100 do the work we'll have a form of graduation this time we're gonna give you homework it's up to you if you want to do it or not and just take base cameras a way to learn as much as you want from Cairo and stagnet uh this is because we don't have capacity to assess hundreds of people submitting homeworks every week a reliable way and we realized that the goal here is just for you guys to to learn all right yeah and we can do cool stall fans and at all you will see that it has it it goes to any do something it will it will be worth it box says we really need have to focus on Chiro One no reason to do Cairo zero anymore yes in this space cam We're not gonna do any Cairo zero it's just all about Cairo One this time just be mindful car one is super new was just released to Mainland very recently so it's gonna be a little bit rough around the edges uh but it will improve over time how can we share that the proof is not tampered so the probability of you being able to create a cryptographic proof that's going to fully verifier is one over one billion times 1 billion times 1 billion times one million so it's very very small that you can actually do that to understand exactly the reason why you have to wait until session seven when we discuss actually stuck the math behind this validity proofs please turn on caption it would be super helpful you know what I try less time I don't know where it is can you almost can you take a look to see there's a way to enable captions I know the last time or some previous style we were able to I just don't remember where if you see any interesting question please interrupt me and we can have a discussion sure oh okay now we are we gonna I don't know it okay so to summarize why why Cairo so first of all it allows you to create what's called a progable program for when you can create a cryptographic proof that verify that attests to the Integrity of the computation uh so as I mentioned the cryptographic proof is generated alongside the result proof verification can detect cheating or malfunctioning without re-execution and that last word is the key to why we use relative for scaling ethereum we're gonna we're gonna look more into that in the net section so you can summarize this by saying that a regular computer is able to keep a super computer honest when you use a language like Cairo okay so we talked about Cairo so why do we need to stagnet so the thing about the issue of scaling on layer one so just a second it disabled disco because it has so many notifications that are distracted me okay uh so in layer one in case of ethereum we have what's called a block producer which is going to give you okay it's going to tell the network hey here's a new state of network let's say the state is 42. but of course all the other validators in the network they just don't want to take the word uh for it and say oh yeah sure it's 42. they will actually execute independently the same blog and verify that they all get to the same result independently so that's the so that's part of the consensus that the actual result they all they get to a consensus is actually 42. so as you can see even a small or a simple computation takes tens of thousands of computer to actually execute right because they all need to execute that independently and get to a consensus so you can see that is fairly inefficient in that regard so this is how ethereum achieves computational integrity but by re-executing the same transaction over and over in the case of a stagnet we execute only once but then we verify everywhere so when you understand that you will do something similar you you know process transactions and then you propose a new state let's say the new state is 42 but not only do you provide the new state you also provide the cryptographic proof and now the validators were just ethereum nodes ethereum validators they don't have to re-execute the same blog to see if it's 42 they only have to verify the cryptographic proof that was provided and that will give you give them mathematical certainty that the actual answer of the new state is 42 without having to re-execute all the transactions in the block and as you can see the verification takes only a fraction of the actual underlying computation so you can see it visually here why a layer 2 like a stagnet is so much more performant because now you don't require every single node of the network only one to re-execute all the transactions they only need to verify the cryptographic proof and that takes much less effort how was the connection how less of an effort well if the execution takes n steps right the execution done by the sequencer on a stagnet then the validation of the cryptographic proof associated with it actually takes log square of n so this poly logarithmic relationship and it's easier to see in this graph so this blue line going vertical oh sorry by going in the diagonal it's actually the amount of steps of certain computation and you can see the red line is the amount of steps or the verification of the associated cryptographic roof so the bigger the gap between these two curves the more you achieve in saving computing power from the whole network to achieve the same result of creating new States so you can think of validity proofs additional validity proof is to computation what zip is to a file size it's all about compression just in the case of validity proof it's a compression of computation while zip is a compression of file size um let's see any interesting questions any question here Omar unmade yes to be honest as long as they use the Cairo VM uh and you have access we're gonna have to see you you need to have access to the underlying Cairo program so we all have an agreement which program is being executed but as long as the super computer use Cairo VM uh it will able to generate this cryptographic proof that the computer will not be able to Tamper or or if they do you with a verifier independently you will be able to spot when they're trying to cheat Oh So when you say cheating and being honest what do you mean like what is we what is cheating in in this context City will be tried to create a validity proof they try to attest to a computation that didn't happen or to a test that some computation that apparently happened uh provide a completely different result that it should have done okay and and you've been trying to fully verifier that you have on your side so is this is the combination of both I give the security of a system okay thank you secure stage uh please people in the chat please use the Q a don't use the chat for questions so we can keep track uh yes we're focusing on the on the on the Q a and also David here's a question on how can as Leo join the Discord I guess they're simply going to the Discord of Stark Nets join and whatever you can share the if you can share the invite link to the Discord server uh put it there and doors and it will be helpful well also let me invite you to the telegram I will send you a link in the chat so you can join the telegram here of English speakers uh it's for only for Builders so if you want to go there and we can just talk a little bit more and and contribute you can ask questions and so on so I will I will send you the link also for the Discord cool thank you Omar all right let's talk a little bit more about validity proofs so validity proofs are an implementation What's called the zero knowledge groups or ck proofs and it uses CK proof to guarantee computational integrity that's basically to guarantee that certain output is a result of computation with input so you can think about about that is like doing the right thing even when no one is looking that's one way to think about computational integrity so we use validity proofs in seeking proofs not for privacy which is a common misconception about standard we use it for a scaling ethereum as I showed you before the comparison of the layer 1 and layer 2 validators uh so starting right now it's not about privacy it might be in the future but right now it's not that's why we think that ZK Roll Up is a misnomer because it can imply some privacy we prefer the term validity roll up or standard and to be fair pretty much any other cable out there uses validity Roll-Ups none of them to my knowledge actually are focused on privacy after I think Aztecs shut down their own Layer Two and very importantly the type of CK proof that stagnant uses is the stocks we don't use snacks probably you have heard both being sick improves but we use Starks and there's an important reason why we chose to go with stocks and snacks that I want to review here so if you compare these two type of ZK proofs and the verification time for uh for a start proof is poly logarithmic maybe you recall the chart that I showed you in the case of a snug is actually constant so it doesn't matter how complex the underlying computation is the amount of work to verify the computation is always the same now the proof size that we send to layer 1 for verification in the case of Stark is pretty big it's about 400 kilowatts in the case of the stock it's pretty small it's only close to 300 bytes so he begs the question if it's not XR so much better than the stock why did we actually chose a stock engine snug or a stagnet there are very two important reasons for that first of all when you use a snacks you have to go through the trusted setup that the trusted ceremony where you have to fit the system with uh with a secret and you have to make sure that the secret is properly disposed because if that secret has been leaked the whole system is compromised in the case of stock we don't need a trusted setup it works even without them so it's it's one less trust assumption for the security of the system it's also very important the stacks are quantum secure which snacks are not so whenever quantum computers come in line with sufficient power they will actually break a start but they will not break a stark so we are making a bet on the future to you know the maximum level of security that we can think of of course that has a price in the proof size but it's better to be safe than sorry in the future that's all this will be thinking David good question here so there are some people that go in the Discord of a star net what they have not been added yet to the channel so what what will we how can we proceed in that case if you if you joined just recently uh allow me some time to get in touch with them the Discord mod who is in charge of the channel so they can add you uh just make sure that you actually provided that your Discord username when you register uh and we will try again to add you to the server some people might try to join the stock where the server and might not be able to and that's because some security Bots that's something that we cannot do anything about that but if you actually were able to join we will add you to the Discord server just maybe tomorrow morning maybe they can send their Discord uh name in the chat right and we can yeah if you can take the note of that it will be super helpful and we will thank you okay let me see more questions I wonder is this a way to hide they wanted me to answer okay is there a possibility to keep the algorithm private so the super computer cannot tell algorithm and they use it later and not now no because as I mentioned the stagnet it's not about privacy it's about scaling and so you have to share the algorithm so basically when you use a star net you have to publish your smart contract so it becomes visible to anyone to use it if you want to read David please pull please click on answer like so we know you already asked me yeah okay there's two questions from Fox from hcp so man you know that there are okay what do you think about the snacks using a trusted without trusted setup they are using some kind of BRS what do you think about them well I'm not sure I haven't takes so deeper into the text and know what's the implication but I know that for ethereum there's a push right now for kcg commitments I think that's that's part of the set the the secret right we're all collectively creating a secret to fit into the system to provide security to to the stocks uh so that's why it can be done but then you have to make sure that you do the kcg community ceremony correctly uh so real quick so when you have a circuit and the verifier has to read so basically you have two parties grouper and verifier all of this trusted Etc is basically done so the verifier can read something shorter than the actual circuit and verify that the circuit is correct so we have to as David has been saying go through some sort of a compression process from circuit to compressed information and then that compressed information is what the verifier reads this compression requires in the case of snarps which is the first product although I've been introduced in the space it requires some Randomness now whether you use verifiable Randomness or I guess unverifiable Randomness that doesn't change uh the security vulnerability that we are talking about is that even if you do have verifiable Randomness and someone is able to get access to that or leak that information after the trusted setup then the plural can basically cheat and create false rules and the verifier will not be able to like figure out what's going on so so that's kind of like what we're doing here stocks required no um no Randomness to generate they only use a collision resistant hash function which is also why they're Quantum secure so so that's kind of like just a a fundamentally Superior Tech stack I guess that's a very interesting question from zeberine is Larry that says aside from blockchain where can Cairo be used let me try to I see some very good answers already from from your peers so let me just provide my own answer as well um one example that I like to think about is in the future you should be able to generate proof directly on your computer right and then submit that proofs to some server and the server is the one who runs the verifier and I like to think gaming is a good example of this when it's a common issue in gaming that people actually modify their client to cheat right and and that's an issue when you have a multiplayer game with language like Cairo you can technically request your client to every every so often create a validity proof out of the execution of your client and send that variability proof to a server which runs the verifier just to check that you are not in that you actually can decline the way that it was supposed to to be right so if you try to cheat if you try to modify your client the server will not because the validity proof that you send regularly will fail so that's my use case uh and then people actually doing research in the topic to actually run even on a smartphone the main issue right now is that creating proof is a very resource intensive process so there's a lot of research that needs to be done uh to get to that point but it's an interesting thought as well how to use Cairo in a different setting that is not stagnant we're also doing something with Bitcoin rights oh that's great yeah can you explain can you elaborate any of you what is happening well I know that there is something being built I will send you the report to the chats something is being built I don't know exactly what but it is in order to scale a bit you should start and it had been very successful within the vehicle community so you thought that's something that's something we can say about it and also uh David there's a question about the program will be open so let me first answer the question about the Bitcoin uh actually that's something that the big Community is very well aware of I think the ethereum community is not as much but on the ethereum community they're actually using our technology to create a very light Bitcoin client they basically uh I think the basic idea is that a cryptographic proof or validity proof is generated out of a regular Bitcoin client and then when you want to sing a new Beacon client yourself you don't have to download the whole blockchain to calculate the utxo yourself you can just verify the cryptographic proof of all the calculation that other server actually perform for you and then you can sing to the latest utxo just download the database and verify the cryptographic proof associated with the execution to get to the current utxo so now you can zinc a Bitcoin client in a matter of probably minutes instead of days I forgot the name of the project let's look at zero inclement Heroes has certain implements conflicts here added the link to the repo the chat thank you very much Clement you can go and see the Toyota is there's a lot of very cool stuff that is being built right now at the at the age of the technology so and it the star Community is amazing to to be honest it's amazing they are building some very cool stuff and yeah it is look and David do you want to to do the program Open Source question the proper open source yes so right now it's not open source but we made a commitment to actually we will make it open source we're just trying to tackle other areas of the blockchain first especially the sequencer is our first Target it's just already we're doing a full rewrite in Rust Open Source One to decentralize also the sequencers before we can tackle the this is the approver but it is the goal to decentralize the whole stack it's just not yet we're not at that level yet so right now the sequencer and the prover are actually centralized which is the same any author every other CK problem right now very centralized that's all they're not actually open source yeah go ahead Omar there's also a question for all Paul asking can you explain why Stark is for the secure and not Stark so real quick the the part of the cryptography that has been vulnerable right now to Quantum attacks are those using elliptic Corpus the cryptography such as snarks and ethereum and Bitcoin and so on and it starts are not relying on this kind of Primitives not they're not using elliptic cores there you see excessive functions as symmetric key encryption so it is believed that this particular Primitives will be one two resistant so that that's the main reason the eligible yeah at least right now we don't know we don't know any algorithm able to break uh hash function using quantum computers but we do know an algorithm to break elliptic curves and and other cryptographic Primitives using elliptic curves using quantum computers the algorithm exist is just waiting for a Content computer to be sufficiently powerful to run it and then they will call when we have that a lot of the movement is so yes and one of the goals they have is actually trying to use this this algorithm to break the elliptical therapy is actually a metric for how good these computers are so it will come a day and when that becomes the first thing they will do is break this lip curriculatory thing yeah all right thank you for the question um meet Omar feel free to keep answering them on the channel I'm just gonna keep moving forward because of time constraints all right so you probably have heard like in a stagnet we use the Cairo VM whether you we don't use the ebm so so why is that so on one side you have ZK ebns right which some famous ones are like the polygon Hermes uh scroll CK sync they try to be as compatible as possible to the Ethereal virtual machine while stung it is actually using its own virtual machine called the Caribbean so these two approaches is trying they're trying to optimize for very different things so CK EDM is trying to optimize for having Max compatibility with current smart contracts deployed on layer one but they sacrify performance because the NVM was created for a particular CPU architecture or a traditional CPU architecture that is not really um friendly to CK circuits that's why Cairo VM or Stockbridge we decided to create our own virtual machine so we can create a our model a computer that is exactly or fine-tuned or validity proofs so we're thinking about how do we extract the most performance of the network long term I mean do you have any more comments you're more an expert at this area than I am probably oh I I would leave it at that today uh and uh but we can but yeah the main differences of course you can compile your code directly into ebm byte code on zkebms with us you have to go through uh Sierra and the maybe yeah I'll let you speak more but we have a session six it's gonna be about the Cairo architecture so probably a lot of the a lot of these uh questions are going to get answered how the architecture with Chira actually looks like what other the Caribbean actually looks like um just a quick comparison if you have read vitalik's article about the CK ebm classification declassifies CK EDM in four categories type one to four so type 1 is basically no changes to the ethereum virtual machine you know full compatibility but the performance will be very very slow to create a cryptographic proof out of those execution so pretty much no one is attempting this right now uh type 2 is that you use most of the ebm but you change at least the data structure for storage to achieve High compatibility at least you're gonna have some smart contacts or you will need to be modified but the performance is still very slow then you have type 3 where you have compatibility but you have to modify something like a storage hashes pre-compiles to make it a little more friendly to the new architecture so you have partial compatibility it's not like you can deploy every single smart contract as is to a layer 2 with these characteristics the performance is going to be slow at least in theory technically and we have projects doing that like scroll and political Hermits as you can see even Kai carrot which is a layer 3 on top of staring it are actually tended to be type 3 CK edns but then you have the Type 4 where they Implement a completely different virtual machine there are either not compatible uh with the smart contracts Deploy on ethereum using solidity but the upside is that it's very fast to create the validity proofs so you have two main projects completing the space obviously this target is one of them and you can consider to be a CK EDM because you can use stagnate with a compiler called warp to compile solid smart contact into Cairo VM and the other one is polygon smiting so we are really focused on performance and long-term view of a scaling ethereum yeah many coding here eleven session he said like we really believe in Star Wars that the future of skeleton will be built using Cairo using Cairo gdm because I think it says they only focus of caro the only focus of Kyle its role is to scale ethereum that is not the goal of the evm right the evm goals is to maximize centralization which is great and it's very relevant well in care we're already giving us a we're already thinking as a given the part of the security and the centralization that the theme gives so now we're focusing only on scaling and that's why we really believe that Cairo is the way to to to to to skill the problem here is of course image form from David's show there's already an ethereum building two links two links or boundary we have profitable ad and so on and and those we don't have in in Cairo or starting we need to build new tooling however the toolingx is being built by the day so we have total star which is kind of similar to Foundry we have a actual truffle no sorry which I we have several apis and SDK that we can use to drag with the storage and Cairo so the link is getting much much better so we are able to write koi and scale board the social part and This calamity as lower fees and faster fastest conceptions well thank you Omar all right to summarize why Stang it first of all it guarantees computational Integrity without re-execution uh proof verification is cheaper than the underlying computation so remember the poly logarithmic relationship with the underlying computation we can think about that as computation compression so we use CK proof for scaling not for privacy that's very important to keep in mind at least not yet and we use ZK proofs we use Stark's CK proofs and not snacks because Starks are quantum secure that's really the main reason we're thinking long term and this is why we have the trade-off cool let's talk about a high level the architecture of standard so in my previous example the story about the you know the head of this space exploration the the person actually got convinced that the result is 42 whatever that is right because he was able to verify in the penalty the cryptographic proof in his laptop but then how do you how is other people gonna trust that that is actually the result right because so far only this guy was able to verify the little proof but not Alice so that's why for for Alice to trust a couple of things are needed please you need to make the Cairo pronoun publicly accessible for anyone she should be able to in the penalty verify the proof basically run her own layer 2 node so she needs a stagnet so standard is a layer two right so that's why I present here ethereum at the bottom has layer one so on a start net when you send a transaction uh you send the transaction to What's called the sequencer right and the secrecy is is like the blog producer of starnet and it uses that's where the Cairo VM lives and also with the stagnet OS leaves and the sequences are just going to take all the transactions it's going to validate them just to make sure that the signature is correct that the person is able to do these things or they've been able to use this user account it's gonna bundle them into blocks and it's going to calculate what's the new state of the network based on the execution of this block right similar to a block producer on layer one in this case the interesting thing here is that out of the execution of all the transactions in a blog and the sequencer sends uh what's called execution Trace should approver that we call it sharp in the case of a stagnet Sharp is because shared prover is used by stagnet is used by Stack X as well so with this execution trace the prover is able to compute the the validity proof to attest to the Integrity of the computation done by the sequencer and this validity profits eventually sent to layer 1 as call data to a verifier a smart contract um that is written in solidity right this is open source anyone can see it so the verifier is going to take the relative proof and it's actually going to perform the verification on layer one this case is the 10 thousands of ethereum computers are going to perform this computation independently any day verification is actually successful then the sequencer is going to change the state difference but changing the state before and after the block was executed again to the leader one as call data to a different smart contract that we call as stagnet core and we use that as our data availability layer where we want to polish this data on layer one so now we can have full nodes or stagnate full nodes who gets uh what is the state of the latest block or the state of the network it gets that from the sequencer correctly because as of now these are two centralized entities but the fact that we send this state div to layer 1 it means that if for some reason the sequencer or the connection between the full node and sequencer fails you are able to recreate the layer 2 current state by reading or indexing data from the standard core smart content so you can recreate the data from layer one independently if you if there is a situation that the sequences stop responding to lead to full nodes so at a very high level this is how standard works so I I went through some of the modules so as I mentioned the sequencer validates executes and bundle transactions into blocks the proverb creates stack proofs for a stung it and a stark X that's what's called sharp or shareproofer the verifier is a layer 1 smart contract verifies the stack proof send from Sharp is another layer one smart contract that just stores is a big word because actually we only send it as cold data it's not get stored at the contact level storage or cost reasons and we use that as a data availability layer apparently the full node provides data to layer 2 taps David in seconds perfect so we're getting the Stars representation there wasn't familiar sorry little for coming there are a lot of questions that were answering each of them so a little ask do we send algorithm or the data to Royal control when you were talking about this part we send it Oh you mean the example at the very beginning yes at the very beginning so what are we saying the algorithm or that the algorithm like the program you can you can send yeah the program it's just in reality you don't send the program as is you send the buy code of the program right the the low level Cairo assembly program to the so to the super computer okay yeah yes uh from admit go ahead do I remember our our is asking can you use different that availability layer like Celestia for example yes we are working on on the valid use which is going to be and we're in the Innovations where we will be able to do the the the data by logistic Parts using different different kind of services for example Celestia file core a USB if you want so let's go to inverters you will be able to write Cairo codes where you can declare Bibles that are going to be stored in the on chain and some variables that will be not store on chat the Google Store I know uh of China or maybe it's an STL or somebody else so like that would be very very cool we believe yeah yes your supplement it's called volition because validium is function uses so we have three different data availability modes but right now only two really roll-up is the one used by stagnet will be published to layer one validium which is used by Stark X that we are not covering here but it's another technology developed by stockware and then we have volition that we want to we want to implement on the stagnet I don't know this year at some point which will allow you to choose where to store your data so you have different costs for your transactions you're going to store it on layer one or have a maximum maximum security or do you want to store it in a similar place it could be Celestia or a Consortium of cells people storing data that's going to be cheaper so we don't have a lot of details about that but we know that is a path forward for selling it to enable evolution do you have 3DS he says scheme for the link to the report or the verifier smart contract in layer one do we have no yeah yeah uh repo oh wait a dog yes it is you go to the Caroline repo uh useful info important addresses they verify your address yeah so you can is there is there a question here I don't know where the question is I put it on the chat but or can you please put it on the connect q a so all right so this is the link to the hair to the deploy smart contract to see the actual source code you have to go to the Caroline on GitHub and and in here uh I think it's here's the Star Wars oh man I know I saw it sorry but I don't remember yeah I can search for it or good it is yeah it is I've seen it is there somewhere actually defined perfect cool uh section four so let's talk about Caroline like we just recently uh uh which recently released this new version of the language which is very different from Cairo zero but it's much better than Cairo zero so cairo1 is a high level language right which makes it easier to learn compared to carols here which was more of a low level language the syntax of cairo1 is heavily inspired by rust which also makes it like a strongly typed language so if you know Ross you will feel comfortable with Cairo One uh when you compile a Cairo smart contract uh it doesn't directly compile to the Cairo VM by code which we call it the power assembly it compiles certain Intermediate Language called Sierra Sierra stands for safe intermediate representation because this is what allows us to create validity proofs even when a transaction fails which was not possible before and now because of Sierra basically sequencers are always compensating for their work even if a transaction fails and in the near future will allow for transactions to be reverted much in the way that happens on layer one so you can see on the right side you start with the car one smart contract you compile it to Sierra and then you send this to the sequencer the sequencer that compiles to car assembly that we also call it Chasm and from the camera assembly the execution of this car assembly by code by the sequencer that's where we uh derive the validity proof on the pro and we sent the layer one so take a look this is how it looks like an example a smart contract on car one it looks a lot like rust where you can do some meta programming with macros uh this is how you bring functions into scope this is how you define storage variables you have to name a stroke storage has to be the name and then you define the properties of all the storage variables felt is still they didn't know the types but then we have more data types that we can use that before in Carousel was not possible one very commonly uses u256 which is commonly used in solidity uh this is how you write to storage this is the syntax this is how you read from storage for now just take a look today is not the the day to focus on Cairo One a lot just for you to have a taste of how it looks like and and now this is how you define variables with the keyword let which if you use color zero and you know that before it was about four different ways to Define a variable now we have only one so the much nicer language to play with uh so there's something called Regenesis that is all about closing the gap so as I mentioned briefly that in Cairo zero transactions fail transactions cannot be proven and because they cannot be proven that opens the door for what's called a denial of service attack on the sequencer because the sequencer gets to execute a transaction to the point where it fails and then it cannot add it to the block because availability proof cannot be created out of a field transaction in KERO zero Carlos cairo1 actually fixes this problem but it means that it eventually KERO Zero's my contacts needs to be disabled from the network for security reasons so we have two important events that happen over time the one that happened recently is the deployment of starting 0.11 to a minute because before 0.
11 main it only supported Cairo 0.10 smart contract right 0.11 now both languages are supported Cairo zero pointing Carol one at some point in time we're going to go through Regenesis maybe four or six months where we actually gonna disable all the Carol zero smart contract and only cairo1 is going to be supported from that point forward but in the meantime we have a migration window where we provide mechanism for you to be able to upgrade your already deploy smart contract from Cairo zero to cairo1 while preserving just saying uh storage layout system storage values the same address so in a way that is completely transparent to your end users using your smart contracts but you will have this migration window to go through it because after Regenesis we gotta disable all the characters my contract in that from 0.4 is only going to be Cairo One from that point on and this is where we are right now just at the very beginning of the migration window so let me go to a summary and I stopped for some questions we'll probably there's some so kind of one current one is a high level language inspired by rust Sierra allows for rebooted transactions before we're not possible we don't have Reverend that's actually just yet we need a little bit more work on on this target to allow that but it's now technically feasible to do it uh smart contest can be upgraded from KERO zero to Carol 1 while preserving the state and their current address for the Spain have been deployed Cairo One started already supports car one in the tested and on mainnet as well and Regenesis will disable Cairo zero code and that's going to happen before six months in the future so let me stop here for for questions I buy better song I there's a question from Anonymous attendee it is possible is it possible to build circuits like Silicon or Noir with Cairo One I don't think so because this is a high level language but I've not done much of an expert to get deeper into the reason why but intuitively I don't think so but from what I've seen you've seen like uh like a layer three we can be able to you to to use Noir and then that compilates so you can get into Cairo so I move into Racine and actually transformation something before of you will be you can be able to prove a snaps into star Nets is something that's been working I think yeah you can you can you can create your own verifier with Cairo right this is my contract it actually did exists they're the stocks verify they're different stock verifiers as well so really the you can Implement your only three right now in and not wait for a start where I was stagnant to evolve to the point that we make all these things like the official verify are available on Layer Two sorry but also sephorini says King can we expand more on Sierra Sierra will be we'll be looking at sessions six likes they didn't more about CLI uh probably I haven't we haven't discussed exactly what's going to be coming in the chapter but probably yes for now just keep in mind that it's going to be an Intermediate Language so when you compile uh in your computer before you deploy you no longer compile directly to car assembly you compile to Sierra and that's what you deploy to stagnet and then on a stagnet the signature compiles your Sierra by code to Cairo assembly code yeah this is a great invention from for those of you who want to for example do audits security audits you can learn in Sierra will be key for you to uh it's very important it's like learning fuel for or layer one I see some questions being unanswered with four votes three votes yeah that's the result we're working on that we have a lot of sports so there's a question by gleam he's a skin by the way his French living in Mexico so in the centralized started the sequencer will be a full note and there will also be a full note that are not a Secret Circle lines which means only sequences would participate to consensus and all other full nodes are all the relaying relaying data to depth or other notes is that correct so the how this in place is a moving Target I don't have a clear answer of course the first sequencer will be the first one to be decentralized and it means that they need to reach consensus right as any decentralized system uh do they need to be full notes I mean signature will they need to store uh the current state of the network right as well as a full node but a full node can exist in independently from a sequencer right you they don't have to be the same thing they can be independently and I think that's the future but they will probably share some modules like right now for example if you use Papyrus as a full node it uses a module called glockifier that we are going to introduce also into the new sequencer that has been Rewritten in Rust so they're going to share some of the same Primitives for storing the state but there are two different systems in the network I also wake up like clients right like viewers being built also by the community we also have beerus which is inspired by I forgot the name of the other that horse is uh forgot that there's uh there's a Lifeline developed by a16z or ethereum that we're using to build Horrors on top of that which I forgot the name yeah which also made word mentioning that Francois she has been answering a lot of questions so thank you very much with snaps is that a okay can we do this question we do we do do that yeah the sharp let me go ahead please you can answer that oh yeah so I was just going to say we do not so initially we generate One Roof object per computation but then uh basically whilst we're still in the Austrian environment we batch those moves together and keep on generating smaller proofs for a certain period of time and only at the end of that period of time do we send the one really sort of like root roof down to ethereum layer one so in that way we're actually getting hundreds of thousands of transactions through one proof object yeah on session four when we go deeper into a standard architecture we're going to look at the had approver and achieves recursion all right sorry let me move on because the time is okay fine if we have time at the end we will go back to see us on this question but please try to answer some of them and directly on the Q a um so some of the tools that you should have if you want to understand it first of all is a wallet and there are two main ones you have Argin X and you have Bravos Argent X they have a browser extension uh you can see for Google Chrome for brave for for Firefox Bravos the same also browser extension but Bravos also has a mobile wallet which is very interesting how they Implement that and how to use account abstraction so pick the one you like the most and make sure that you have installed on your browser so you can follow along some of the exercises we have two different block explorers welcome Voyager and the other one called Stark scan for their great options so click the one you like the most uh and we have some tools for developers one of them is protostar which right now I mean I actually was thinking about removing protostar for now because it's definitely a full rewrite of output Star Wars character one using a thing called scarp so maybe put that on Ice in the meantime but uh just know that there's a tool similar to Foundry on ethereum so you can test your smart contracts using the same language you use to program the smart content in this case Cairo and also we have uh collaboration with open sampling that they actually develop uh smart contracts for Cairo always all the best practices for you know yes 20 years 7 21 and and so forth other tools that we have available we have a plugin for our heart if you want to test using JavaScript we have a devnet similar to ganache as well if you want to run it locally we have a library for react for your decentralized app we have different sdks for different languages for typescript or JavaScript for python for Java calling Scala and for iOS so whatever you're building we have an SDK for that many of them right now are going through the process of upgrading to support Cairo One and so just just be mindful of that all right so let's take a break uh 10 minutes we have 10 minutes how much do we have let's let's have sorry five minutes because we have we better jump into the live coding session so just have like a you know washroom breaks and get some coffee and we'll get back in five minutes sorry I'm just going to mute myself and turn on the camera and I'll be back in a moment all right so let's go and set up uh other Dev environment for carowind um so first of all just a warning we are going to be doing using a lot of tools we're very new so we're gonna be living on the edge which means that some of these tools are still rough around the edges so we have two main repositories that we're gonna use one's called Cairo Lang which is written in Python is where the we have the starnet CLI and where we have the Cairo zero to Cairo assembly compiler right so like they all compiler uh but it still has the standard CLI and then we have the Cairo repo without blank which that's where we have the Chiron one compiler the compiler Sierra and then also we have a compiler from Sierra to Chasm and I'm going to go into detail why we have two different compilers I'm gonna explain that in section four I think uh but this one is written in Rust not in Python and it also has a vs code extension that we can use but we will have to build it from source so you can uh have some you know syntax completion and validation as well so we're gonna need three main languages for setting up this Dev environment as I mentioned it's going to simplify as time goes by but for now give it three we're gonna need Ross to compile the carow one compilers and I know it's a mouthful but that's what we need to do and also to compile the vs code extension right because right now it's not yet published to the to a Marketplace we're gonna need python especially particularly 3.9 to create uh an external account so we can deploy and declare all those things and invoke to use this target CLI because the Cairo land whereas CLI leaves is written in Python and we also need to sorry to declare to deploy and to invoke transactions understand it finally we need node.
js for packaging the vs cool extension before we can actually install it on our IDE so this is the plan for like going parts hopefully you can follow along but we had instructions shared for you here at the bottom so first we're going to compile cairo1 from source then we're going to test that the compiler is actually working by completing a simple smart contract a car one smart contract then we're going to style the vs code extension for Chiron they're gonna install this target CLI when I create a user account locally your computer so then you can declare an example of smart contract you can deploy it to stagnet testnet and then interact with it uh using blog Explorer and a regular wallet so you have two links here at the bottom uh I abusing the guide today but in the startup book we also have steps for performing this as well uh so I'm gonna this ends okay so let me I'm gonna start a virtual machine so we can follow the steps from in the beginning basically so let me see in a sec to start this Ubuntu so this will install and start I just don't know what the VM starts and I log in share the screen in a moment okay I mean and I'm going to follow my in guidelines here so guys I just tried to set up my computer here with all the things that I need or I can start the Litecoin perfect in the meantime oh okay I'm ready how about a clean installation of from Ubuntu machine the instruction for Mac OS are very similar in the guide I put whenever there's a small difference I put their comment like an if else kind of blog so the first step is to install rust so to install rust you basically you follow the official instructions of how to install it we want the release version of rust so oops now why I can't like that so we need to just scroll to get it I mean let's see I can increase the font size of this I'm just going to proceed with the installation how is the font size [Music] um not that good if you can zoom in okay yeah [Music] let me know size column suppose custom fonts here I already changed it aha Crystal fonts and can increase it to a thing better now yes looking better what the what do you think guys they see it's okay perfect thank you very much make a little smaller yeah now well okay all right cool so I have Ross installed it asks you to activate some things on your shell so you can just run this source or you can just close the terminal which you're going to do and open a new one so the configuration takes place and just to verify that rust is installed at least rust up he do this version and yes so we have version 1.25.2 okay so raw seems installed as I mentioned when it rust to compile the car one compiler from source so the next step is to actually download or clone the the repo or the compiler for car one leads so I have this Commander here all right so this is the repo where the Cairo One compiler lives and I'm going to clone it to a specific folder on my on my home directory just called dot Cairo I just want to have a particular location that I can always go back to because we're gonna do some when I have to do some mapping of the binaries that's why I put it here so after quiet we should have it in the dot Cairo folder so if I come here right so we have appear in the in the replay store for car one so we need to activate a very particular tag the latest stack available in the repo because that's the the compiler that was used or supported right now by its Target so we need to make sure that we use the same so this is why we enable or activate this particular tag which is the latest tag on this Rebel story Target person 1.00 Alpha 6. right so we are in detached node in this particular commit of the carbon repo so now we can actually build uh all the binaries using cargo and using this command I'm sorry it went a little too fast just because yeah sorry David So Rajiv and also one of memory is our skin is we can sure pigments yeah um in the slides which I share with you at the bottom of the last slide where I have the live coding plan you have you see the reference and let me just put it here and suppose if you can share again the link to the slides of will be great oh okay all right link to the slides publish the web it's a links where do I put in the chat yes please in the chats okay so I put the chat the link to the slides and if you go to this last slide before let's let's start the setup you see a link to the guy and I share this link to you this is the steps that I'm following basically that you don't see on the screen and just using a secondary screen but you also have this target book as a guide it's just this is like when I'm following in this uh session you should turn see it cool thank you really all right so going back here all right just a sec an environment I'm trying to chat the link to the star net book where you can also see the comments please bear in mind that the standard book is very brilliant we're working on that but that part is finished Omar I just no I I will share the link right now there okay let me call the start of the book yes all right so the next step is to actually build the binaries right using cargo build and we use the release version of rust we don't want to use the the latest or the edge it's gonna take a while so it's a perfect time to answer some questions and perfect so let's see when will the minute support Karo one but my it's live it is supported already you can deploy it's right there's that problem okay so we're really sure that must take you much crypto nerds and right if and internal phonetic consumption from Ramsey from cover novel uh runs you were looking at that particular question with a no right but already asked internally to see if we can get an answer as soon as possible Ramsey thank you very much for that what are the benefits of the Caribou from a Shield versus serial TVs they have to be strong for DSL to win with solidity and thank you very much Paul Henry is the answer that the carrier is very specifically used by starnet yes exactly and the benefits are is that again that Taro is focusing only only onion scalability and this is something that the terrible machine is not focusing on they focus on our on our stuff like the centralization which is very relevant but the camera has the only goal of skinning theme so that allows to do certain kind of stocks that make us scale while having to follow all the rules of the evm which that are done for different purposes so the garbage machine should be able to allow for a foreign that will be the main benefit s you want to answer right now David mm-hmm which one um sorry for answering this a little bit late we have a lot of questions so tell us the skin most parties will probably be attracted to seriously and change because they are already bunch of selecting tips how easy would it be to transplant solidity to Cairo in the future is it better for bricks to transplant or to create native on a Starlet and if you allow me David hey there is a let me call here again founder of the stocks inventor of the stocks founder of Star Wars he said that indeed we'll have actually a Serial GBA Danilo is leading that development it is called back out which I Advanced already sure thank you very much Francois but and he said our Focus here is to scale gold using Kyle so the real skill is going to be coming from Cairo not from transpilers like the one we have warp will be transplanting solid colleague however building native color codes will be the real power of a stone so indeed and there's a lot of developers already for solidity but we think that developers can easily adapt for most of you I think you know at least two different languages I don't know maybe Python and JavaScript or something like that and so I I will only believe that that developers will have no problem learning care also aside from you also keep in mind that the standard gives you way more resources for executing transactions that you are that's possible on on the limitation of a gas piece in layer one so that allows you to create more interesting applications you can actually create things that are not possible at all to create on layer one so do you actually want to just transpile your contact as is you're going to be missing a lot of interesting features for example a kind of abstraction that doesn't that exist technically on L1 now but it's a little confusing because there's three different ways to have an account on layer one on Layer Two and started everything is a smart contract everything is using a kind of fraction or smart wallets so really the idea is that when you have a different environment with different constraints or less constraints you probably don't want to just rewrite the smart content exactly the same way it's in layer one and it's worth mentioning that any serial knowledge project following data virtual machine like the ckvm so we'll have the same constraints that means a construction for example okay do you guys know any open source project that had my Reddit free to Cairo so that I can refer to the codes you can let me show you the link to the starnet guido 101 which you can already do and it is it is called it's called us my way to kill once I guess also interesting uh I don't know if we have a project where we do it and and this thing so there are a lot of products my way to carry one but they're doing it's maybe not open source or experimenting behind the scene also origin I think will have soon their culture one so that will be very good but in the meantime I will share to you start get one-on-one tutorials those are very very very good for you to understand how to structure your code if you want to learn standard Cairo code you can learn with it but it is also very useful to learn uh the syntax and the way destruction reported so I will show it to you in the chats compilation is taking a while it's pretty intensive and also it's a virtual machine it's not my host machine so it has limited resources but we're getting enclosed perfect okay so DV says King way not both decentralization and scalability star disoriented more to the second one but I don't see the trade-off to live in the the first one and yes sure well uh correctly if I'm wrong here remind me that they bought a star that is having bought this decision from with you and the scalabic that is providing plus we will have the centralization in the in the there's there's no layer 2 that is the central list right now actually we're working on that we're working on deciding how we have civilization so we can decentralize the use of sequencers and so on but I don't know David if you want to to add something to this button no the goal is to decentralize everything right it's just it's a hard problem to solve so it took ethereum a long time to the right will take us a while also to to do it right so we need to approach it first let's let's see that the technology works and we can scale and then we can decentralize with that you have to tackle some big challenges once at a time to do it right but that's the goal to have it completely decentralized but then okay any other questions today that is great thank you very much for coming very happy to have you here I think those are all the questions that we can answer vibes we did it oh there's a question from Leo what are the most interesting use cases you are seeing off on chain apps that would benefit from being able to access more compute and by me this answering right now do you want to answer live Man meets let me yeah just like the hotel dropped in the chat one of the most exciting things that I've been seeing out here in San Francisco is uh the new push towards zkai because Ai and machine learning models are inherently very computationally intensive so being able to prove inferences so people don't have to run them all over again is actually quite a powerful thing um so so yeah that's that's one thing off the top of my head rather than the obvious scalability also if you have to follow along for going back to the previous question about digitalization you can go to the standard Forum that I put it on the chat blink where we actually post our thoughts and ideas of how we want to decentralize stagnets you can follow the discussion there in the proposal and you can comment or but it's yay anything you want to add they meet regarding star and Cairo ground and yeah again I don't know again if you want to share your Discord in the in the chat so we cannot you do that to the group we have a Discord in case you haven't been added yet please put your Discord there also join the terrorland community where it's uh or is also useful for in order to plan meetups you want to do some in your series or you want to talk with us you have any questions please let us know there all right good news uh it finished compelling and so we can move with the next step it's clear the terminal here so now that we have the carowind compiler compiled we want to add these binaries to our path right so we can execute this financial from any any place in in file system so an easy way to do it is just by adding to our configuration file for our shell in this case I'm using CSH it might be using bash so your Spotify is depending of your terminal if you're using bash will be bash RC just basically adding the path where we compile where the compiled version of the carbon compiler lives to our path so once with that uh I'm going to just close terminal and open again so the changes takes place and we're able to find the binaries so if this goes well we should be able to call this stagnet compiler just to see the version and something is called standard compile not compiler and there you go so we have the binary ready the binary is added to our path so we can use it to compile or Chiro One Smart contacts to Sierra so let's let's test that the compiler actually works so I'm going to create a folder just like a sample project we're just going to put a very simple smart contract and try to compile that so I'm just going to call this folder stagnet connect when I get into it and in here you're just going to create just like a test folder it and I'm going to create two folders just for usually I like to have one for where my source smart contract is and where the compiler folder so I'm just going to call the compiler for the Sierra so this is how my sample project looks like and I'm gonna create um a file for my sample smart contract inside of source let's call it sample.
cairo okay so I'll put the tree again I should see the file so let me open this with vs code a quick question is there some kind of pre-dinner or ES lens for Cairo prettier or eslint the closest will be this extension that we can install but it's not exactly as pretty because pretty is a formatter so I will say not yet something that he has linked the the extension will will work similarly but not like prettier than actually four months when you save or something like execute it here you go the soul I just gonna put a very simple smart contract right and just gonna basically we use this macro contract and then we create a module it's called Simple storage I for now today is not a goal to learn Cairo One just to make sure the tooling is working as you can see we don't have anything that's highlighting our tooling or ending because we haven't done yet the work of each other the extension but we have the smart contract so let's try to to compile it so here I can just don't stagnet compile and I provide the file example.ciro and then the output and it's going to be a Json file the output so it worked right our compiler is working this is how the Sierra looks like for this very simple smart contract good so we have confirmation that the compiler is working now a company for Cairo One Next Step will be to actually install install the vs code extension and this source code for that extension actually it's inside of the cairo1 repo so let's go back to that repo that we're storing Cairo and we have here a folder called vs code Cairo that we're gonna get into it right all right we have the right folder so first of all we're gonna need to have a node.js installed uh so in the case of Ubuntu a simple way to install it will be with this command there are multiple ways to install this I'm just going to use this to get the latest and node version 19 let me just expand this in more uh it's gonna work let's say so in theory now I can do pseudo apt update where I try to install it so now I can actually try to install node.js see okay so if it works well I should be able to denote M version and yes we have node version 19 the latest one installed on the computer so we're good to actually now uh compile the extension or just well when you use a JavaScript you don't really compile let's say you package it somehow so first of all we need to have installed a global package uh called vs code vs ese so this is what you do for component extensions so install it globally it's under this name ESC this is provided by vs code so remember it all everything is being reported and will be open YouTube so you will be able to will send you an email with the link so you can review everything that version right now yeah and the guy that I'm following also we have shared with you the link so your exactly what I'm doing is just documenting in a nice document there okay so now uh let's install the penises for the JavaScript with npm install remember inside of the vs code Cairo with the extension leaves okay that's let me just update my npm just in case that this is suggesting me to do oops copy paste oh I need to do sudo this is optional all right so now I can actually package extension previous to be able to install using this command package either we install this binary globally on npm now we can use it here this is just a temporary measure eventually the the the extension is going to be published to the marketplace and you will get it directly from vs Gold without having to do that but whenever we leave it at the edge so this is how it needs to be done right now so now we have the package we can actually install it with I mean sorry to vs code with this command right solid extension this is the file that we just created now we go ahead and in theory should be installed so let's try uh right so if I open the extension here okay I can see that is it is now installed camera one is called extension but we need to be configured because it's asking for where's the path for this particular binary the chiral language server this is one of the binaries that we compiled from using rust from source so we need to provide this path and to provide that path let's go back to [Music] that's going to be the target release let me just go back here let's go to Target this is where all the binaries are placed this is my absolute let's say path to it I'm just going to copy this I'm gonna put it here and slash with the name of the binary and I think it to probably close this and turn it on again so it takes see let me close the vs code and oops I need to go back to my workflow or maybe just open here and it's not taken okay now let's work now I'll get syntax highlighting and it's gonna complain just do some things wrong like in this case right so it's a nice helper when you write carowind code so cool so we have the vs code extension work yes sorry it's word measuring that as limit sets I want to repeat that that we're not learning learning Cairo right now but we will do and we will have a big chapter of the book ready for in a couple days so you can start learning Cairo by yourself and then we can come here and Away with more knowledge of scale and we also teach you something and also we have some tutorials like starving so we will share in a minute so you can start also learning yeah today is just about the the dev environment not really about Cairo but let me put a little more complex Cairo Cody here because we actually want to deploy it today uh oh my God fixed yeah all right okay now I'm not gonna really explain how this works we're gonna talk more about Cairo in future sessions I just want to make sure that we can compile this and we can deploy it to standard so let me just recompile this as we did before you ever go back to oh my God okay it's gonna copy this all right uh can I paste it here no anyway compile okay so we compiling the new version of the smart contract so this field is more more complex now as you can see here right way more complex so this is the code that we actually deployed to start net that we give to the sequencer the Sierra smart context okay so let's keep moving on the next step now because to interact with this target we used to use the starting tli the standard tli is written in Python so we need to have python 3.9 in particular to be sold in our system so to install a very particular version of python at least in on Ubuntu you will need a particular PPA and this one here every time if like this okay so I add this repository to my apt it's because we need Cairo sorry python 3.
9 we installed python 3.10 it might not work now I do update references and I'm ready to install python 3.9 using these two packages especially for development because we also need to have virtual environments thanks a little bit okay it all went well we should have now python 3.9 installed version yeah there it is you do have it so now let's actually install the Cairo CLI um so to use the carousel light install it we need to have one Global dependency called GMP so you can use that this command to install it this is required for the chiro sort of for the stagnant CL line on the calculator CLI you need this Global dependency now uh let's go back to our project we were working on and call it stagnet test and we're back to our project and I'm going to create a virtual machine here for sorry virtual environment for python so when I install packages I don't want to install it globally just want to sold it per project so to do that you do this command you define that you want a virtual environment the health and then you give it a name I'm just gonna it's called Cairo uh all right and then you activate that virtual environment so you can start installing Cairo Cairo pin activate so as you can see now we're inside of the Python virtual environment so we can install the Caroline package just before I do that I'm just going to upgrade pip to the latest version just to be saved and now I can actually install Caroline pip install which is going to give you the standard tli see and into sold for this particular projects uninstalled globally if you own a Mac this might fail I put some instructions on the guide what's the alternative command that you can run on a Mac because happened to me that it failed so I found the solution it's a more complex command but it works all right so if this is working so we should be able to execute the binary called stagnet which is the one used by the CLI and there we have it we have 0.11.
0.2 perfect so um so we'll use this target CLI in every command you will have to Define so which network you want to deploy or interact you use that with flags and also you need to Define which type of wallet remember that on standard every wallet is a smart contract and you have to Define to the CLI how the slide manager looks like and how this Micron is able to verify signatures so to be able a little bit easier for now I'm not going too much into it until we get to those sections I'm going to Define two environmental variables on my on my shell that the standard tli is going to use and gonna make us our comments look a little bit simpler so let me open the my profile configuration in case each RC uh what open right now go to the bottom I'm going to add two environmental variables uh one is to tell every time they run the standard command that always targets the test net Alpha curly instead of main it right I don't want to spend money right now and also to tell him because it's a kind of abstraction which type of wallet I want to use to sign transactions so uh using this one here okay so this would be export as well it's not export export actually this is using an abortion of the open sippling wallet okay this looks good so I should be able now if I I close my terminal and I open it again should be able to access these environmental variables we do Echo strike net Network there you go so it's installed it's available on our shell so now next step before we can deploy anything we need to create a user account in our computer because we need to pay for declarations and deployments so let's go back to our project for now and start net test let me activate again the virtual environment or python Pi or old bin oops activate Okay so take because like they're starting to CLI is only available in this python virtual environment so create a new account at least to get the address of our user account we use this command this target new account and we give it a name oops here right so using this the song CLI to create a new account in my computer and I'm going to give it a name the 0.11.0.2 right so I can add different wallets once they the network keeps upgrading so by doing that it's not gonna create the user account yet he's just going to give me the the address because the address is always it can be known uh before you deploy because it's just an algorithm that'll be always the same so this will be the address of my user account while I deploy it so I'm just gonna copy this one here and the next step is just I need to send test if to this account I need to fund my wallet even before the wallet exists on chain this is called the account counter factual deployment I think it's called this second feature when you have a kind of structure so I'm going to send a small amount of if to this address so let me open I think you should have should have a wallet here in this VM that I could use oh yeah I don't know maybe I don't yeah I have to send it from my so let me just bring this up um give me a sec to unlock my wallet not briefly without sharing my key or anything just a second all right okay so as you can see I have Bravos here another account which already has some tests eat on girly so I'm just gonna send some test if there so I need just to copy the the address and from here just gonna send some amounts could send 0.
05 test if I'm using Bravos it says that it doesn't exist on chain which is fine uh this is the counter factual depending we're going to talk more about that when we talk about a kind of traction in future sessions we're not just follow along all right so I've sent a transaction to starting to test net using my wallet I can follow a lot of transaction here on a Blog Explorer so we need to wait until the transaction gets at least to the pending State before we can continue so I think right now on test Nets blocks are produced every three minutes if I'm not mistaken that's where you see the counter so let's wait a little bit I mean because the font size we can see better so once we get to the pending state it means that I can actually I have the funds available on that particular wallet and I can continue with actually the on-chain deployment of my user account again this is a feature of a kind of obstruction hopefully we can make it easier for you in the future with tools like scarp that we haven't talked about it yet questions in the meantime Omer or people just post questions we have a question from Michael sorry Michael for the label apply he's having control combining there are a couple questions for you there Mike yeah argentin as you've seen a a log logo Michael and the second person is are you using what version of the compiler can you check started slash compile slash version please or if you're using scarp let us know scarb is using the the newest compiler version because I think there's a one with that part it will be nice opportunity to showcase faucets oh it's a good point yes you in this case I'm sending ether from another account that I have but you can actually use a faucet uh where is it tools faucet there you go I'm gonna put it in the chat link to the faucet where you just put your address and it will give you some amount it the faucet has the limitation that it has a limit of how much test if it can give you every 10 minutes so if I try to use it now I say oh you have to wait 10 minutes and I don't have time to wait 10 minutes that's why I went the other way but if you are more patient you can use it this way you will get some tests if on your address okay so now that we have yeah oh my gosh okay go ahead let me mention is something very important in the chat but we can work ahead and measure it later okay so now that I have uh test if associated with this address I'm actually gonna deploy my user account which is a smart contract to this address so let me get back to my notes put in my secondary screen okay okay okay so to deploy my user account just clear the screen here I use this command so again you see the standard CLI now you see the deploy account command uh always using this particular account that I created before the one that we know the address so if I do that it's going to actually deploy my user account to test net and you can see it's so it sends the deploy account contract transaction so we can follow along the transaction using this hash on stock scan dark scan you that's that put here the transaction hash because we need to wait until it gets to at least the pending State that's when we know it it's ready to be to be used because what we really want to do is to deploy the the cairo1 and smart contracts that we were I showed you before that we have in vs code okay so it's not the pending state so now we technically have now uh a user account that we can use to deploy and to invoke transactions cool let me just clear here and let's go back now so before we can deploy a smart contract understanding you have to first declare it the reasons people explain it in the next session but for now we're gonna execute this command I'm just going to try to explain what it what it does so basically it's going to upload our Sierra the Sierra code of a smart contract using this account to pay for fees for gas fees and declaring is the previous step before you can deploy because on a study you can deploy multiple instances of the same declared code without talking more about that when you go to account strategy for now I just follow along so when we try to execute this send this transaction to test net it's gonna fail because this smart contract was deployed was declared before actually by me so you should tell me there's an error yes and the error is that says the class hash the blah blah blah is already declared right and that's what I was expecting that's fine it means that I can just go directly to the deploy I don't have to declare but because sometimes you don't know it's better to just try to declare and see if it fails you can move to the deployment so oh wait did I copy what was the address that I used the address of my account just a sec I had to find out which addresses send a account or Customer Center address sorry just a moment right yeah I forgot to take note of what was the address of our user account and now I have it because we need to send the deploy transaction uh let me try again to declare because I need to take note of the of the class hash which I didn't do before so so that will are having trouble using the you see the full set so it's very understandable we are sending you which or David do we have a method to send it needs without using the faucet right now not right now uh there's something we thought right now how to how to do better because we know that faucet has a limitation yeah so we have a lot of people right now asking for it yeah no it's not something that we that's why we yeah we kind of knew but it's hard to get around hopefully that's one of the things that we need to improve for next time we do a base camp for sure so to deploy the smart contract we need to provide a class hash that is provided here in the previous account I'm just going to remove this because this is that previous thing that I did comment and the class hash is here and with this we should be able to deploy our smart contract okay so the transaction was sent or deploying or smart contract we can follow along here I need to remember to not delete anything from the terminal because I need those addresses uh paste okay so this is transactions to deploy the smart contract that we wrote in Cairo One so we need to wait until it gets to the pending State before we can actually start interacting with it so let's wait a couple of seconds the only question in the meantime Omar nope nope Michael is asking will there be a gross based CLI and the answer is yes that would be it will be strong but don't but don't worry the plate on what is going to be working but and it's going to be the same uh also a lot of people are asking for it making my meat if you have some heat and you can help me send to Thomas please that would be great in the meantime that you know that all the translations that I made I send you the address the the date and you should be able to find it in your now you can deploy your wallet because the transactions were successful so you can deploy you do about things yeah so our smart contract has been deployed so we can actually now interact with it because we know the address this one and if we can see you can see first of all there is a car one smart contract and we can go to the read write section and if we compare it to our code you can see that our smart contract had two functions one to increase balance and one to get balance one two this is read only this is for modify the state and if you see in this Explorer you see they get balance right now it's going to be zero because it has no value but we can actually use the right to increase it I'm just going to collect oh the connect the wallet wait a sec that's one thing that I didn't prepare for to install a wallet here so let me just do it on my Mac copy yeah while leaving the screen this uh rafaeli says we Bridge girly it to start yes we can you can ask you can get some eats for example you see enough faucets and remember the name Paradigm has a faucet that can give you girly eats to layer one so you can send it to your metamask account for example and then from there you can reach it using the bridge but I will send you the link in the chat and you can reach it to the uh actually Clement already short Bridge thank you very much equipment Stargate dot starnet.io it is on the chat so you can use that to reach to connect your metamask account to your Parables or rdn account and then you can bridge that it to your account so it is relatively simple yes and sorry just gonna go back to questions after so I think some people might be leaving right now most of the time so is there any question what is it sorry what is the the homework is there any homework or next Sunday in the email I'll send an email with the instructions okay ladies and gentlemen thank you guys all right so I'm just gonna uh send the value 10 to the increased balance used in my wallet I'm gonna start this transaction and then we wait a little bit until it gets to pendant state so we should be able to do the the read operation and see the value of 10 coming back so it's way a little bit let me see what questions we have when will the minute support everyone okay we answer that one somebody oh are we are we sure Omar that is deployed to Cairo One um two minutes because Michael is saying no no it seems like uh it's a little bit more complex like in the the like a contract has to be interested for a while and then it can be uploaded to the maintenance so we cannot do it right now coach I didn't know that foreign state which is a little bit it means vlog while we wait for that and Anonymous attend this skin is having an error while deploying the account it is called it started error called uninitialized contract it is likely because you haven't sent it to your account you first have to send to the address of your account date and then you can deploy it is sorry I thought you were finished I query the balance again now I get the value 10 so to confirm that actually our transaction went through and modified the state of smart contract so now we can read the new value so that concludes the tutorial to settle the environment it's a long one it's a complex one again Chiro One is fairly new um so hopefully just to do a brief summary we had to install rust Python and node.js we compile the car one binaries using rust then we configure those banners to be available anywhere uh add into the to the path then we install also Cairo Lang and we sold python to be able to execute Caroline and we installed the vs code extension as well so you get this nice syntax highlighting and some easy errors to spot there when you write uh thank you very much for staying so long it was supposed to finish a while ago but it took longer hopefully it was useful you have the guides there and if you have more questions please use this score and hopefully you will be able to use the faucet eventually and get some tested yes also if some some of you are not able to to get some it let us know please in the telegram so I sent it to as much people as possible I I run right so so I will need to recharge but let us know if 10 are Blitz I won't be able to to store all your addresses right now but send it to the telegraph or Bridge it and thank you very much to do Clement who help us a lot in this also Glenn thank you very much and Glenn mentioned also something very important that you have to change your contract cash okay no words we'll see the next the next time and we'll add to the book so thank you very much folks thank you take care see you next week bye
Automatic transcript — names and jargon may be misspelled.