Solidity 101 in Hindi: Updraft Study Session, Part 1

Cyfrin Updraft Solidity 101 Study Sessions — Hindi · 1:57:18

Begin Solidity with Syed Asad Kazmi in a live Cyfrin Updraft study session, taught mostly in English with some Hindi. The workshop introduces smart contracts, then follows a SimpleStorage example in Remix through compiler setup, variables, functions, visibility, scope, gas costs, and the difference between view and pure functions. Learner quiz questions are answered in the chat. Prior programming experience is not required.

Speakers

Topics

From Cyfrin Updraft Solidity 101 Study Sessions — Hindi, hosted by Cyfrin.

Transcript

We are live. Okay, sounds good. Hello everybody. Hello. Good morning. Good morning. Welcome everybody. Hi. Hi Gulam. Gam Rasol. I see so many good people here. Vivec if I am reading it correctly. Gulam Sidart. Uh so hello everybody. Can't wait to Yeah, me too. VC we are already here. Thank you so much for joining us today. I am also so excited. I hope you guys are doing okay today. Okay, you know what? Uh I'm going to introduce you to a superstar actually and a king of web three I would say and also I'm going

to introduce myself and we will be talking about cypher ambassador program. We will be learning solidity 101 today with you guys and in your local language. I am so excited. Okay everybody, my name is Ilif and I am currently working as a debra leaded cipher a company that steeply uh focused on smart contract security education and building a more secure web3 ecosystem for you guys. Today I want to tell you a little bit about something very close to my heart actually the cipher ambassador program which maybe you already know that because s is one of the best ambassadors uh like the others this

program isn't just about hosting events or hosting content or something like this. This is about empowering the next generation of security-minded developers, researchers, and actually community leaders all around the world. Guys, we're looking for people who are passionate about blockchain security education community uh developer community. Whether you are a developer, student, engineer, or just someone who wants to make an impact, you are welcome to apply. I'm going to just send you the link for this in a couple of minutes.

And during this time, by the way, once you are accepted into the program, there is one just key step, you will need to complete our SSCD plus certification that is smart contract uh security developer plus within six weeks. You will get six weeks to get certified. It is essential because we want everyone in the program to have a strong foundation in uh secure smart contract development as well. Once you are in, you're not alone. Say will be there with you. Hema will be there with you. I'm going to be there with you. We have really nice team there. And actually we are not just teaching code, we are building a moment with you all guys. And also I'm going to

talk about cipher updraft course as well which you already know that one of the me most exciting parts is that it is free for everybody and today uh as a part of updraft study session you will be learning solidity 101 in your local language with say thank you so much again say can you please please please introduce yourself and then we can just get started with the team and I'm going to send you guys the uh resources SSCD plus certification resources an ambassador program application form.

Welcome. Let's get started. Thanks say for joining me. Yeah, thank you. Thank you for a great introduction, Alif. So, my name is Sagy and I'm like the very first ambassador at Ciphin Updraft and like I was quite inspired. I'm actually quite inspired by Patrick Collins and guys like Alif and Kiara at Ciphin. So it's really like motivating and exciting to be a part of like this amazing community at Ciphin and Ciphen updraft. So looking forward to like teaching you like whatever I can and then hopefully we'll build web 3 safer together. Yeah.

Yeah. Awesome. I think we can just get started in your local language. Feel free to speak in Hindi actually. No worries. I'm going to be there to support you guys. If you have any questions, if you want me to be here and say, this is your call today. Thank you so much again. Yeah. Yeah. Let's get started. Uh I think everyone needs to create siphon profile first in my opinion then use your remix for on your computer actually because it is a practice today. We need to practice it together today. This is your call everybody. Okay VC, I can feel your energy though. Let's get froggy. Yeah, exactly.

Okay. So like first of all I think like it's great to know like if you guys tell me like from where exactly you are joining from which part of India from which city? Yeah if actually you are on mute. Yeah. Yeah I'm here. Okay guy everybody uh you know what I am I'm from Turkey. Turkey actually you know they changed the name internationally and maybe you are already know this you already are familiar with this but Istanbul is not the capital city and I was born in Ankara you know the capital city yes um yeah I'm from heard Turkey you are from Pakistan say by the way which part of India you're coming from yeah I'm

from Delhi New Delhi that's good that's good anyone anyone from Delhi Okay. I think most people are from Hyderabad, Duttra. They are saying, "Yeah, someone is from Spain though." Yeah. I mean, we will have the Spanish version of therapist Asian. Just wait for two or three weeks. Okay. Yeah. So, like shall we get started? Yeah, of course. Okay. Feel free to speak in India, Hindi. Yeah. And uh I'm gonna be there. Uh actually I'm going to be sporting you. Uh I'm gonna just mute myself and stop my camera, but I'm here

stage just for Yeah. Yeah. Just to support you. Okay. Sure. So hopefully you are guys you guys are

already on this siphon dashboard and here you can see like I'm logged in with my profile. Just this one to over here. Okay. So like once you come to this cipher updraft uh

website then you can just go to the courses section and then we will be covering this solidity smart contract development. So like we will continue this conversation in like mix of Hindi and English mostly follow so that the guys who are coming from Spain and all can also follow up with us somewhat. But yeah as Al if has mentioned there will be separate sessions in Spanish language as well. So I will try to mostly cover it in Hindi or English.

We can say mix of Hindi and English. Yeah. So first of all we can just play this. Welcome to solid solidity fundamentals. So you guys can also play it on your end and then quickly get started. Let me just speed it down a bit. Okay. So like that's the first lesson. I

hope you guys have watched that. Now we will move to this. This lesson is slightly bigger. Yeah, make sure to pay attention to the best practices because the best practices would be like beneficial for all the courses that that are there in the cipher of draft. I think they don't hear Patrick though say

[Music] okay so like I need to mute myself you think or let me check. No, we don't we don't hear that still. Yeah. Yeah. Is it audible now? No. No.

We don't hear that yet. Did you enable you though? Yeah. Did you Did you enable your desktop audio though? Okay I think hopefully it'll be fine now. Is it audible now? No, we don't.

Nope. Uh let me let me answer the questions. Actually I had a question only is a pretty person. Okay. No. Uh cyber right.

Okay. I can't hear you though. Uh don't know. Um did you Yeah, I can hear you now. Okay, sounds good. And then I will also answer your questions, guys. Just a minute. Let's handle this. Uh say can you just start the video again and then like uh your website is sharing your voices. Yeah.

Okay. Let's make sure. So like from the settings like I have enabled like like in the audio I've enabled the mic volume is full. Yeah, in the speaker like I have selected AirPods. So like when I'm selecting the laptop then it's not like like I'm unable to hear you but like are you like are you guys able to hear the Patrick's voice? I'm not sure. Steam stereo audio is disabled I can see. But yeah, it's just showing eco cancellation must be off to I can also try to share my screen. Wait

a minute. Okay, let me stop sharing. Oh, wait. We hear that. Do you do you hear mine? Wait a minute. Let me let me let me share mine. Uh share screen. Wait a minute. Okay, guys. Guys, do you do you see this or hear this? I mean, I didn't uh Yeah, I can see I can see you see it, right? Do you hear this? Say it. Wait a minute.

No. You hear that? You're on like on the like on the studio. On the studio I'm unable to hear. But let me just check on the YouTube as well. No, I'm unable to hear audible. Interesting. Like there's a section here that shared the voice and notifications as well and I clicked it but weird. Let me try again.

Do you hear this uh say by the way now section of code that when called will execute okay sounds okay sounds good okay guys I'm starting it from scratch by the way say you can do the same thing I just realized what we are doing wrong actually uh when you want to share your screen for example It asks you to which and like if you are sharing your entire screen or a tab. You need to share your tab actually not screen or not window. You need to share your tab. Do you want to try?

Yeah. Actually like sure let me just open a draft in this tab itself then. Awesome. And if it doesn't work I'm going to be here and share my screen. It's okay. But you can also try again by yourself. Sure. No problem. I saw some Turkish people here interestingly. Hey, G. What's up? Yeah. Um, we're going to continue in English, in Spanish, in uh in Arabic, in Turkish, uh, a couple of more language and in Korean as well. By the way, we're going to have the all uh language as soon as possible, which is great because you guys I mean there's a great uh

opportunity for us here in my opinion because there's a gap there's a really big gap like all educations and trainings are English and sometimes the local people are not familiar or they are not native in English. This is why we are trying to teach you guys in your language in your local language. Yeah, this is why you will join all the session. Okay, sounds good. Sounds good. And and there was a question by the way say are you ask are you sharing your screen now? Yeah. Yeah, just sharing. Okay, no problem. Yeah, I'm going to be here. No worries. Uh there was a question about the certification as well if I remember correctly guys. Yes, you have to finish the solidity 101

blockchain basics uh course on updraft and also uh foundry and advanced foundry and devops uh devops as well. By the way, I feel like five or six educations course on updraft and also when you click the certification there is a tip there you have to finish this courses that kind of tip you can see it I added it to the stage by the way say it I think we we are seeing it okay let's listen if it works Welcome to the Solidity fundamentals

course. Sounds good. Solidity, as we mentioned in the blockchain basics course, is the most dominant smart contract programming language. And once you get the skills to code Solidity and work with Solidity, you will be able to go out and become a smart contract developer, security researcher, and enter this blockchain world as a very technical person. I'm so excited for you to go through this because these are the steps that will make you a phenomenal blockchain engineer. So, welcome to the Solidity Fundamentals. Myself and Kira will be the instructors for this course. And if you missed these already, let's once again start with the best practices for working with this course. Okay. So, like let's move to best practices section. So, the best practices will come handy in each and every course on cipher draft. So, you

shouldn't skip. So, let's begin our journey by talking about some best practices. That way, you can get the absolute most out of this course and be as effective as possible. Now, you're either watching this on Siphon Updraft or on YouTube. And I encourage everybody to watch us on Siphon Updraft because we've got a ton of features to make the learning experience that much easier for you. So, if you are watching this on Siphon Updraft though, there's a couple links I need you to be aware of. The first one in the top right is going to be the GitHub resources page. This will bring you over to what's called a GitHub repo or a GitHub repository or basically a site that has all the code and all the information and basically all the materials that you're going to need to learn. So like that link might move I

think to here like in the resources section uh like when you click on that then you will see these two course resources and discussions. So like due to the updates on this website, I think that's a small change. Uh you guys can easily follow up that learn everything in our curriculum. You could basically think of this as your bible for the duration of your blockchain developer journey. Additionally, in this GitHub, there's a discussions tab right here that you can click on. And in here is where you can ask questions, discuss with other people taking the course, interact with members helping out, and it's where you can discuss anything that you're having trouble with. Then on the other side, you'll see this tab called written lessons. If you cannot stand the voice coming out of my mouth, you can just

flip over to that and just read the course curriculum as well. If you prefer the written content over the video content, and it's good to go over to the written lessons anyways to maybe copy paste some stuff. If you scroll down here, right now it's blank, but if anytime there's an update to a video, something's changed in the video, we haven't swapped out the video yet, you'll see a little updates section with information saying, "Hey, the video says this, but you should do this instead." Now, like I said, this is a very fastmoving industry and sometimes things change and sometimes things need to be updated. So, when you're watching one of these videos, be sure to look for the updates tab at the bottom. And then, additionally, whenever you're working with the code that we're working with, I will give you a link to the finalized

edition that you can use as a reference as well to make sure that the code that you're working with actually is going to match what we are going to build. Additionally, if you think you found something that is different or doesn't quite work, be sure to make a discussion for it in that GitHub repo. Like I said, it's going to be your Bible. Additionally, there's a link to join the GitHub discussions. This is your platform to ask questions, engage with the community and learn with both other people taking the course and also our TAs who are going to be helping you out along the way. Additionally, there is a link to the Discord for more real-time communication. I urge you to ask questions in the GitHub discussions as well because those are going to be indexed, going to make them much easier to Google search later and have them

show up as opposed to Discord. Discord is still phenomenal for you to join them. For those of you watching on YouTube, hello. You should scroll down to the description. And in the description are going to be links to these resources as well. And additionally, a link to Siphon Updraft. If you've been watching, you've already seen some of the advantages that Siphon Updraft has, including written lessons, single videos, and there's also ways to track your progress instead of having to scrub on a giant YouTube video. So for all of you who are watching this on YouTube, definitely be sure to go over to Cipher Updraft, sign up there and watch the curriculum there because your learning experience will be much better.

But leave this video playing in the background on YouTube so we get the bump from the YouTube algorithm. Thank you. That being said, as we go through this course, we're also going to teach you some best practices on working with artificial intelligence, how to best prompt these AI so that they can give you the best results. Just keep in mind they sometimes get things wrong and it's a good idea if you are going to use an AI to fact check it with a human or another resource. So be sure to say hi in the discussions and maybe meet some like-minded peers. And additionally, once we do get to the coding portion of this course, it's a good idea to code along with me as I'm explaining things.

So having the video up as well as your coding screen is a good idea so you can follow along with me as I'm explaining it. If you're watching this on siphon updraft, you can just click the little video pop out button and have the video pop out as such and code next to it. All of this is to say if you run into an issue, jump to that GitHub repo and make a discussion. We will also be giving you some tips very soon about how to best make a discussion. Yes, asking questions to other human beings is a skill and we're going to try to teach you to be the most effective because asking well formatted questions is not only the secret to being a fantastic AI prompt engineer but also becoming an incredibly successful developer. We're going to learn how to ask well- formatted

questions and whenever we post on discussions or forums or whatever, we're going to work on formatting them as best as possible. Take breaks. I cannot tell you how many people have tried to rush through these courses and be like, "Oh, I'm going to finish in a single weekend." Your brain doesn't work like that. Your brain needs time to absorb the information. So, take breaks. Maybe every 25 minutes to a half hour. Take a 5 minute break. Or maybe you like working in longer chunks. Maybe take a whole hour and then take a 15- 20 minute break. Don't try to rush through the whole video in a day. You're not going to retain the information. Go outside, go for a walk, grab some ice, get some coffee, go to the gym. Your brain needs time to have the information settle.

Maybe every two hours just step away. Maybe be done for the day. Work at whatever pace makes sense for you. Everyone's going to have a different learning pace. There is no right speed for this course. I've had people take my courses in 2 weeks, in 3 months, in 6 months. It doesn't matter. Pick a pace that you can do and stick to it. Not only work at your pace, make sure that I'm talking at a pace that makes sense for you. There's a little gear icon in the YouTube video here where you can change the speed of how I'm talking and how fast the video is going. So, if I'm talking way too fast for you, then you can slow me down. But if I'm talking too slow, then you can speed me up. And if you're watching this on Siphon Updraft, you have the same dials as well in the

bottom right hand corner. Additionally, if English isn't your native language, we have seven different subtitles in the Siphon Updraft video player as well. So, make the adjustments you need to make me go the speed you want me to go. And of course, this course is modular, so you can bounce around topic to topic and go to where you want to go. If you don't want to do any full stack stuff, then skip that section. If you want to go right to the advanced stuff, do that. Like I said, go the pace and take the learnings that you want to do. And after every lesson, it might be a good idea to go back and reflect on each lesson to really make sure the knowledge gets ingrained. Repetition is the mother of skill, and we're going to be repeating a lot of smart contract development. Now,

the last bit here is in the Siphon Updraft platform, we're going to have quizzes that you can take to help see if you learn the knowledge that you were supposed to learn. If you're watching this on YouTube, you don't have that. So, go sign up for Siphon Updraft and then play the YouTube video in the background so the YouTube algorithm bumps us up. But additionally, at the end of every section, if you go to the GitHub repo associated with that section and you scroll down, there's going to be a bonus NFTts section with a link. This will bring you to a coding challenge on chain that you can actually solve to mint yourself an NFT, a badge of honor, proving that you gained the knowledge that you were supposed to. These are optional challenges that you can do to try to make sure that you actually

learned what was meant to be learned here. And if you do solve them, you get a very cool NFT along with it. Don't know what an NFT is? Don't worry, we'll teach you later. Blockchain development and open source development world is incredibly collaborative. So be sure to use tools like of course the GitHub discussions tab, Ethereum stack exchange, the decentralized Q&A forum, Piranha issues on different GitHubs, artificial intelligence, and more. And like I said, we'll give you more tips on how to most effectively use these sites in the future. And the reason I'm putting so much emphasis on this and that I will continue to put so much emphasis on this is being a successful smart contract developer is more than just knowing how solidity works. Knowing where to go for information and how to collaborate with people is often more important than your smart contract

knowledge because oftentimes you're going to run into issues you don't know how to solve. So, we're going to teach you to unblock yourself on this and really anything in life. Plus, syncing with other people in the space makes it way more fun. You are muted. Say it. We don't hear you. Okay. Okay. So, like what I was

saying like before moving to the next lesson, it will be great if we can know like like it's good to know what best best practices you guys have learned from this video. What are the best practices best practices Google meet? It will be great to know in the chat like just any like each guy can share one best practice that he has learned. Anyone? No one is typing in anything in the

chat. Yeah, Gulam has typed leveraging using AI. Apart from that like I want to know like what best practices you guys have learned from this video. Vive Okay. So like apart from AI I want to know like AI is good. Yeah. And it's getting better day by day. Yeah. That's a great practice.

watch the videos according to your speed. So like you can slow down and and particularly with the speed I think months cover 3 months and some can cover it in 6 months some can take up to one year like who are working somewhere else then they can they can they usually take more time in covering. So yeah definitely take breaks is a great point as well. join community. So hopefully all the guys in the chat have already joined the siphon discord. So Alif, it will be great if you can share the cipher discord link in the chat as well. So Vive, what exactly do you mean

by I used to add more code? I think you you you mean to say that adding your own test cases and all if I'm not wrong, right? and adding your basically playing around with the code that Patrick presents uh in his tutorials. Yeah, that's great. Okay, so you guys should definitely join Discord and it's like a one-stop shop for everything whether be for updraft or code hawks or cyber audits. So we got some great answers from Gulam and Vive. And one more thing that I want to point out is

to search on like the to ask questions on platforms like Ethereum stack exchange so that like as Patrick mentioned so that the question can be indexed on the internet and whenever like a guy who is like watching the course after a while then whenever he faces the same problem and he searches for that problem then he can easily find that problem over there. So like to basically search engine optimization if we can say to improve the SEO of that question. So let's move on to the next lesson which will be our simple storage smart contract in Remix. Before we get started an

important note the GitHub repo is going to be the siphon/foundry full course that we work with. You may see references to a GitHub repository with a different name such as FoundryFocloundary Focus, but this is the GitHub repo that you should be working with. Sometimes the names of our GitHub repositories or these links will change. So, just be sure to use the GitHub resources in Ciphern Updraft or if you're watching this on YouTube, the links that we provide to you so that you always know that you are on the correct link. Now that we're getting to the coding part, I need to stress to absolutely use the GitHub repository or go to the GitHub resources associated with Cipher Updraft. If you're on the GitHub repo right now and you scroll

down to this section down here, welcome to Remix Remix simple storage. And this is going to look a little bit different when you come to it. You can click on the GitHub repo associated with this lesson. This will have all the code that we're actually going to be working with for this section as well as a readme section which is going to have a lot of notes on how to actually work with the code. And instead of making issues and discussions on this repository here, if you have an issue, please use the discussions tab of the Foundry full course here or use any of the areas that we've laid out in the questions section.

We're going to teach you how to ask questions so that they have the highest probability of being answered by either somebody else in the community by an AI or by a forum. Additionally, please be sure to check out web3dev.education for more information as well. I highly recommend that you pause the video right now and make accounts for first of all GitHub and then at least stack exchange Ethereum. Additionally, chatbt is a great resource to make an account for. Just remember that it will often get things wrong and isn't quite up todate. Find you don't need to make an account for, but it often gets things wrong sometimes as well. Typically, for each coding section, I will give you a brief rundown of what we're actually going to be building. And in this lesson, we're

going to be building this exact smart contract, and we're going to be building your first smart contract ever, and we're going to deploy it to a blockchain. At the end of this section, you are going to have deployed your first smart contract ever. So, be sure to get to the end so you can deploy your first smart contract. We're going to be using something called an IDE called Remix to deploy and interact and work with this smart contract, which is going to be very exciting. It's highly recommended to get the best experience out of this is for you to follow along and you to code with me. You can change my speed on the YouTube video if I'm coding too fast or I'm coding too slow.

But you taking the time to write out the code as I code along with you is going to ingrain the knowledge into your brain. Repetition is the mother of skill and I want to make sure you come out the other side with skill. To actually code this, we're going to be using a tool called Remix. You can either Google search it or you can just come to the GitHub repo or web3dev.education and click this link to remix which will pop open the Remix web ID. So, let's go ahead. Let's jump in and let's learn to deploy our first smart contract. At the end of this lesson, you will have deployed your first smart contract. You'll have written your first bit of solidity. And we are very excited to get through this part.

So like I hope you guys have opened Remix on your on your devices. So it's available on I think remix.ethereum.org and you can simply click from the GitHub resources as well. if you are facing any problem. Uh I think somebody's asking Vive. So like for simple testing I usually use remix itself and uh for like but yeah lately I'm trying to use more and more foundry like basically spin up

a simple foundry smart contract and write test cases because I think that's what the legendary coders like Patrick Collins themselves do. So foundry will be a great tool like if you want to basically deep dive into the smart contract journey particularly like the security space and all then I think foundry will come handy but yeah for beginners for and for uh like if you just want to try something then I think remix is also a great option but remix or foundry found yeah sure vive feel free to ask then we will move to the next Here you go.

Yeah, actually definitely like like front end is not everything. Uh like if you know back end and like all the other stuff then you can like definitely get a role like similar role. So like there are a lot of roles in any industry. Yeah. Actually me too. I also hate front end and even I think Patrick Collins also. So generally like the back end oriented guys who loves to build logic and all are quite like not interested in building the front end and UI part but yeah the design guys who love drawing and all are usually great in front end.

So welcome Rdanat from Kolkata. So let's get started with our you guys can keep asking questions in the chat and I will definitely pick them up. Welcome to the Remix IDE or the integrated development environment. This is where we're going to learn to write a lot of our code in the beginning. If you want, you can go ahead and accept to help out Remix here. And if you've never been to the Remix website before, it'll give you a tutorial walkthrough of some of the features that Remix has to offer.

For example, it has a Solidity compiler. Solidity is the programming language that we're going to be using in this course to code our smart contracts where and we need to compile them when we've written the Solidity. We'll learn about that in a little bit. We have a tab here where we can actually deploy our contracts to a blockchain. And we have all these different folders and scripts since we can actually write JavaScript and TypeScript in Remix as well. But don't worry about those too much for now because I'm going to be explaining everything that we're going to do. Remix is an incredibly powerful tool because it has a lot of features that allow us to really see and visualize what our smart contracts do. Eventually, we're going to move off of Remix to a local development environment. However, Remix

is a tool still used by some of the top auditors and smart contract developers in the space when they want to quickly check something out. And additionally, it's fantastic for learning the fundamentals of Solidity. The left hand side is where we're actually going to start interacting with Remix. If we bring our mouse up to the top, this little file explorer is where we're going to have all of our files and where we're going to write our Solidity or our smart contract code. If you want, you can leave all these folders in here, but I'm actually going to go ahead and delete everything so that there's less for me to work with or or deal with. I'm just going to go ahead and rightclick and delete everything in here just so I can start completely from scratch.

Again, if you want to leave all of these in here, feel free to do so. Doesn't matter. I just think it's cluttering up my mental space a little bit. Now, we have a blank Remix project. And the first thing that we're going to want to do is create our first file to start writing and deploying our Solidity smart contract. We're going to go ahead and click the create new file right here and type in simple storage.souls soul tells our compiler that this is going to be a solidity contract, a solidity file and we're going to be writing solidity inside of this file which again solidity is the most popular smart contract programming language. And you'll see we actually get popped up a simple storage.soul on the right hand side which we can type in and

actually write our solidity code. Now right below the file explorer button is a little search icon which allows us to search for different code in all of our contracts. So for example, if I type in hello in here and I copy that, paste that into the search bar, hit enter, we can see that it found this line hello in our simple storage.soul. Let's go ahead and delete that. Right below that search icon is this Solidity compiler and you'll see a bunch of different stuff pop up which tells us about our compiler configuration and we can see even more advanced configuration if we hit the drop down. We're not going to hit that for now. Let's go ahead and double click the solid compiler over here so we can just see the simple storage. Soul. I'm

also going to click this hide terminal button so that we just see our simple storage. Now, the first thing that we want to do in all of our Solidity and smart contracts is write the Solidity version that we're going to be working with. Solidity is a constantly changing language, and we want to be very specific about what version we're going to be using to write our smart contracts as each version does different things. To write your version, you're going to do Pragma Solidity and then type your version. For most of this course, we're going to be using 0.8.19 8.19 as that's the most current edition of Solidity. However, getting used to working with different versions of Solidity is really good for you as you're going to be working with different versions of Solidity no matter

where you go. Certain versions of Solidity are considered more stable than other versions. Right now, there's a popular tool called Slither, which recommends using 0.8.18. So, if you want to default to 0.8.18 for this course, feel free to do so. We're going to be using a couple different versions as we code. So, this line says we're stating our version. Now, these two slashes here stand for what's called a comment in Solidity. And this allows you to write anything after the two slashes. And when we compile or run our code, it will just ignore what's in here. So, we could type blah blah blah, whatever we want. Cats are cool.

And it doesn't matter. You can write anything in here. I highly recommend as we're going along, you should write comments in your own code as well for you to refer to later on. And additionally, feel free to copy all the code that you write and paste it locally so that just in case your browser cache refreshes or something, you won't lose all the work you've done. So, so before you lock off for the day, copy paste this into a text file so that you can have it for later. But a good comment for here might be this is the version. Now, writing our version like this in Solidity tells the Solidity compiler that we're only allowed to use 0.8.18 when compiling this. However, maybe a new version comes out and we're okay to use anything newer than this version. To

tell the compiler that, we add this little hat, this little carrot, which says this contract only works with 0.8.18 or anything greater than that. This means 0.8.19 would work. When 0.820 comes out, that one would work. However, 0.8.17 would not work if we were working with 0.8.18 or above. If we don't have the carrot, this tells the compiler that only 0.8.18 will work with this code. If we want to use slotted versions within a range, we could do something like this.

We could say we want our version to be greater than or equal to 0.8.18 but less than 0.9.0. This would tell the compiler that any version between these two is a valid version. For example, 0.9.1 would not work. Neither would 0.9.0 because these are not strictly less than 0.9.0. Great. So now we know how to do compiler versions. Now the next thing every smart contract needs to start with is something called the SPDX license identifier. Now this actually isn't required by the compiler.

It'll actually throw a warning if we compile and it won't error. It's fine if you don't have this. However, it's highly recommended. This is a way to make licensing and sharing code and IP of your contracts a lot easier from a legal perspective. I have a link to more about how licenses work in the GitHub repo associated with this section of the course. MIT is known as one of the most permissive licenses. It basically means anybody can use this code and pretty much do whatever they want with it. I wouldn't worry too much about the licenses right now, but let's actually go back to 0.8.19. And on the left hand side, let's scroll down to this compiler button and open this back up. Even right now, now that we don't even have any code, we can actually go ahead and compile this

contract. Now, you might see a red squiggly and you might see a warning here, but don't worry about that for now. To choose our compiler version, we scroll up to this section and we can choose the compiler version that we want to work with. Most of the time though, if you just hit compile simple storage.soul or you hit this big compile button, it'll automatically choose the version for you. Example, if I scroll down, but I hit compile, it'll automatically flip up to 0.8.19. And we were able to go ahead, we were able to successfully compile this code. Now, it says no contract compiled yet because we haven't put a contract in here yet. We just put the version of Sludy that we're working with. Compiling our code means taking our human readable code and transforming it into computer

readable code which is essentially a bunch of zeros and ones or it's bite code. Computer code is very specific instructions for the computer to use or in our case the blockchain to use for our contract. We'll learn later about machine level code and op codes and EVM codes in a much later section of this course. Additionally, you can hit command S or control S which will also save and compile. You'll see I kind of have a trigger finger and I will out of habit hit command S all the time because as somebody who codes a lot I need to make sure I save all the time otherwise things might not work as intended. As you saw if we use a different version of Solidity and we hit the compile button it'll automatically flip back. But for example, let's say I wanted to use

0.8.7. Anything greater than that and we're on compiler 0.8.19 and we hit compile, it won't change. However, if I use something less than 0.8.7 and we hit compile, it'll change because it wants to automatically select a Solidity version that is appropriate for the version that you chose. Again, I want to use 0.8 and I'm going to hit compile. And we're good to go. Now, we're going to go ahead and start writing our contract. And to get the full screen view again, we just go ahead click the Solidity compiler so that we can just see our code here. To start writing our contract, we're going to use a keyword in Solidity called contract. This tells Solidity that the next piece of code is going to be the name for our contract

that we're going to create. You can think of a contract very similar to a class if you're familiar with JavaScript or Python or Java or really any object-oriented programming. And we're going to go ahead and give our contract a name here. We're going to call ours simple storage. And then we add this little open and closed curly braces or curly brackets. Everything inside of these curly brackets is going to be considered part of this contract simple storage. Now if we hit enter, we go back to the compiler and hit compile, we can see once again this little green check mark pop up. This means our compilation has been successful. If we were to remove, for example, this curly brace and hit compile, we would see we would get this error. Compilation failed with

one error. And if we scroll to the bottom, it'll tell us where the error actually is. And we'll get a little red popup saying what line the error is actually on. We'll learn about debugging these errors in a little bit. But let's add the curly brace back. Go ahead back to the compiler. Compile. And we're good to go. So I hope it's pretty clear. I think it's so I think next thing is quiz. Let me just click on retry and then we can solve it together. So I would love to know the answers in the chat. So what programming

language is primarily used for EVM based smart contract development? So s like I'm using like remix because that's what Patrick is using in this session. So I'm also coding along with this trying to code along uh because like I've already coded it quite a few times but yeah I'm still coding along with you guys so that I can also take like a look and feel of the session.

So yeah, actually like you guys should use your own computer like to answer these questions in the quiz. I hope like you you guys have opened uh this course devices.io and here we are in the fifth section of this particular fifth lesson of this particular section simple storage which is simple storage intro quiz. So the first question is what programming language is primarily used for EVM based smart contracts? So one has already answered.

Yeah actually like most of them have already completed this course. I know but yeah it would be great to know the answers. Yeah solidity. Great. Let's move to the next. What's the keyword pragma used for? It is used to handle you guys answer like I will just Yeah, it would be great to know

this answer as well. Yeah, last option the So like as of now 16 guys are watching. So it will be great to at least uh get 10 answers at least 15 people are watching right now.

Uh yeah, two have answered. Last option D. Hulam and Vive. Anyone else wants to try? Let's move with this. Then it specifies the version of the solidity compiler that should be used. Uh that's correct as well. What does compiling a contact mean? Answer. Answer. Answer in the chat. Then like now we are on the last

question. What does compiling a contract mean? Now we are getting conflicting answers. Two guys have said A and one is saying

B. That's getting interesting. Anyone else wants to try? We will go with the majority after that. Okay. Now, two A's and two B's. Yeah, that's pretty interesting. So like yeah I think it will be great if I also know the reason from you guys like Vive and Shesta why it's A and Ditro and Seph why it's

B okay one more B A.M. So should like shall we go with B then? Okay. One more A we are getting. Now it's again tie between A and B. Just wait for one more answer then we will proceed. Oh, there is a

new newcomer. See getting a lot of conflicts in this question. It's A now. I think A is winning. So we have four votes for a 1 2 3 four and five. Okay, we need evm. So a okay dero like like sorry if I'm not pronouncing it correctly but he's also saying a compiler code makes why it's a or b. So let's proceed with the majority option says a. So, so what does a say?

Let's read. It converts the solidity code into bite code and AI that can be understood and executed by the Ethereum virtual machine. I think EVM will be clear in the blockchain basic section if you guys have already covered it. So, EVM usually like EVM makes the code like the solidity code compatible with like each of the EVM compatible chains. So, it basically compiles the code into bite code and AI. So to make it EVM compatible uh we write like we use this solidity compiler and then it compiles the code into the bite code and then the AI can be generated from when the code is compiled and I think you guys have al also seen

if you are familiar with this like when when our contact is not verified then we only see the bite code on the explorer on the contact explorer. But yeah once it's verified uh which which means that we are verifying the AI with the byte code so then we will also see the contact functions and then and the entire contact code. So AI and bite code basically goes side by side in compilation of a smart contract. Let's just proceed with yeah A is correct. Now we can

proceed next next lesson which is basic variable types. So I know like the guys who are coming from the programming background a bit uh might be familiar with the data types like integer, boolean and uh string uh like a string is not a basic type though. Yeah, but the floating point numbers but we don't have floating point numbers in solidity yet.

I think the floatingoint numbers will be added in the upcoming versions but I'm not sure. there are high chances but yeah the basic types are I think in solidity there are like address bytes 32 and then into 256 uh for signed integers and the unsigned one is u into 256 and one is boolean yeah let's proceed with the video and see what hypothetically we could deploy this smart contract right now this is a valid contract although it doesn't do anything. But congratulations.

Technically, with just this little piece of code, you've written your first smart contract. I spelled version wrong, so we're going to correct that. Solidity has many different types of things that you can build in these smart contracts. Many different data types or just types. If you go to the Solidity documentation at docs.solidity.org, again, linked to this in the GitHub, we can select the types section on the lefth hand side to learn more about Solidity types. If you want to get a holistic view of all the different types, you can go ahead and read this documentation. Some of the basic types are going to be boolean, boolean, uint, and an address, and bytes. Bytes is a lower level type, which we'll talk about in a little bit.

A boolean is some type of true false value. A uint is going to be an unsigned integer, aka a positive whole number, meaning no decimals, no fractions. A integer is going to be a signed whole number meaning it could be positive or negative but again is a whole number and then we have an address which is going to be well an address. It's very similar to if we open up our MetaMask and we click this account here. It's going to be something like this. There are some other types as well and ways to create your own custom types but we'll learn more about that later on. We can use these different types to define different variables. Variables are essentially holders for different values

and these values can have one of these types. For example, we could create a variable called has favorite number which would represent if somebody has a favorite number. This has favorite number could be true or false. Either they do have a favorite number or they don't. To tell Solidity that this has favorite number is a true false or a boolean we would add this bull keyword before has favorite number. So this has favorite number is going to be either true or false. And to set its value, we're going to give it this little equal sign and say true. So now has favorite number is a variable that represents true. We could also say has favorite number is false, meaning that somebody doesn't have a favorite number. For a

uint, which again is an unsigned integer, we could say int number equals 88. This means that this variable favorite number is going to be 88. A uint and int are actually special in that we can actually specify how many bits or bytes that we want to use. For example, we could say u int 256 and 256 specifies this variable favorite number has 256 bits. We're not going to go over bits and bytes in depth right now. But if you want to get a quick refresher, we've left a link in the GitHub repo associated with this course to give you an overview of bits versus bytes and how they work. An easier way to think about this is really just how big can it get.

The bigger the number over here, the bigger this favorite number can be. The maximum size is a Uint 256. And if you don't specify the UN 256, it defaults to being a UN 256. So this and this are the same thing. This, this, same thing. You could also have 8 bits, 16 bits, 64 bits, etc. Often times it's better when we're writing our code for a readability standpoint to be as explicit as possible. So you'll see me pretty much always writing U and 256 because I want to be very explicit with how many bits I'm using for UA 256, even though they mean the same thing. Instead of a UN 256, we could also have this be an int 256. And actually, let's add that boolean back up here. Now, an int can

actually be positive or negative. So, we could have our favorite number begative88 if we wanted to. We can also have strings or text variables, which I didn't name up here, but I'll say why in just a minute. We could say string favorit in text equals 88. Let's actually make this positive 88 even though an int could be positive or negative. I'll put this little semicolon here. You'll notice that at the end of every one of these lines, I'm adding this semicolon. This semicolon is how you can tell Solidity that a statement has completed. So this semicolon is saying the end of this line is right here. If we wanted to, we could put all of our code on the same line like this.

And this would compile fine. It just looks really ugly. So we always want to put our code on a new line after the semicolon. A string in Solidity is basically text that represents well words. So, I could say 88 instead of having 88 in here. To tell Solidity that something is a string, you have to put it in between quotes. I could put really any combination of characters in here, even like hello or follow Patrick on Twitter. And let's actually do you 256 here. Favorite number. And we'll do an int 256 favorite int equals88. This way we'll just have an example of all these different types on screen. We can also do an address. So we can say address my address equals and we

can go into our MetaMask, copy the address and paste it right into Remix and add that semicolon. And now we have our address type in Remix. And then finally down here we're going to say a bytes 32 object favorit bytes 32 equals cat. And we're going to put it in quotes just like we did the string up here. And what's interesting about the string object is that strings are actually secretly just bytes objects specifically for text. So a string can actually get converted to a bytes object really easily because under the hood they're essentially the same thing. Bytes typically look like something like xerx and then a whole bunch of random numbers and letters that represent the hex of

whatever the bittes is and can often be represented as strings like cats. We'll talk about bytes more in the future. Similar to you in 256 and in 256, you can have different size bytes like bytes two bytes bytes four bytes 8 etc all the way up to 32. You can also have just straight up bytes and not have a number after but that's a slightly different type and we'll go over that later as well. Aint like this and a 256 are the same thing but a bytes 32 and a bytes with nothing are actually different. So keep that in mind for now. The largest bytes like I was saying is actually 32.

So for example, we can't do 8 bytes 64. And if we type that in here, Remix actually goes, hey, there's an issue here. And if we try to compile this, we scroll down, we'll again see this little error code here. And this little error pop up. It even gives us an output declaration error identifier not found or not unique. It gives us the line. And we can say, ah, whoopsy daisy. This should be a bytes 32. and we can go back and compile this for our simple storage contract. Let's say that we only want to store a favorite number. This contract is going to be a contract that allows us to store our favorite number and some different people's favorite numbers as well. So, we're going to go ahead and delete everything except for the 256 favorite number. So, we're going to go

ahead and delete everything. And boom. And we'll pick a smaller favorite number just to make it a little mentally easier. Now, these variables actually have default values. So, for example, if I don't set my favorite number to anything and I have a line that looks like this, you'll see that this actually compiles fine. Favorite number will actually get defaulted to zero. And all of these types have a different default value. U 256 is zero, booleans is false, etc. So saying 256 favorite number and not having an equal sign after here is the same as doing U and 256 favorite number equals zero. So for now, let's not initialize it to anything. So that favorite number starts off as zero. And

remember, as you're coding along here and typing along with me, if you get confused, make sure to write your own comments. For example, we can say favorite number gets initialized to zero if no value is given. Okay. So now we are up to this functions part. I hope the variable types are clear. So like I can see in the chat most people are asking

like some people are asking uh which programming language should we learn before solidity and all and also can can we get job if you are not coming from the computer science background. So I think one of this topic is already covered by Patrick in one of his video on YouTube. I've already shared the link of the same. So you guys can watch this particularly rdranat to build code logic on every part. Yeah, I think like in the in the beginning building logic is uh somewhat difficult but yeah as you practice more because repetition is the mother of a skill. Patrick usually mentions this in

all of his videos. So once you like keep repeating and uh keep trying out the stuff by yourself uh writing code by yourself seeing tutorials and all then I think you will get to know and you will learn a lot and you will eventually start building logics of even complex complex uh programs. So it's not only applicable to smart contexts, it's applicable to almost every programming language. The logic building is almost same because like once you start building logic then you can eventually cover it in like any programming language. So the

logic is uh slightly different but yeah uh so like that's why we the people who go to like pursue any CS degree uh they usually teach data structures and all they usually help out in building logic. So I think one post that you can see like I have answered this uh similar question on Ethereum ST exchange. So Ruran you should definitely check this answer. I've shared this link already like which should I learn before solidity. So you can just copy this link. I think it's not showing as a URL.

So if like if you can share it as a URL I think it will be great that people can click on it. So let's move to the next section. So like if you guys have any questions uh regarding the variable basic variable types yeah as Vic is saying like you can go with JS if you want to build your fundamentals uh and if you want to basically later on learn solidity then you can go with JS. So like what address are you

referring to? Vive, can you please elaborate? Okay. Okay. So like address is also a like a data type uh like a basic data type. So like the way you see your wallet address, right? uh when you create your account on metam mask so it's basically like a value of type address so like everything in solidity is usually like encoded so that's why we have this address field so so that like we don't end up storing

that kind of characters into something like a string and then like the string operations are usually costly so that's why I think the EVM guys decided to create their own uh like the separate data type named as address. So if you want to learn more about this address data type, I think there are various documentations available by I think solidity by example is a great [Music] example. I think solidity by example is a website maintained by one of the guys working in siphin uh known by the name of smart contract programmer. So he's a great guy like a lot of knowledge in

defi and building smart contracts and the courses like uh unis swap and curve finance are covered by him only on siphon updraft. So let me just quickly find the address address data type. I think this article has explained it. Uh quite nicely.

So V you can see through to that article understanding the address data data type in solidity and there there are more articles as well I So like is this link opening on your end? V can you check if you are copying this medium article link that I have shared. Is it opening?

I think you're muted. We don't hear you. Okay. Okay. So, like I was pointing out that like Al if has already shared an amazing article uh on cipher updraft Twitter post which is related to from partygoing student how a guy becomes a smart contact security expert guy named Carlos I think. So these are the some like inspiring stories and like it's just one of the many stories. There are many similar stories like sky's is the limit in web 3 and in web 3 security. Yeah sure V that will be

great. You can also share a thread. Okay. So let's proceed with the next next section like next lesson which is functions remix simple storage functions. Now now like the like a smart contract structure is already declared which is like the contract simple storage and some data types basic data types are explained by Patrick. Now we will proceed with writing simple functions into that particular contract simple storage contract. Now let's go ahead and learn

to make our first function basic solidity functions section. Functions or methods. Functions or methods are a subsection of code that when called will execute a very specific small piece of our entire codebase. If you're familiar with JavaScript or Python or any other programming language, functions in Solidity are exactly the same. Functions are identified by the keyword function. Let's create a function and name it store. And we're going to have this function be responsible for actually updating our favorite number. We're going to store a new favorite number. So you first write the function keyword, the name of the function, and then you add these two parenthesis. Whatever is

in between these two parentheses represents what we're going to pass or send to our function or the parameters that we're going to send to our function. For example, we need to tell our store function what value it should use to update favorite number. So, we're going to tell our store function it should take a unit 256. And this variable that we're going to pass to it, we're going to call underscore favorit number. It's important that we give it a different name than favorite number up here. And we'll talk about that in a little bit. Then we're going to say this is going to be a public function and we'll explain that soon too. We want to put these little curly brackets in here as well. And we're just going to say favorite number equals underscore favorite number. And without going too

deep into what this is doing, we're saying I'm not going to explain public yet, but we will in a minute. But what we're saying is whenever you call this store function, you're going to set our favorite number variable to whatever variable that we passed. I'll explain why we do this underscore here as well in a little bit. And with just this, we can actually start to simulate what this smart contract will do and if our store function will actually work correctly. So, what we can do with just this code right here is come over back to the compile tab and hit compile. Make sure that we get this green check mark and that everything looks good. And then we can go down to this deploy and run transactions tab. Our deploy and run transactions tab has a ton of different

parameters in here on how to actually deploy and run with our transactions. We're going to deploy this contract to a simulated virtual environment. So, we're going to deploy it basically to a fake environment. We're not going to be deploying it to a test net. We're going to deploy it basically in kind of an imaginary world. In order for us to do this, first make sure we're on this Remix VM. And for us, we're going to just use the default, which is the merge. Doesn't really matter which one you're on, just so long as it's the remix VM. This Remix VM is a fake local blockchain where we don't have to wait for transactions to complete and we don't have to deal with any of the oddities on deploying our code to a real test net or a real mainet. And don't worry about the rest of these for now.

We also get an account here. When we run on our fake Remix VM, we get automatically given an account with a different amount of Ethereum for each account. You can think of each one of these accounts similar to our MetaMask accounts in MetaMask, except for these are fake imaginary accounts that Remix just gives to us. For our transactions, including deploying contracts, we're given a gas limit values that we can send, and we can also choose our contract depending on which one we've compiled. Since we only have one contract in here, we only have one to choose from. So on the lefth hand side, to deploy our contract to this fake Remix VM environment, we're going to go ahead and click the deploy button. If we scroll all the way down to the bottom now under this deployed contracts, we can see we actually deployed a contract

here. Simple storage. We can see the balance is zero and we see this big orange button that says store and then U6 favorite number on our local blockchain. This at blah blah blah here. This is going to be the address of our contract. Similar to our wallets how they have different addresses, every single contract has a unique address as well. And if we hit this little copy button and we close this, we put as a comment here and we paste it, we can see this looks exactly similar to an address such as what's in our MetaMask. And then let's go ahead and open the deploy back up and we see that deployed contract is still there. Additionally, if you hit this little show terminal button and you pull this up, we can actually see we have this little comment here, creation

of simple storage pending, and we have this green check mark here. This is notating that we actually sent a transaction to deploy this contract. Similar to sending ETH back and forth, in order for us to deploy a contract, we actually have to send a transaction. Since we're doing this on the Remix M, this is a simulated transaction, a pretend transaction inside of our Remix environment. You can even hit the little drop down and see even more information about this transaction. You'll see a lot of familiar keywords like status, transaction hash, from to, gas, etc. Deploying a contract uses the exact same process as sending a transaction for just ETH. Main difference is we populate this data or input field with a ton of that bite code. And if you copy this

input field or this data field and go ahead and make a comment in here, you'll see it's a massive line. And this massive line notates all the data associated with this smart contract, all the machine readable code. Remember, anytime we do anything that modifies any value on the blockchain, we actually do that by sending a transaction. deploying a contract is modifying the blockchain. So, we do it in a transaction, which means yes, we spend gas. Now, this big orange button over here actually resembles our function store in our smart contract. And if we add some numbers in here and we call it again, if we pull the terminal up, we can see transact to simple storage pending. And we see we sent a transaction which

called this store. If we do this again with a different number, if we call it, we can see our terminal say, "Oh, you sent another transaction to update the state of the blockchain." And if we scroll all the way up to our account, you'll see that we have a little less ether in our account because we had to spend the gas associated with well a deploying this contract and then b calling these functions. And then, for example, if I add this if I add five in here and hit store, we'll send a transaction to store five on the blockchain. Now, you might be thinking, "Okay, Patrick, that's pretty cool, but what is this is the value of favorite

number?" You're telling me that this function store is updating favorite number, but I can't really see it. How do I know that favorite number has actually been updated to five? Well, the reason we can't see it is that the visibility of our favorite number is actually defaulted to internal. So, us not having anything here or right internal are actually meaning the same thing. And we'll talk about visibility and default visibilities in a minute. But in order for us to actually see the value of our favorite number, we'll go ahead and add the public keyword to this. This changes the visibility of favorite number to public. And like I said, we'll talk about visibility in a minute, but let's go ahead and compile this. Let's go ahead and delete this contract by hitting this X here. And let's redeploy this contract with this

new public keyword. So, let's go ahead and hit deploy. And now, if we scroll down and we open up our simple storage, we actually now see a blue button labeled favorite number. And if we click it now, we can see it returns zero, which makes sense because we know that 256 is default to zero. Now if I go ahead and add five into here. Okay. So like I hope you guys are following along and we're able to write this contact. I think there are some questions.

So like for experience I think Rudraat you can like join the code hawks uh like once you complete the cipher security courses and also get the certification uh then you can definitely participate on competitions like codeox and uh you can build your portfolio and once you have strong portfolio then you can definitely start applying and I think it's like already well explained in the YouTube video of this YouTube video of Patrick Collins that I shared above like the process which simplifies like how one can apply and all and like let me just quickly explain some of these things in Hindi as

well so that you guys can understand. So I'm audible I think. So line it will show a warning compidity version 0.8.18 contract contact keyword which is similar to class keyword the class

keyword JavaScript C C++ language C++ not C because C is not object- oriented C++ Java JavaScript contract keyword contact then opening curly brace and then the closing curly brace. So, so like uh curly bracket or or just a simply brace you can say. tom by default value u into

56 line into 56 data type variable favorite number visibility public I think visibility will be covered later in this course but yeah public means Default and there are advantages or disadvantages. So there are some best practices that you can definitely learn while writing your own contracts and all.

Obviously compment storageable value and hit the store button. If I pull up the terminal, we'll see that we went ahead and executed that store

function call that transaction that's going to transaction function. V basically transactionless functions. You can say function. Function call store transaction exeute locally favorite

number to take input this five as favorite number and set it to our favorite number. Now, if I hit favorite number, you can see it does indeed return five, showing that we actually updated our favorite number with this function call. And remember though, I'm going to go ahead and do this again. And remember, when I hit X here, this is just removing it from this window here. If you actually deploy a smart contract to the blockchain, hitting X from this window doesn't do anything because once you deploy your contract, it's immutable. It's out there, and you can't just delete it by clicking X and remix.

Functions and variables can have I think there are some questions. Let me just address them first. Negative marking in the certification. I Yeah, I like I'm not sure though. So, Alif, can you please address this? Like is there any negative marking in the certification exam? And after that we are having SPDX

starting unlicensed keyword MIT video starting. Yeah, it's the best best practice to use SPDX and there apart from MIT there are other licenses licenses as well. I think there is a whole list of licenses like I think GPL general public license and but yeah licensing is a completely different topic and then like you will eventually know about that by yourself but yeah for now you can just think of it like yeah GPL general public license and I think there are there is a list of SPDX

licenses over here but I don't think that that will uh that will be required for Oh man. Yeah, MIT is mostly used but SPDX but but like you you don't you don't need to stress about this certifications and all because that wouldn't make your learning

like any better or worse. So continue question. Please feel free to ask. Yeah, sure. Go ahead.

So now I think he's telling about this function visibility specifiers. So visibility specif ally one of four different visibility specifiers in Solidity: public, private, external, and internal. If you don't give one of these keywords to your variables, it'll get defaulted to internal. Public functions mean that they're visible externally and internally. And you'll see here it says it creates a getter function for storage/state variables. This means that

other people can call this function or call this variable. When we didn't have a visibility for favorite number, it defaulted to internal, which is why we didn't see this blue number pop up because internal that means that other contracts and people aren't allowed to call on this favorite number. We have a little bit more here. It says it actually creates a getter function for storage/state variables. When we add this public keyword here, it's actually equivalent to us making a getter for this favorite number variable, a getter function. And I'll show you exactly what that function will look like in a little bit. Now, keep in mind though, everything on chain is technically public. So, setting a function or variable to private isn't a good way to hide what the value actually is there.

And we'll talk a little bit more about storage and visibility and and that much later. Just remember, everything on these EVM chains is actually public data. This public variable just means any other contract can call this favorite number and see the value what's in favorite number. And private means only the current contract can. External functions mean they're only visible externally. And this is only for functions, not for variables. And it means another function inside this contract couldn't call an external function. And internal means only the current contract and its child contracts can call the function. We'll talk about child contracts and inheritance in a later section. So let's just keep it public for now. The reason that we have this underscore here in this parameter is because we need to tell users that this variable in here is different than

favorite number. And there's a couple different conventions on naming local variables versus these what's known as state variables or variables outside of functions. And we'll go over those later in the course. Now, here's something that's really interesting as well. Remember how I told you earlier that sending ether is a relatively simple transaction, right? Well, let's see what happens when we call this store function and we update favorite number to five. Let's actually call it one more time and we hit the little drop down here. Let's go to gas and we'll see gas actually cost 27,000 gas, which is a lot more than the 21,000 gas it costs to just send ether between accounts. Remember, every time you update the state of the blockchain, it's going to cost gas. Now,

what do you think will happen if we do more inside of this store function? For example, we say favorit number equals itself plus 1. Let's go ahead and compile this. Let's delete our old simple storage. Let's deploy this new one. Remember, the last one cost 27 gas. Let's pull up the terminal. And Remix actually gives us a little tool tip. And it's saying an infinite gas, which we know is actually wrong. But let's go ahead and add 1 2 3 in here. And we'll hit store. We'll see this transaction. We'll scroll down. we'll see gas is actually a lot more. It's way more gas.

It's 50,000 gas with just adding this line here. Now, technically, I'm not telling the full story here because there are some other gas costs associated with the first time you run a function, but it's still more, right? And that's what's important here. So, so like as you can see, I hope I'm audible. Yeah. favorite number starting. Uh I hope it's clear. Feel

free to ask any questions related to this. So Gulam and uh I think like whoever have any questions Vive uh like the guys who are having any questions related to certification uh they will be addressed by Alif like in the last few minutes. So don't worry about that. So if you guys have any questions related to this calling of a store function then feel free to ask. So and the questions related to gas gas consumption the transaction yeah storage and

gas external you mean the external like like if you make this uh function as external right that's what you are saying guest cost is decided by like the operations like whatever operations you do in the function so am like you can let me know if you are comfortable in Hindi or uh you want me to continue in English? Gas optimization is a major cuss. Yeah, obviously like I think there are separate videos related to gas optimization and all in later courses like the like more complex the operations in the particular function the gas cost will become expensive because the function will

consume more gas. Obviously the transaction cost cost will be incremented. So each gas unit will have its own cost. So the more the gas consumption will be the more transaction cost at the end. So that's why it's recommended to optimize the functions as much as possible and also to retain the readability of the functions transaction cost. how operation how to reduce the cost. So yeah, obviously like the first thing is to write the function uh with whatever knowledge you have and then the next thing will be to optimize it. So

you don't need to worry about the optimization in the very first stage otherwise you will face problems because you will just stuck in writing one function itself. But yeah eventually when you uh start building logic you can simplify it like I think the guys who are coming from the programming background because the first like we basically learn about the linear search and then the binary search and different different search algorithms to minimize the complexity. So you can think of the complexity is somewhat related to this gas uh gas consumption. Those who are from the programming background uh might get a better idea at this. But yeah like it it's not a problem like in case of simple functions you can

just make them as as readable as possible but yeah later on when you are calling it on the main net and all then the algorithms obviously like the data structure and algorithm section of like uh of I think in universities they teach about uh the DSA and all in C++ particularly in Indian universities is so that's why I think in my answer that I've shared above uh which programming language should you should anyone learn before solidity it covers everything related to that so for beginner friendly basically languages and uh if you want to strengthen your programming fundamentals so but yeah they are not required for learning

general solidity solidity development but yeah obviously the more you learn the more better like the the better you become in coding and programming. So it's just like a kind of rabbit hole or you like you will get addicted to improving your code. So it's not like somebody has to say to you that you need to improve your code. You will eventually get addicted to making your code base uh better and better day by day. You won't be satisfied if you are a programmer by heart.

Okay. Yeah, that's great to know. Bachelor of Engineering in blockchain. So from you, which university if I may ask? Uh from which part of India you are in? I'm not sure like Indian colleges are providing this blockchain university. Blockchain engineering. That's interesting. Osmana University. Okay, that's great to know. So, Al iff I think we can target this university to conduct our events.

They are having their course in Bachelor of Engineering in blockchain. So, I think they are building their fundamentals in blockchain. That is sounds that sounds really nice. Uh which university you mentioned? I think Osmania University is saying Osmania. Osmania University. Okay. Uh who is there actually? Let me check the messages here. Gulam. Gulam Rasul. Okay. Uh can you reach out to me Gulam? That would be really nice. I mean you know my name right. You can definitely reach out to me on Twitter or LinkedIn or whatever. We would love to talk to you about the collaboration and what we can

do. What are the options? Yeah, thank you. Thank you so much. Sounds good. Okay, by the way. Yeah. Yeah, sure. So, like we can proceed with the rest of the video. Then we will cover the questions later. Just adding this line here. Now, technically I'm not telling the full story here because there are some other gas costs associated with the first time you run a function, but it's still more, right? And that's what's important here. So, so let's go ahead and delete that line and go back to our old function here. Now let's talk about something called scope for a second. So if I create a variable in here called unit 256 test var equals 5 and I create a new function called something make it public. Could I access

the test var and then maybe change it to six or seven? What about the favorite number var? What about the favorite number variable? Could I access that to seven? Well let's go ahead and see what happens if we try to compile this. We try to compile. We actually go ahead and get an error in our compilation. undeclared identifier. Whenever you create a variable, it can only be viewed in the scope of where it is. If that's confusing, just look for the curly brackets. The reason that our something function can read the test var is because this test var isn't inside of the curly brackets of something. The reason it can't read the test var is because test var was created way up here inside of these curly brackets outside of something. But favorite number wasn't created inside of these curly brackets.

So, how come it knows what favorite number is? Well, something is inside of these curly brackets and favorite number was created inside of all of these curly brackets. If favorite number was created inside of here, it wouldn't be able to access favorite number because again, favorite number is inside of this scope and not this scope. If you create a variable like test var inside of store, you can only access this test var inside of this store function and not anywhere else. The easy way to know what the scope of a variable is is just look for the curly brackets. So let's go ahead and delete this something variable. And let's delete this test var. And let's recompile. Now, like we were saying earlier, when we add this public keyword

to favorite number, it's the exact same as if we created a getter function to return this favorite number. So let's actually write a function similar to what this public keyword is creating. So, we're going to say function retrieve, make this a public view function, and we'll talk about that in just a second. And we'll say it returns a uint 256. We'll add the curly braces here. And we'll say return favorit number. And often times when these auto suggestions come up like this, you can just hit enter and they will automatically do it. So, if we do favorit and then I just hit enter. Boom.

Automatically like that. Now I'm going to hit command S which is equivalent to me going to the compile tab and hitting compile. Now if I go to the deploy tab and let's deploy this contract now we scroll down we now see we still have that store function. We have our favorite number function and we have a new blue button called retrieve. Right now they both start off as zero. And then obviously if we update this to five by calling store. Yep I called store. These now both return five since favorite number is the actual variable and retrieve is just returning whatever favorite number is. Now as you can see here these two functions are blue but this one is orange. What's the difference? Why are the colors different? Well the key is actually with this view keyword here. Solidity has a

special keyword which notates functions that don't actually have to run or don't actually have to send a transaction for you to call them. And those two keywords are going to be view and pure. A function marked view means we're just going to read state from the blockchain. For example, in our retrieve function, we're just going to read what the favorite number variable is. Our store function isn't reading, it's updating something. So, and it's changing the state of the blockchain. So, we have to send a transaction. Since our retrieve function doesn't have anything inside here that updates anything, it just returns favorite number. We don't need to send a transaction. So if you add this view function in here, it disallows

any modification of state. For example, I couldn't add favorit number equals favorit number + 1. If we go ahead and try to compile this, we'll get an error. Function cannot be declared as view because this expression potentially modifies state. So we'd have to remove this line or we'd have to remove the view keyword. So, view functions disallow updating state. Your functions disallow updating state and they disallow even reading from state or storage. This favorite number here is what's known as a storage variable because it's stored in a place called storage. We'll talk about that in a later section. But if this was labeled pure, we'd see we get a little red

underscore here because favorite number is reading from state. Instead of returning favorite number, we would return something like seven. So this would be an example of a pure function. This would be an example of a view function because we're reading from state. Again, we'll explain the difference a little bit later. And like I was saying before, if we call a view or a pure function, we actually don't need to spend gas since we're not modifying the state. That's why these buttons over here are blue. They're representing view or pure functions, functions that we can call without having to send a transaction. For example, if I pull up the terminal here and I pull this up and I call retrieve, we do get another function, but it's just a call. And it looks different than if I hit the store, which has this

little check mark. They're different because the store is obviously sending a transaction, and the retrieve is actually just making a call and not sending a transaction. However, something weird's going on here. If I hit retrieve and I go into the details of this call, I can see, oh, what's what's this? Why is there an execution cost? It says cost only applies when called by a contract. What's going on there? The reason for that is because if another function that does update state, that does require a transaction calls retrieve, that transaction does need to pay the gas of reading and calling this retrieve function. So calling a view or pure function actually does cost gas only when a gas cost transaction is

calling it. So we can go ahead and call these as much as we want, it costs nothing. But if another function that does cost gas calls it, it's going to cost something. For example, if our function store here then went ahead and called retrieve like this, since store costs gas, you're telling this function, hey, also call this retrieve function, which is more work for it to do. And since it's more work, it's going to cost more gas. So for example, if we delete this contract over here, let's go ahead and compile this. Let's go ahead and deploy this with this retrieve in here. So, let's go ahead and look at these.

These are now zero. We'll store five in here. We'll select the drop down. We can see how much gas we actually sent. 50,000 gas. Go ahead and drop this now. Close this out. Let's remove the retrieve line. Let's compile. We'll hit deploy. Simple storage. These are both zero. We'll add five. Hit store. Pull up the terminal. Hit the drop down. Look at gas. It's still 50,000, but it's actually a little bit less than before. Although I'm pointing at gas, we really should be looking at transaction cost because gas is really just actually how much we're sending, whereas transaction cost is how much gas the transaction actually cost. But in any case, it was a little bit less without the retrieve function. Now, I've kind of been

glossing over this a little bit, but this returns keyword specifies what this function is going to give us when we call it. So when we have this returns keyword in our retrieve function here, we're saying whenever we call this retrieve function, we want to get returned or we want to be given this favorite number of type U256. We want to return a U256 from this function. Okay. So I think I can see one question in the chat. So Vive like you are saying like reading state is the view and writing state is pure. So that's not the case like view means like when we are reading from the

state then it's view but yeah when we are writing to a state uh basically modifying any storage variable then it's neither view nor pure it's a transaction function that's why you can you can see there is an orange button next to it. So like whenever there is an orange button means we are making a transaction and pure is when like we don't use any state variable. storage variable simply pure function or view function. I think there is one video let

me just share that with you that I had created previously to explain this. You can watch this video where I have explained this view and pure functions in detail. And also there

is solidity by example article or like this video actually. I think the link

was wrong. This one. So that will explain uh the view and pure functions in more detail but yeah obviously it will be clear when you practice more and uh apart from that I think so like if you guys have any questions then feel free to ask I think it's about like the time to wrap up the session and obviously we will continue from from the next part which is I think arrays and strs from lesson 8 in our

next session. So I will give the mic to Al if I think she can address the questions related to certifications by Gulam and Vive. Yeah. Yes. Yes. Yes. Yes. Okay guys uh thank you so much by the way say uh that was a great session and very high quality uh participants as well that I can see. Uh if you have any questions about being ambassador or or any any questions about uh certification please please let me know but also I'm going to uh share the certification link with you again and also if you have any feedback for this section also let me know you can definitely fill out that form and

this is the certification page guys it is solidity smart contract developer certification which is SSCD plus certification uh you have to write test and implement your uh your skills actually there there's a test there and you need to have at least 62 score to to pass the test actually you need to complete this um actually we have a couple of suggested courses because we have already you know cipher updraft which is an free educational platform blockchain basics solidity 101 foundry 101 advanced foundry 101 uh not 101 one advanced fundry cannot be 101. Yeah, advanced fundry. These are the the courses that

you have to look at actually because when you do this when you learn solidity and like all the details about Foundry, I think you will be go for it. Yeah, you will be good for this. Uh, and then normally the exam voucher is $199 actually, but I can give you guys a little bit discount if you follow the sessions with say and myself. And by the way, next week, not next week, in two weeks actually, we will have another ambassador from India and she will be also uh teaching with SE and helping you guys to understand every details. She will be also speaking in Indi as well.

Say, she's also from Delhi. You know what? Yes, our new ambassador. You can definitely apply for being an ambassador, guys. I really encourage you to join us and uh have the certification, okay? As soon as possible. But I mean, you don't have to do this now because we will be continuing to teach you in your local language on updraft study sessions. This is totally fine. You don't have to do it now. Just watch us and stay tuned. We will see you again in two weeks which is 19th of April by the way guys. Let me write it down here. April. Yes. And if you want to join us, you should definitely follow us

actually here on the events page as well. I mean you will see it eventually but let us know you know if you don't see the events if you don't see the YouTube uh page etc. If you don't see the event registration please please let us know. Say is a great teacher. I mean I I you know what we have known each other for years and uh yeah I'm definitely a fun of him as well. Thank you so much say I think we will see you guys in two weeks. Let us know if you need anything else and so excited to have you back again guys. Nice meeting you all. Do you have any questions? Say, you know, including you. If you have any questions, I'm here.

Yeah, actually like if guys have any question then I think they can definitely ask on Discord and also post on Ethereum ST exchange. Yes. Awesome. That's a great idea. Yes. And and I'm also happy to answer your questions on the social media as well. Thanks so much. Yeah. Thank you. See you later, guys. Bye. Bye. Bye.