The One Question bounty closes Thursday 10 December.

Join in
We Them Media logo We Them Media Support us

Writing Cairo Smart Contract on Starknet I

The picture loads from YouTube. The player loads only when you press Play. Turn on captions in the player if you need them.

An instructor teaches a class how to write Cairo smart contracts for Starknet, covering project setup, interfaces, storage structs, external and view functions, and events. Students answer questions along the way, then the group starts building a to-do list contract and the update function is set as the assignment.

Not by We Them Media Channel: Web3Bridge. Published Monday 27 May 2024.

Titles are the owner’s. It plays from their channel.

Transcript

This transcript may contain errors. This video belongs to Web3Bridge. Letters mark each change of speaker.

These are the speakers’ own words. We have not checked their claims.

0:15 A: So I'm sure you all can see my screen, right? Yes. Okay, thank you. All right, before we start writing the code, let's have some foreground and background to writing Cairo smart contracts on. StackNet. So I'll be reading through. One of the key applications of the Cairo language is writing smart contracts for the StackNet network. StackNet is a permissionless decentralized network that leverages zkStack technology for scalability. As a layer 2 scalability solution for Ethereum, StarkNet aims to provide fast, secure, and low transaction costs. StarkNet contracts are programs specifically designed to run within the StarkNet OS. The StarkNet OS is a Cairo program itself, which means that any operation executed by the StarkNet OS can be proven and succinctly verified. Smart contracts can access StarkNet's persistent state through the OS, enabling them to read or modify variables in StarkNet's state, communicate with other contracts, and interact seamlessly with the underlying Layer 1. To start writing your Cairo smart contracts, you need to have installed Scap. So to even start writing anything Cairo, I'm sure you should have installed Scab and get your installation ready. So the difference after installing Scab with your Cairo program and your Cairo smart contract is that you add this flag, that you add this flag and this dependency. All right, so Scab facilitates smart contract development for StarkNet. To enable this feature, you need to make some configurations in your scab.toml file. First, after installing and creating a new Scab project, so scab new whatever, in your scab.toml file you have to add this Starknet flag, this Starknet dependency to your list of dependencies if you have any, and add this flag. So next, enable the Starknet contract compilation of the package by adding a target, the Starknet contract section. By default, this target will build a Sira contract class file which can be deployed on StarkNet. So remember the first class we had, I explained, um, Sira to us. So we can quickly refresh our memory as to what Sira is.

4:56 B: Can I say- can I talk?

4:58 A: Yes, you can.

4:59 B: Okay, so Sarah is more like the language Cairo gets compiled to. It's like a subset of the- is it the Cairo VSL or something? I can't remember. Where's the compiled version of what Cairo gets compiled to at the lower level?

5:20 A: Okay, does anyone else want to try? Does anyone-

5:41 C: can you hear me?

5:42 A: Yes, we can hear you.

5:44 C: I think Sierra is the language that Cairo is compiled to, to ensure that it does not panic when it is in production or when it is deployed as a smart contract. Like, it's like a middle point between the Cairo language and then the Cairo assembly language.

6:04 A: Okay, cool. But is C language?

6:07 C: I think it's like a stream of like commands, because when I checked the C file, I was just seeing bytecode, something like bytecode, hex.

6:19 A: Okay, okay, you both are correct. So C is the compiler that compiles it from Cairo to KASM, which is Cairo Assembly Language. All right, so if you omit to specify the target, your package will compile but will not produce an output that you can use with StarkNet. Below is the minimal Stark.toml file required to compile a crate containing Starknet contracts. So the normal package, the name of your project, the version of the project, then the dependency flag. Because this is a Starknet smart contract, you need to add the Starknet flag as a dependency. The Starknet dependency and the version of StarkNet that you are working with. Also, because you want it to compile, you want Sira, you want it to compile to Sira code, you have to add this. So remember, was it you guys? Um, okay, I don't, I don't think it's I don't think, I don't think you guys- you do. I would go over it again when we instantiate a new project. All right, so this is setting up your file, your, your project to accept, to start writing smart contracts that will be accepted by StarkNet. So this is a general introduction of smart contracts that we all know. This is what you've been doing for the past 4 months, so you should know what smart contracts are. If you don't know what smart contracts are by this time, I don't know. I don't know what you did with your 4 months. Here. All right, Cairo programs and StarkNet contracts- what is the difference? Who can tell me the difference between Cairo programs and StarkNet contracts? You can just unmute your mic and speak. What is the difference between Cairo programs and StarkNet contracts? Yeah, go ahead.

9:19 D: Okay, um, I think, uh, difference between Cairo program and StarkNet program is, uh, StarkNet smart contract is designed to only run on StarkNet OS, while Cairo program can function as every other regular program and can be run on any other Uh, this thing, as long as you're using the, uh, the Cairo VM.

9:44 A: Okay, thank you very much, Abraham. All right, so that's the difference. All right, so, and then once you're writing a Cairo program, for any Cairo program to be executed, it needs to be a main function. for the Cairo program to get executed, just like writing Rust. Or what program needs a main? Is it C? It's C, right? It's C programming language that needs a main function to execute.

10:23 D: And Java.

10:25 A: And Java. Okay, cool. So they need a main function for any other functions to be executed in the program. Yes, so once, once you're writing a Cairo program, it will require a main function. But once you are writing a Cairo StarkNet smart contract, you do not need a main function to implement, execute those, um, the file. It's a different ball game altogether. So main is only for- is only found in Cairo programs. Anatomy of a simple smart contract. So this is a smart contract and it's a storage smart contract. Now, okay, I think let me just read this before I make- do my explanations. This is a contract. You can see the flag, Starknet interface. It has a trait. of ISimpleStorage and a generic type, and it has 2 functions. Or what do you call this without the implementations? What are they called?

12:06 D: Interface.

12:16 A: Okay, cool. Yeah, but I'm referring to the function without the implementation. Once you see a function like this, right, without the implementation, what does it- what is it called?

12:50 C: An interface.

12:50 D: Func-

12:54 C: It's called an interface.

12:57 D: Function signature.

12:58 A: Who said that?

13:02 D: Function signature.

13:03 A: Okay, who said this is an interface?

13:10 C: I did.

13:11 A: Okay, but do you know what interfaces are?

13:18 C: Yes, I do. After I had this response, I figured I was wrong.

13:24 A: Why? Why do you think you are wrong?

13:27 C: Um, because you said function, like the declaration without implementation. Um, the interface has to be like the com- like everything put together. So when everything is put together in that trait, that's what makes it an interface.

13:41 A: Yeah, that's awesome that you figured it out. Nice, nice. Yeah, so this is the function signature because it doesn't have the implementation, but it carries the entire, um, signature of that function and They are both wrapped up in this trait. So seeing something like this, you should understand that this is referring to an interface, right? Here you have the flag Stacknet contract, and in this flag you have a mode, a mode called simple storage. In this simple storage, you have another flag called storage. Yes, you can ask your question. Was someone trying to ask a question? All right. So you have a mode, simple storage. You need another flag called storage, and under this flag we have a struct called storage. And this storage has a, a variable called stored_data, and stored_data is a uint128. Outside, we have another flag called ABI embed. ABI embed has an implementation called simple storage of super high simple storage. So this implementation means it is implementing this trait called ISimpleStorage, calling the first item set and the implementation for set, and get with implementation for get. So this is a very, very simple smart contract. All right, what is this contract? Contracts are defined by encapsulating state and logic within a module annotated with the @StacknetContract attribute. The state is defined within the storage struct and it's always initialized empty. Here our struct contains a single field called stored_data of type uint128 indicating that our contract can store any number between 0 and 2 raised to the power of 128 minus 1. The logic is defined by functions that interact with the state. Here, our contract defines and publicly exposes the functions set and get that can be used to modify or retrieve the value of the stored variable. You can think of it as a single slot in a database that you can query and modify by calling functions of the code that manages the database. So hope we all understand the, the use of structs in your smart contract. I think let me go, let me, let me start from there. So what is struct, guys?

17:38 E: I feel it's the same use case for Solidity. Just gives you like a structure for your, um, yeah, like a structure for your data types.

17:58 A: Okay, structure for your data types. Is that all?

18:05 E: Yeah, just gives you like a logic for implementation. You can also use it in traits. when you want to, um, work on traits for your, for your contract. So I just see it as same thing, just gives you like a structure. Let's say you want to implement, um, like a book listing, so you just need like a structure to put in data for the books, the book that the person bought, the person's name. So for each person's- now each person that comes to your bookshop, you have like a struct that collects their data, then you can use it in your trace because I saw them using that in tracing.

18:48 A: Okay, does anyone else want to explain to me what struct is? Guys, you've been, you've been writing this for the past 4 months or 3 months. And some of you have been writing it way before you came here.

19:19 F: Can I come in?

19:21 A: Come in, please.

19:23 F: Okay, um, so basically, um, something similar to struct is, um, the way we have objects in JavaScript. So struct in Solidity, for instance, is just In Cairo, it's a generic type actually. So it's used to group some data that's related. So to group some data that are related, we make use of struct.

19:50 A: Okay, is that all? Like, is that all? So after grouping this data, what happens?

20:06 F: We also use- we use it actually, we use it to store data in a kind of key-value pair.

20:16 A: Yes, so where is the data stored?

20:20 F: The data actually is stored in is attached to the keys.

20:30 A: Okay, nice. Okay, so struct is, according to you guys, is a structure for or data types. It's a structure for to arrange data types that are similar, or to arrange items that are similar, or refer to a particular field. But what is the use of struct aside just arrangement of data, aside from being a complex data type that is formed by other data types, what happens to a struct? What happens to the information in the struct once that smart contract is deployed? What does this drug do? Okay, so most of us don't, don't really bother. We don't really care about about it. We just want to write our smart contract and deploy to the blockchain. Yeah, we are not really bothered about that, right? Cool. But you should understand that this contract you are writing is going to be deployed. And what executes smart contracts? Let's make it interactive. This is something- these are things you know, don't Don't, don't feel scared or feel, um, like I'm going to swallow you. These are things you should know by now, so just say it. What executes smart contracts?

23:01 E: Uh, the compiler, the EVM.

23:10 A: The EVM,

23:15 E: that's for Solidity. Yeah,

23:19 A: yeah. So the EVM executes the smart contract. So that means- what does that mean? That means the, the bytecode, right, that the EVM understands. for that smart contract is stored there, right?

23:34 F: Yes.

23:39 E: Yes.

23:40 A: Okay, cool. Now we have struct, and you said struct is to give structure, right? So once this structure has been given, once these inputs are entered, what happens next? Where does this input go to? What happens once this structure is given? It gets stored. Oh boy. So you have a struct, you want to get a structure for something, and Okay, it takes in different types of data, and you want when this function that executes this struct is called, it will take this, this, this, this, and this from this person, right? Then pass it as the values to the various, um, um, parameters in the struct, right? So once these values now are passed, maybe age, name, and stuff, is passed, what happens to these values?

24:54 F: They are stored to

25:00 A: the state. Thank you. They get stored to the state, right?

25:04 F: Yes.

25:07 A: Cool. It gets stored to the state. That means the struct doesn't just give you the structure for your- to write your implementation. In your smart contract, it doesn't just stop there. Once these values are instantiated, initiated, or whatever you want to- executed or implemented, or whatever you want to use in English you want to use- once there are values, these values will automatically get stored to state. And getting stored to state Means there is a slot. Have you guys done something called slot packing, or have you tried to build a smart contract and then you see storage too deep or something too deep, stack too deep error? Yes. You didn't- you don't- you know that it's a struct that is giving you that error. You're getting that error from something from your struct. Or you didn't research to understand it properly. And that is why in arranging your structure, you have to arrange your structure properly. If you are, you're calling age and you are using units 2, 5, 6, that is not logical because there's nobody that lives up to the number, the last number in units 2, 5, 6. So anytime you are instantiating age, it is proper for you to, um, to initiate it as a uint8, right? What is the last value in a uint8? You have the analogy that someone will live to that, to that age, or at most that age, or a uint16, depending. 16 is even very large. So say you eat it, then maybe something else. You have to allocate spaces according to that particular thing. Why? Because you are- you have to consider the machine, you have to consider the slots, the space in memory where this information you are storing is going to stay. Is going to- a slot stores one variable, and a slot only has the space to store up to 32 bits. And if it is not full, the next item in your struct is supposed to take up the next- it's supposed to take up that space. So if from the beginning you are assigning age to be uint256, that is already 32 bits. Its age is already taking up a whole slot in the memory. And then the next item, you put 256, uint16 and stuff. It will take up- in the way to save in the memory, you know that that's the way you wrote it in your struct is the same way it will get executed Right. One by one. It, it is not smart enough to look through it and gather all the uint8s in one place to put them in one slot to save space, and then move all the uint16s or whatever, or join uint8, uint16, uint8s to form the 32 bits and save them in one of the slots. I want you to understand what is going on behind the scene. when you are creating a struct. So once you, you, you, you say- when you say you are creating a structure, yes, it is also for implementation and also for storing these values to states. And once you are storing these values to state, you should remember that it is going to be stored in a VM. There is an allocated memory space for these values to be stored, and in this allocated space, it is like a divide. It is divided into slots. That's what we call slot packing, right? It is divided into slots, and each of these values or information are stored in each of these slots. So if you have a uint8, you have a uint16 in your struct, you have to rearrange it so you have your uint8 first, uint16 next, and stuff like that, so that the first, the first 2 or 3 variables should form 32 bits. The 3 of them will be in one slot. And then if there is a uint256, that uint256 variable should be towards the end of of your struct. So to stop that stack too deep errors you get, you have to rearrange the order of your struct so that you can conserve space. So why am I telling you- why am I asking you this? I'm telling you this, I want you guys to really understand. Go back and reflect and research, understand what is actually going on behind the scene. Because in Cairo, you are- it is more like you are almost closer to the machine than in Solidity that just gives you- has just abstracted almost everything for you. Okay, but do you understand where I'm going to? And do you, do you now understand what happens at the end? With a struct, the full lifecycle of data in a struct. Do you get now?

31:08 E: Yes, Frederick.

31:10 A: Okay, so Victoria?

31:12 E: Yes, Emma.

31:17 A: Yeah, so, so I want you to understand it well. You know you're a public speaker. Don't go and fall my hand, babe. All right. Um, let's come back here. So let me take this again so you get what I'm trying to say. The state is defined within the storage struct and is always initialized empty. Here our struct contains a single field called stored data of type uint128, indicating that our contracts can store any number between 0 and 2 raised to the power 128 minus 1. So that automatically means if you are storing any number higher than that, there's supposed to be an error, right? The compiler is supposed to throw an error because you are going overboard. The logic is defined by functions that interact with the states. Here, our contract defines and publicly exposes the function set and get that can be used to modify or retrieve the value of the stored variable. You can think of it as a single slot in a database that you can query and modify by calling functions of the code that manages the database. So after my explanation of the struct and the slot, do you now to some point understand what this part is actually talking about? Talking about the slots, the storage and stuff?

33:08 E: Yes, yes. Yeah, it makes sense to me now.

33:13 A: Okay, cool, cool, cool. What about you, Benjamin, Abraham, Kenny, the rest guys in the class, in the call? Yeah, yeah, Benjamin, do you get it?

33:24 B: Yeah, yes, ma'am.

33:25 C: Yes, I understand what you've been explaining.

33:27 A: Okay, cool, cool, cool. All right, so the interface. Sorry guys, if I'm slow. We're supposed to start writing code, but I really want us to understand what we are doing properly. So you don't just write mediocre code just because you know Cairo syntax, but you write code based on- you understand what the VM is. You know it's a CPU. a virtual CPU, and you know it uses, um, the same machine language. And that is why the compiler is doing the work, and then it's, um, it's compiled down to machine code and it is stored there. And it has a space and it's allocated, um, space to every item in the smart contract. Every variable in the smart contract stored in those slots that have been allocated. So when you are writing your code, you will not just write anyhow code just to make sure it is working and stuff. You will write code understanding economics, at least to some little part, understanding the computer, understanding the VM, and the best practices for writing the code. Please, that is why I'm really taking my time to explain this to you. So in case you feel it's boring, I'm sorry about that. I just want you guys to understand the background, the, the backend of things before you start writing your code properly. All right, so interfaces. Okay. Interfaces represent the blueprint of the contract. They define the functions that the contract exposes to the outside world. In Cairo, they are defined by annotating a trait. Um, guys, please give me a minute. Okay guys, please just give me 2 minutes. I just want to pick up a delivery outside. Can you hear me? Yes, ma'am. Yes. Okay, thank you. Okay, sorry about that. So, so sorry about that. I'm back. Okay, hope you can see my screen.

39:07 F: Yes.

39:10 A: Okay. So I was talking about interfaces. Interfaces represent the blueprint of the contract. They define the functions that the contract exposes to the outside world. So we all know what interface is. All contract interfaces use a generic type for the self parameter representing the contract state. We choose to name this generic parameter TContractState in our interface, but this is not enforced and any name can be chosen. In our interface, note the generic type TContractState of the self argument, which is passed by reference to the set function. Seeing the self argument, okay, note that- note the generic type TContractState of the self argument which is passed by reference to the self set function. This, this is the generic type What does this mean? It means this is a contract. You are referring to the state, the contract state. That means the state of this particular smart contract. This, whatever is inside here, must giving you- must be giving you values or giving you access to the state state of this current contract wherever this interface will be called. So that is what this means. Now it is saying here, um, that it is passed to self as a reference. Now in this, once you are setting, setting is a write function. Why is it a write function? It is a write function because you are changing the states. Whatever you pass in here is going to update the state from what the value of the current state is, or update the state meaning the state has not been initialized with anything yet. It is empty, and then whatever you set here will automatically be sent to state. So it is a write function, that is why it takes a reference. It is referencing this contract state. It is referencing the contract state. So anytime you see this reference, remember that we are referring to a write function. We are referring to something that is going to change the states of our contract. And when you see just self, the get function, it means it is giving you a snapshot of the current state of your contract. So you are just reading, you are not updating or writing to or instantiating a new destination, you're just reading. So for reading, it is just refer- it's just referring to self. But for writing, you have to reference the self and make the updates, make the change before it will get reflected. So this self is just the snapshot of the current state. It's just returning the current information in the state of this smart contract. While this returns the current information of the state smart contracts and gives you the ability to update that information in the states. Okay, I just hope we are understanding this. So where was I? Okay, here. Um, seeing the self argument passed in a contract function tells us that this function can access the state of the contract. The ref modifier implies that self may be modified, meaning that the storage variables of the contract may be modified inside the set function. On the other hand, the get function takes a snapshot of TContract state, which immediately tells us that it does not modify the state. And indeed, the compiler will complain if we try to modify storage inside the get function. So By leveraging the trait and implementation mechanism from Cairo, we can make sure that the actual implementation of the contract matches its interface. So we all understand what is going on here, right? Yes. Okay, cool. Is it just Emmanuel that is following? No, ma'am. Okay. Benjamin? I'm here. So do you understand what's going on?

45:27 C: Yes, I do.

45:30 A: Okay. Daniel?

45:32 D: Yeah, I have a question.

45:34 A: Okay, cool.

45:35 D: Okay, um, from the definition of interface, you said, um, it declares our function that we want the outside world to see. from the contract. Yes. So if let's say we have a smart contract and we are writing a private function, if we don't, uh, declare it in the interface, will this still work as it should? Or we have to declare it? A private function?

46:06 A: A private function.

46:12 D: Yes, ma'am.

46:12 A: The private function is private to that contract alone. Even if the contract is inherited, the children cannot even include private function. It is only within that function- that contract, sorry. So you cannot, you cannot add the private function to an interface.

46:38 D: Okay, okay.

46:39 A: Yeah, yeah, yeah, because interface is, is, um, is actually, um, giving you the concept of inheritance, but controlled inheritance where you inherit just what you want, just what you need, right? All

47:02 D: right, thank you.

47:02 A: Not the entirety. Yeah, yeah, yeah, you're welcome. Daniel, Daniel Joseph. Okay, Victoria, ask your question.

47:15 E: Okay, so is it like in Cairo, does the same public, external, and private also apply for interface? Because for Solidity, you have to do external. for the other contract to be able to see?

47:32 A: Yes, as long as it's in the interface, right, it has to be external. It's the same concept of smart contracts everywhere. The only difference is that because of the language, the lang- this language is more closer than Solidity, that is more high level. So it's just the, the language syntax that would change, but it's the same, um, background knowledge of smart contracts. It applies everywhere.

48:09 G: Yeah, that makes sense. Thank you.

48:11 A: You're welcome. Daniel Joseph. Is Daniel Joseph in this class? Yes, I am. I'm in a noisy place, that's why. Oh, if you're in a noisy place, can you hear me?

48:27 F: Yes, I'm using my earpiece.

48:30 A: Oh, um, Kemi? Kemi?

48:41 B: Yes, ma'am. Yeah.

48:43 A: So do you understand?

48:46 B: Yes, ma'am, I do. Thank you so much.

48:49 A: Okay. Okay, what about the ladies, Mary and IJ? Are you guys on the call? I don't really know everyone by name. Nefisat Abiodun, are you with us? Okay, at least most of us here understand what is going on, so yeah, I'll proceed. Um, Victoria, so here When you are implementing the interfaces, you have to add this flag. Before, it was external flag that was here, but it has been changed to ABI embed blah blah blah. So what does, what does this do? It makes sure that every function found inside this implementation is made external. That's what it does, so users can access it. Okay, so let's, let's proceed so we can start writing code. So it's almost 5. Oh, let me take this. Public functions defined in an implementation block In the context of StarkNet, a public function is a function that is exposed to the outside world. A public function can be called by anyone, either from outside a contract or from within the contract itself. In the example above, set and get are public functions. What we call an external function is a public function that can be directly invoked invoked through a StarkNet transaction, and that can mutate the state of the contract. Set is an external function because it can be called by anyone and it can mutate the state- that may change the state of the contract. A view function is a public function that is typically read-only and cannot mutate the state of the contract. However, this limitation is only enforced by the compiler and not by StarkNet itself. So we'll discuss the implement- implications of this in a later session. section. Get is a view function. Set is an external function. That means it is public and has the ability to change states, change the states of the smart contract. Now, um, okay, since the contract interface is defined as this, in order to match the interface, the public functions of the contract must be defined in an implementation of this trait, which allows us to make sure that the implementation of the contract matches its interface. So what this means is that in this implementation block here, any function you pass in here must have been- the function signature must have been called in the traits. If you try passing in any function here that wasn't specified in the trait, it is not going to compile. It will return an error. If you have 3 functions here, you have function set, function get, and you have function update, and you only write function set and function get in this implementation, your code will not compile because everything in this trait- this is an implementation of this trait, so it has to execute implement every function found in this trait. Okay, however, simply defining the functions in an implementation block is not enough. The implementation block must be annotated with the ABI embed V0 attribute. This attribute exposes the functions defined in this implement- implementation to the outside world. Forget to add it and your functions will not be callable from the outside. All functions defined in a block marked as this ABI embed are consequently public functions. Because the SimpleStory contract is defined as a module, we need to access the interface defined in the parent module. We can either bring it to the current scope with the use keyword or refer to it directly using super. So this is what it means. When we defined the trait, if you can see in this contract this trait is outside this module. So to be able to access this trait, you have to import it into this module. And to import it into the module, you can either use the use keyword or use the super Flag. Super, then double colon, and then call the name of the trait. Why? Because it is just an immediate parent, it is in the same file, so you can use super to call it. And you can use the use keyword to call it, and whatever you, you save it at the end, you just when you say implement SimpleStorage of whatever is the last item you saved it here, you just call it. You don't need to put super with the colon any longer. So that is what that part is trying to explain. When writing implementation of an interface, the self parameter in the trait method must be of type ContractState. Please take notes and understand this thing clearly. Don't confuse it when writing the implementation of an interface. So this is not referring to the trait now, it is referring to the implement part in the module when you are implementing that trait. The self parameter in the trait method must be of type ContractState. Remember, in the trait you wrote it as TContractState, right?

56:31 G: Yeah.

56:38 A: So you wrote it as TContractState. Now in the implementation you remove the T. You are now implementing it. It is no longer, um, generic. You are now implementing it. So you are removing the T from it and just calling the contract state. That is what this place is talking about. So the contract state type is generated by the compiler and gives access to the storage variables defined in the storage struct. Additionally, contract state gives us the ability to emit events. Hmm, the name contract state is not surprising as it's a representation of the contract's state, which is what we think of self in the contract interface trait when self is a snapshot of the contract state. Only read access is allowed and emitting events is not possible. So you understand what this place is talking about. So when we are, when we are, um, Okay, here. Additionally, contract state gives us the ability to emit events, but when it is a snapshot of contract state, only read access is allowed and emitting events is not possible. So with this Do you know that I've been working with events and I've not noticed this? So with this, it means that you can only emit events when you are changing states, but once you are getting the country, the snapshot of the state, you won't be able to emit events. Well, we're going to try it and see. All right, so to access and modify the contract state- now that means we are now implementing the functions, the set and get functions. The 2 methods are commonly used to access or modify the state of a contract. Read, which returns the value of the storage variable. This method is called on the variable itself and does not take any argument. self.storage.read, then write, which allows to write a new value in a storage slot. This method is also called on the variable itself and takes one argument, which is the value to be written. Note that write may take more than one argument Depending on the type of the storage variable. For example, writing on a mapping requires 2 arguments: the key and the value to be written, just like this: self stored_data.write, then passing the argument you want to write into the mapping here, or into the storage here. All right, so that is the overview. That is the anatomy of a smart contract. Do we have any questions?

60:19 E: So, uh, if I understand you correctly, yes. If I want to write interfaces, I have to use traits for the interface. Can I use traits without, um, like interface? Like, I just want to write normal traits instead of using interface.

60:41 A: You just want to write normal traits?

60:46 E: Like, this trait now, can it be only used under interfaces?

60:51 A: Yeah, what- that is what trait is majorly.

61:04 E: So if I want to declare a state, I must put that, um, what did they even call it that they said? This StackNet interface, I have to put it at the top. But let's always write treat. I can't write treat like just straight up like that, so I have to use-

61:20 A: yeah,

61:20 E: like I want to use treats like normally inside my code.

61:26 A: Okay, yes. No, you can work with traits. So you mean something like your TypeScript, right? How you just implement a trait. Yeah, yeah, you can implement your traits like that, but I really haven't done anything like that. I only did that, I think, once, and that was for a normal Cairo program. And I think Rust also. Yeah, but for a smart contract, if you are writing a smart contract, you cannot just implement traits. Trait is an interface. The trait is actually the interface. So just like your Solidity, when you want to write an interface of ERC-20, you put IERC20. In this one, it is the trait. In this, um, in Cairo, the smart contract, it is traits that you use to, um, define the function signatures that you want to be implemented.

62:32 E: This makes sense. Thank you.

62:37 A: You're welcome. Okay, any other question? The guys, ask questions now. What's going on?

62:50 F: Questions are coming, but not yet time.

63:03 A: The questions are what?

63:06 F: When we start doing the practicals.

63:14 A: All right, so everyone is clear? Like, it is very, very clear to us what I'm trying to explain, right?

63:21 F: Yes, yes, yes, it's clear.

63:27 A: Okay, all right, cool. So having explained that, my next task Okay, so that is the anatomy of a StarkNet smart contract. Here is building a StarkNet smart contract. So, um, at the anatomy, it explains a very, very simple StarkNet smart contract. So understanding that gives you the foundation you need to, to build upon when writing your StarkNet smart contracts, no matter how complex it will be. Starting from there gives you the foundation, and understanding it gives you more clarity when building your smart contracts. So in building StarkNet smart contracts, um, can I go through this? Okay, I can go through it. What is time? Okay. All right, so in this session we'll be taking a deeper look at the component of a smart contract. Step by step. When we discussed interfaces, we specified the difference between the 2 types of public functions, i.e., external functions and view functions, and we mentioned how to interact with the storage of a contract. At this point, you should have multiple questions that come to mind. How can I store more complex data types? How do I define internal/private functions? How can I emit events? How can I index them? Is there a way to reduce the boilerplate? Luckily, we'll be answering all these questions in this chapter considering these smart contracts. So this is a full smart contract, the reference smart contract for this chapter, and let's just go through it to understand what it's doing. Now, in the previous one, it just gave us a foundation of a smart contract, but in the reality, when you are writing a StarkNet smart contract, you start with this flag. on top your file. So use StarkNet contract address before you go to your interface flag where you put your traits or public traits, the name. And this one takes 3 functions: storeName, getName, and getOwner. storeName is a write function Because- and it takes in the parameter of name as a field 252. Um, we've done data types, right? You guys have done data types in Cairo, right?

66:52 D: Yes,

66:53 F: yes, yes, yes.

66:55 A: Okay, cool. So it takes name as a field 252. It takes registration type. Registration type is a Name registry type. So this name registry should be a complex data type. So we are going to check what, what this data type is. I'm sorry, we have function getName, which is just a snapshot of contract state. To get the name, you pass in the address. Address is a type of contract address. And then seeing this, it means that this function is meant to return- it's meant to return a float 252. That means it's meant to return the name. And the get owner is a It's just a snapshot of the contract state and returns from the name registry person. So either this is a struct- probably this is a struct. So name registry person, and here It is returning registration type from name registry. So when I say when you have this colon, what it means is that you are trying to access a function that is in another implementation block, right?

68:38 E: Yes, yes, yes,

68:42 A: yeah, yeah,

68:43 E: yeah. Well, this name registry is a module.

68:46 A: Exactly. So it is in another block from the traits. This is not here. So to access this trait here, you have to use super.this. So to access anything from here, you recall the name of the module and the name of the, of the item you are trying to access, like this. Name of the module and this. So I feel this is either a struct. I'm not sure it's a function, but let's go through it with it. Okay, so this is the module name registry. It is using StarkNet contract address, get caller address, storage, storage access, the storage base access address. It calls the struct flag storage flag, need struct storage, and this struct storage takes in the following field. Name- name is a mapping of contract address to 3252. Owner is a person, so I feel this person is a data type, so it is either a struct or something else. Registration type is a mapping of contract address to registration type, so this registration type too is also a Either a struct- it should be a struct. Then total names, total names is a uint128. So this is the information that will be stored to storage, and it is emitting an event. To emit this event, you need this flag called derive drop and the StarkNet event. So to emit an event, use an enum to specify the event. Stored name is a data type of stored name. Now this stored name would have to be a struct. So after specifying the event, they gave us the event and the data type in the enum. Now we have to implement this data type called stored name, and to implement this we use a struct. Also, mind you, you have to still call this flag derive_drop_stacknet_event. Well, when you call this struct stored name, you have to pass the key flag that serves like an index. Thank you. So taking in the user, the contract address of the user, and the name of the user. And if you have different events, if you want to emit more than one event, this enum event would have all the different events you want to emit. So stored_name will be stored_name, maybe write will be write, read will be read. Then the way you implemented the struct for the stored_name, you will implement this same thing for the different events and the various parameters you want the events to emit. Now also note that this struct stored name is not a storage struct. This struct has the storage flag. This is a storage struct. So everything here is either writing to or reading from the states. Okay, any other thing you define outside that is important, that is needed, you have to make sure you call it inside this storage to be inclusive here. So the things you cannot implement here that you want to do the computation outside the storage. They'll be done outside the storage, but then their value will be stored here finally. So we have stored name. Stored name is the event. Here we have derived drop, said stack net store, and we are calling a struct called person. It's passing the address and the name. Now we couldn't do this inside here because you don't want to- you want to remove most of the implementation. Oh yeah, is it implementation I'm trying to say, or computation, or whatever, from here? And also because we are trying to instantiate this as a mapping, legacy map only works in this storage struct. You can't call legacy map outside. So since legacy map is, um, is, um, what do you call it, um is a mapping that contains a key and a value. You can just do it this way where you have a struct that has a key and a value, and then you pass it here. So whenever you call owner, it will call person and return person to you. Here is an enum. Still passing the flag derive, drop, set, stacknet stop. Okay, this is for the registration type. Either it is a finite registration or an infinite registration, and then it is called here for registration type. So once you pass in the person's address you should see the registration type for the person. So all these extra structs, enums, or whatever help you to, to move most of the computations and complex stuff from the storage. You do them outside and finally pass the values here. Okay, so hope we are good. Um, next, constructor. Once you have a constructor in your code, you will have- you have to pass the constructor flag. Passing the constructor flag makes it know that this function you are calling or implementing is the constructor function. So this constructor takes in- is a reference constructor. Normally all, all constructors are referenced. Now they are write functions because the state is actually- is always initialized as empty. It's a constructor that puts the first inputs or the first values to state. So the constructor references itself and then takes in the owner before you can deploy it. So to, to instantiate this, you have to first call self.names.write. Self.names.write. So know that, yeah, anything in this constructor majorly is implemented from the storage struct. So it is only things from the storage struct that you can easily call, like this self.names.write. So we call this names is a mapping So it takes in 2- key and value. Key, contract address. Value, 3252. So once we call names.write, it takes the key, the owner.address, and then the value is owner.name. Remember, owner, right, is a person struct and it has address and name. So to get the address, you just say owner.address and owner.name. Then self.total_names.write, you pass in 1 because you are instantiating it now. Then self.owner.write owner. So what this means is you are instantiating this, passing this owner as the parameter to instantiate this struct- this constructor. Owner takes in 2 fields, 2 inputs. So whatever you write in the first input of owner, it will take it as the first item here, and whatever you write in the second, take it as second item here. Push these ones to names. So in this struct, names now have one person in it. Then self.total_names.write, it will come here. Total names, instead of it being 0, will now be 1. Then self.owner.write, this owner here. Anything you pass into owner will be passed here. So you've just instantiated the owner as a person. So you have passed, um, um, this thing value to address and to name for this particular owner. So anytime you pass the address of this owner, you are supposed to get the information of this person. All right, so instead, let me not confuse you guys too much. This is what the constructor does, it instantiates the values in the struct. Now we are going into the implementation of the traits. Of course, the store name, the get name, and the get owner. So store name is a reference to self. Now if you can remember, it had T contract state in the traits. Now in the implementation, you have to get rid of the T. Name is a field to survive to, and registration type is an enum called registration type. Now to instantiate this, you say let caller be equal to get caller address, and then self.store_name. You pass in the caller- uh, what is going on here? It is calling itself here. You pass in the caller, you pass in the name and the registration type. So what happens next?

82:06 C: I think store_name is an internal function. Like a private function.

82:20 A: Okay, unless there's a private function here that I would not see.

82:25 C: That's it.

82:27 A: Oh wait, oh okay, underscore. I just saw it. Okay, so it is self._store_name. I thought it was this one. All right. And then the function get_name, get_name, just self.names.read address. Whatever contact address you pass here, it will go to these names. You know, names is a mapping. It will pass the address here. If there's any address like this in the mapping, it will return the name for you. So self.names.read returns the name of the address you passed in. Then function get_owner is to return a person struct, so it will return self.owner.read. So who do you think- what do you think is going to be the output? Person. here. I'm not sure if you are following me.

83:41 F: So it's good, it's going to return the Person struct. So the name and the

83:59 A: name and

84:13 C: Guys, the name and the address.

84:15 A: Name and the address. Which name and address is he going to call the-

84:20 C: For the getOwner function, is the name and the owner of the person that deployed the contract, at least, or the name of the the name and the address of the person that actually, um, passed their name during the deployment as one of the constructor arguments.

84:35 A: Okay, thank you very much. I just wanted to be sure you are following. All right, so that the owner.read is going to return this person. here. So whoever is here, it will, will be returned here. All right, standalone quick function. This is an external function, function get contract name. Mind you, this is outside the module. Get contract name. So just the name of the contract. So you know this one, you don't need to do too much work for it. This is the name of the contract. You already know the name, it is not going to change. So it's, it's, it just, they just called it NameRegistry is the name of the contract. Okay, now this is a private, um, yeah, a private function, internal function. Now with internal function, we have something called generateTrait. When you pass this flag and you call generate_traits, you know what this external flag does, right? It makes this function external. Um, this generate_traits, what it does is Any, any, um, function you call, you implement here because this is an implementation of internal functions. Any function you call here, the generate_traits behind the scene will generate the traits for it. So you don't need to regenerate the trait for this. So whatever name you give this implementation, just know that the trait will be the same name plus trait. So we call this internal functions, so the trait name will be internal functions trait. Automatically generate trait will generate the trait for this private function. And what do you think it will generate, even though you are not seeing it on the contracts? Just looking at this and, and with the idea, with the whole story I've been telling you about, considering the VM, considering the compilation, everything that happens, what do you think could be generated here? During compile time as a trait for this.

88:04 C: The function signature for store_name-

88:14 A: Please, um, I don't want Benjamin to talk again. Sorry. I don't want Benjamin, Vicky, or Emmanuel to speak again, or Abraham. These 4, I don't want you to speak again. Sorry, I want another person. Once this gen- once this is compiled, what traits will be generated for this implementation? Emmanuel Okeke David Dada Kemi Oke Ajee Nefisat, Obiwa, Femi, Steve, one of you should answer this question. What trait will be generated here? Where are you getting- Someone said- Where are you getting address function from? Where is get address first? Are you trying to say this one? Get owner storage address. Is this what you mean? This is not part of our implementation if this is what you are referring to. And store name is not the way the trait is going to return it, judging by how the trait is being formed. So yes, you are halfway there. But this is not fully correct. Complete it. Kemi, what's going on? Ajee.

91:43 G: Hello, ma.

91:44 A: Mhm.

91:47 G: Yeah, sorry, I didn't get the question.

91:49 A: So I said, looking at this implementation, right? Yeah, the generate trait would automatically generate the trait for this implementation. So what-

92:02 B: I can't hear you.

92:06 G: All right,

92:11 B: sorry, I'm missing this.

92:14 A: Yeah, so I'm saying once the trait is generated for internal functions, what would the trait look like? Here we are implementing the trait. Okay, so what would this internal functions trait be? A std name?

92:43 G: Contract address. Tell me answer. You not tell me answer. You're not saying-

93:13 A: Wow, so you're asking someone for answer. Amazing. All right, um, David, you are so close. There's just one thing out. You've gotten everything, but one thing is off. One thing is not correct. Just one thing. If anybody knows what that thing is, please speak up. Anybody can speak now.

94:10 F: All right, um, he made mention of the contract state. It should have been a generic type instead of the actual contract state.

94:18 A: Thank you very much. So what was he supposed to change there? So what is it supposed to change here to make it a generic type?

94:32 F: Okay, sorry, the T contrasted.

94:38 A: So there we do get- well, this is cool. I'm happy you people are getting it. So here where you put ref self in the trait, it will be TContractState. It is in the implementation that you just call it, um, contract state. Okay, cool, nice, we are following. All right, so this is the implementation of the internal functions trait. And it's a store name, and it takes the contract address, 0x252, the name, and registration type. Then what does it do with it? Once it gets it, it creates a variable total_names and say total_names is equal to self.total_names.read. You know, total names- now at this point, our total name is 1, right? So that you- here, when we deploy this contract, in the constructor we set total name to be 1, right? You remember, right? So we have something in the total name. So now we want to add another information to the struct. We'll first read the what is in the struct, the total name, then self.names.write user and name. User will be this contract address. Name will be this field 252. Then self.registration_type.write, still pass the user contract address and pass the registration type that the user selected. Then self.total_names.write Will read the previous number of total names and add 1 to it so that it gets updated. So it will read what total name it currently, then add 1 to it. So at this point, the total name will be 2. Then self.emit. So now we want to emit the event called stored name, and stored name has user and name in the struct. So we pass the user address and we pass the username. So this implementation has been done in this internal function, and then we can call it here self.storeName, passing the caller here. It is supposed to be user, right? User is a contract address, and our user we are referring to is the caller. So in Solidity, in Cairo, getCallerAddress is similar to msg.sender. So whoever, whatever address is calling this function is the address they want to, um, be saved here as caller address, as a user. So this person address, and the person will pass in the name, and then the registration type will be passed in. And then this store_name function will be implemented. Okay, so that is the work of the store_name, and the work of the internal function is to get the implementation of this store_name so that it does the implementation. as an internal function and then passes this to the public function. Then there's also a free function, and this function doesn't have any flag attached to it. So without any flag attached to it, it might not not be accessible to the public, but it can be called within the contract. So get owner storage address is reading the snapshot of the state and is returning a storage base address. passing- calling self.owner.address. Okay, so owner is a person, so it's getting the address of the owner. So StorageBaseAddress was imported from storage_access. from StarkNet. Okay, cool. So they write in the storage access, to access the storage there's a storage base address. So I think what is going on here I'm not really sure. What do you guys think is going on there? Um, Vicky, you can speak.

100:59 E: Okay, so just to be clear, this generates traits. So that means you don't need to actually have that trait. Immediately you do the implementation, it generates the traits for you.

101:11 A: Yes, for only internal functions.

101:17 E: Only internal functions. Yes. Oh, I don't think I get it.

101:22 A: Like, only internal functions. If it's a- if it's a function you want to expose, you need to generate the traits, and then the implementation will be the functions in that trait. But it's an internal function that you are not exposing. So everything you implement here, generate_traits will generate a trait for it. But if it's like an external- you know, these functions, um, are external, right? They are public. You need to have generated the traits. You have to generate the traits for these. You cannot just use generate_traits for public functions. generate_traits flag only works with internal functions.

102:20 E: Okay, so if I'm just using it internally, that's in only my contract, why do I need the trait?

102:29 A: The trait is more like, like I said, is the interface. for your contract. So you can't- you really can't do anything within your contracts, or yeah, anything with your contract without an interface. There has to be a structure as to how that function will be defined or called. Because, um, I'm not so sure of this, but everything at the backend works with function signatures, and that is what is checking the correctness of your implementation. So if your implementation is not following the, the correct function signature that has been defined, it will return an error. Because it's expecting a specific type. So for the interface to, to work, for your implementations to work, it needs an interface. The interface defines the structure of all the functions that will be called in your smart contract and The- and then will be implemented later on. So for this one, you don't need to define it, but if you want to define it, fine. But there's already a predefined method that is stored in this flag that helps you to define your traits, your internal traits. This is a public trait, so it is- this will only generate a trait for you for this internal function. All the functions that are listed in this internal implementation, the trait will be generated for you because it has already been abstracted and called in this generate_traits flag. But this works with internal. Yes?

104:47 E: So otherwise

104:48 D: Yeah, this was exactly what I was asking about earlier for the internal functions. Okay, thank you.

105:01 A: Um, Victoria?

105:02 E: Okay, so all my functions, right, would have to be inside an implement that- I can't have like a function just be on its own? Because

105:18 A: you can't- like this function we see here.

105:21 E: So the- my idea of interfaces, right, is that you, you use it as a structure so that anyone that wants to use your, your contracts can just, um, get the interface and get the you know, contract address and, you know, just implement it just like this in Solidity. But now I'm seeing that I'm generating traits for private function. Like, why do I need, um, interface for a private function since other contracts will not be able to see it to implement it? It gets- I don't know if I'm making sense.

106:03 A: Yes, yeah, you're making serious sense. I'm making serious sense. Okay, let's check why private interface is needed, right? I don't really- I didn't really pay attention to it, so let's check it out. So it, it was explained It was explained somewhere around here. Private functions. So let's, let's understand it. Functions that are not defined with the external flag or inside a block. annotated with this are private functions, also called internal functions. They can only be called from within the contract. They can be grouped in a dedicated implementation block in components, or easily import internal function all at once in the embedding contract, or just be added as free functions inside the contract module. Note that these 2 methods are equivalent. Just choose the one that makes your code more readable and easy to use. So what are the 2 methods? This could be a group of functions about the same topic, or this, it could be a free function. So what is generate_traits attribute? Where is the trait definition for this implementation? generate_traits attribute is a special attribute that tells the compiler to generate a trait definition for the implementation block. This allows you to get rid of the boilerplate code of defining a trait with generic parameters and implementing it for the implementation block. With this attribute, we can simply define the implementation block directly without any generic parameter and use self as contract state in our functions. The generate trait attribute is mostly used to define private implementation blocks. It might also be used in addition to ABI per item to define the various entry points of a contract. So you can see this next session using generate trait in addition to ABI embed attribute for a public implementation block is not recommended, as it will result in a failure to generate the corresponding ABI. Public functions should only be defined in an implementation block annotated with @GenerateTrait if this block is also annotated with the ABI per per item attributes. Okay, so you can use generate trait for your public implementations also based on this, but it is not recommended. As you can see here, it is, um, used for private implementation blocks, and using the generate trait gives us this self in our functions. So if you can remember, when we wanted to call- when we were implementing store_name, we used self._store_name. It gave us the access to just use self._store_name because it was defined here. But then I'm looking for where this was called so we see the difference. So if you don't want to use traits to reduce your boilerplate code, this is what you do. You don't declare the trait anymore in your mode- your module. You put your flag ABI per item and then generate traits, then the implementation. Your constructor, and then for every function you pass into this, if you want that function to be public, you add this flag external attribute to make it public. So if you are using this method, you have to- you can implement both your private and, um, and public functions in the same implementation block. The difference will be the flag you will be passing to it. So if you don't pass any flag, it is an internal function. But if you pass this flag, then it is a public function. So if it has a ref, that means it is a write. And if it doesn't have a ref, that means it's a view function, view public function. So yeah, I think with this we, we have gotten the whole use of generate_traits, but it is majorly used with these internal functions. Because if you check standard codes of serious projects in the ecosystem, they don't do it that other way. Unless maybe new projects are coming or some security threats and stuff that makes them implement it, or maybe they just want to just do some crazy stuff and then they implement it the other way. But this is the standard for writing smart contracts. At least it is more readable and understandable. Imagine seeing this as they start. Where are you? Imagine seeing this at the start. Do you- would you understand what is going on here if you've not understood the concept of the traits, generate traits, ABI per item, external? You wouldn't understand what is happening here, right? Or would you? It doesn't look readable. Am I talking to myself? No.

113:33 F: No, no, no. Yeah,

113:36 A: so if you look, if you see it this way, it doesn't really look readable and understandable. It needs someone that has really been writing the code to understand what is really going on here. But with this, it's still not very readable, but you have an idea. you see that it is called an interface, and then you see it implemented here in this implementation. You see the constructor and stuff. It makes it easier to understand what is happening here. You see it is, it is calling this function, and then you see the function here. So without understanding so much about Cairo, you can kind of deduce what is going on here because it is more readable. But once you're an OG like Victoria, then you can write it the other way. So I'm trying to understand, I'm trying to see where this was called, I'm trying to see where this was used, because if it isn't called anywhere, you can't call it once it's deployed. You won't even see it. Because it's an internal function. You only see it in- those are internal transactions. I don't think you'll see it. Was this called anywhere? It wasn't, right? Get owner storage address. It wasn't called anywhere here. Okay, so it wasn't called anywhere here. Storage base address, it wasn't called anywhere here. Yeah, all right, we're going to find out what that is used That last function. Okay, so next, so far, are we clear? Is there any other question? No. Any further questions? If not, then are we good to go? Should we start writing our smartphone chat? Yes. It's only Vicky and Emmanuel that is in this class today. What's going on? Are we tired? It seems I've talked too much.

116:31 F: No, no, for the

116:33 A: action. Okay, is this readable? I'm sure this is readable, right?

117:05 F: Yes.

117:06 A: Okay, so we want to bootstrap a new Cairo project. So what do we- how do we create a new Cairo project? So we are sure we are following. So call it for me while I type it.

117:22 D: Start new.

117:24 A: Oh, who said that? Benjamin. It's Abraham. Abraham. Okay, cool. Okay, so what is the name of the project? What name should we give the project?

117:42 D: Our First Smart Contract.

118:01 A: Okay, cool. We have instantiated our first smart contract. So new window. Okay, I think this is, this is readable, right?

118:34 E: Yes.

118:42 A: Okay, thank you. So what is the, what is the next thing we need to do?

118:48 D: Edit our TOML.

118:51 A: Thank you. So what should we add?

118:55 D: Under dependency, to add our StackNet

119:05 F: and then the targets.

119:06 A: Okay. So we are adding this, we're adding this to the dependencies, and then we are adding the targets to compile to server. And we save. Okay. So src/lib.chiro, don't need all these things. Okay, so first thing you do, use StackNet. So what are we calling?

120:08 D: Contract.

120:11 A: So the next thing is our traits. So before we call the traits, it has a flag. And the flag is called StarkNet- what?

120:34 D: Interface.

120:36 A: Is this correct?

120:37 C: Yes, that's correct.

120:41 A: Okay. Do we need anything else? Why is it crying? Um, see, doesn't need anything else. So okay, let's just call it traits. So what are we building? What is our first contract about? Give me ideas now.

121:38 F: Let's see.

121:50 A: What? What? Who is speaking?

121:56 E: Get name.

121:57 A: Get name.

121:58 E: And set name.

122:00 A: And set name.

122:01 F: Let's do to-do list.

122:06 E: Oh yes, to-do list.

122:09 A: Okay, to-do list. Okay. Why are you shouting?

122:39 E: Maybe I'm supposed to use public.

122:49 A: Yeah, so what are the functions for to-do list that are needed? Add to-do, right? Right?

123:13 F: Yes.

123:15 A: I need to add it to-do and name. Does it take any parameter? Um, to add a to-do, what does it need? It just needs description, right?

123:41 C: Yes, and maybe deadline if you want to add that.

123:45 E: Name and description,

123:48 F: right?

123:53 A: What is the deal for? Okay, to tie the to-do to a person.

124:04 F: Title, title of the to-do.

124:09 A: Yeah, what's the title? What do you mean by title? If there's a description What do you need title for?

124:27 E: Just like the general idea of what the to-do is about.

124:29 F: Like a header.

124:32 A: I'm not- you know, if you say number 1 and then the name of the to-do you have to do. And then the next thing you see is the- is if you've done it or not. So I don't understand what you mean by title. Can you like explain? We're adding a to-do now to a list. So what is the title there for? Is it like- what is it for? I think what we need majorly is just the description, right? And deadline for Yes, yes. Okay, so description of the to-do and deadline. And deadline is what? What data type is deadline?

125:33 C: U32.

125:38 D: New size.

125:39 A: New size. And then the deadline will be returned as an epoch time now, right?

125:49 C: Yes.

125:51 A: Uint32 can handle- can Uint32 handle epoch size? The current epoch size? Can someone check? 1 times 2- is it 1 times 2 raised to power 32 minus 1? 2 raised to power 32. Uh, what am I doing?

126:23 C: Epoch time is actually in 32 bits.

126:34 A: Yeah, but it keeps on increasing. Epoch time is, is seconds, is the number of seconds since the world started. So As long as the project continues, the epoch time is going to increase. So if they want to use this project in the next 20 years, epoch time might have grown from unit 32 to unit 64. I'm just saying, what is the current epoch time? Is it within the range of unit 32 at the moment? So we got-

127:22 C: it's actually within the range of uint32, but I think after like 20 years it should expire, like should go bubby. I don't think it's up to 20 years again.

127:31 A: Okay,

127:35 C: so,

127:37 A: okay, so we add todo. Are we expecting it to return anything once we add It should return a boolean, right? So what's other function?

127:59 F: You can update.

128:05 D: That's good.

128:06 F: That's the good one.

128:07 A: Update. So if you want to update- What? Description and deadline. Okay, then someone said getTodo, right?

128:52 F: Yeah.

128:55 A: So if the getTodo, because it's a list, it should probably be an array. So this will get to those first, and then self, let's see, contract state. We don't need to pass anything, and then it returns what? Uh, what is- how do you call it? I really- how's I trade on you?

129:49 F: I think-

129:53 C: okay, I read without- yeah, I read without the trade. I think- I don't know.

129:59 D: About-

130:00 A: We'll check the- we'll check the documentation. Anything wrong there, fix it. So function getTodo, self,@ And then we pass the index, right?

130:29 D: Yes.

130:31 A: Index would naturally not be more than- so what will we return?

130:42 D: It's dropped. Yeah,

130:46 A: it's supposed to return is dropped. Okay, let's just, let's just proceed, then we'll come back to this. So once you want to update, update also needs the index of the particular todo we want to update, right? Yes. Okay, so we are sure of the first 2, but the last 2, ain't too sure about that. So what is the next thing? Start next. Contract.

131:49 D: Contract.

131:50 A: Okay, cool. So next mode, to-do. The mode to-do. And in this we have our storage, we have our struct. So even though you do not implement structs, you can just leave it like this. If not, your code will not compile if you don't have a struct. a storage struct, right, in your Cairo code, it will not compile. So we'll still use this in the mode, and then next, Todo, we don't need to instantiate it with anything from the beginning. We do not need a constructor because it's not supposed to have any information, right?

133:02 D: We can set owner sha.

133:08 A: What?

133:10 D: Can initialize owner.

133:12 A: Can initialize owner. Why do we want to do that?

133:23 D: So, you now will be the only one that will be able to update some things.

133:27 A: Okay, okay, cool. So, User contract address. Okay, so we can either use the caller at this point using get caller address. But it seems it is slightly different when you're working with get caller address when it comes to deploy. Let's just

135:07 D: You have to import it to use it.

135:09 A: Yes, we have to import it. Um, I'm just thinking, let's just do it. If we encounter any error, fix it. So, get- why is it not auto-completing? Just call our address. So I think I want to write something here because I want to check properly. Owner, the contract address. So let's caller will be equal to get_caller_address, and then self.owner.write. We don't need this anymore if we're using caller_address. Sorry, but I don't think that will work because the caller will be the deployer, universal deployer. Exactly. So that's why we need the owner. That is who will be the owner. That's why we need the owner in the constructor, but we don't need the caller for this step. It's what we are trying to check. That's what I was thinking. The address will be the universal deployer.

136:44 D: We'll have to add code, the owner.

136:48 A: The owner. Yeah, so I have to hardcode the owner. Okay, so this is all we need for the constructor. Okay, that's all we need, right? Are you guys still with me? Yes, yes, yes. Okay, so next, what's next?

137:55 D: Yeah, our public functions.

137:57 A: Okay, cool. So how do we start?

138:02 D: So we have ABI, blah blah blah.

138:06 A: Then embed, right?

138:10 D: Yes, that's called v0.

138:12 A: v0, like this?

138:21 D: I'm not sure.

138:23 A: Yes, why did we use v0? On task. Okay, I don't know what's up. Let's continue. Okay, so now we are implementing to-do lists. Is it for off? So I was saying we could use the use, use our first smart contract. Or colon colon lib colon colon todo list, ITodoList here, or we can just write super. And here we are setting it to Okay, so another thing we need to do is create a folder. a file called todo.kyro. Sorry, I forgot that was the first thing we're supposed to do once we came here. So everything we copied here, cut it and paste it here. Your todo- lib.kyro is where you add your modifier. So we are adding mode todo, so it's going to be reading this todo file for us. So I hope you guys got what I just did. All right, so the first thing we want to do is implement AddTodo. And to add todo, I'll just copy this. So, so I have to do- where are we adding it? Where are we meant to add the to-do, the new to-do to? So which document are we sending to?

142:00 F: I think we need a struct actually to-

142:04 A: okay, okay. So in this struct we can have something called TodoList, right?

142:15 D: An array of TodoList, right?

142:18 A: Yeah, so it's not- we cannot, um, have an array in the structs, but we can have a legacy map. We can have a mapping.

142:34 D: Sorry, I have a question.

142:39 A: Yeah,

142:39 D: what's the difference between this legacy map and dictionary?

142:48 A: Legacy map is your normal mapping in a normal mapping. Dictionary also helps you to do mapping, but not in the struct, not in storage. So map, yes, helps you to do your- add your mapping to storage directly. But dictionary, you can do your- you can do it outside. And then the value you send to one of the, one of the variables that will hold the results in the storage struct.

143:28 D: Okay.

143:30 A: Yeah, so for todo list, so what are we supposed to pass Todo list should have- if you take a uint8, right?

143:47 D: Index. Yeah,

143:49 A: that's the index. And what's the value?

143:56 D: Struct of todos, I think.

143:58 A: So todos. Okay, so I need to create a struct. And to create a struct, what was the flag? Just derive, right? And we're deriving what? Drop. You guys said, right? And we derive- was it start, next, stop? Was it stop? Yeah. Okay, let's just check it. Is it this one? I think here. Sorry. Okay, yeah, this. So derived DropSet and StackNetStore. So this Drop should be capital and then make it a public- but why is pub giving me issues? So struct todos, should it be todos or- because is this list that should hold The entire to-dos, right? If I'm correct.

145:56 F: Yes, yes, yes.

145:57 A: With the to-do, and the to-do will take the description, right? Take the description.

146:10 D: Headline.

146:13 A: Description is a field. 25. I should take a deadline of unit 32. Um, now that should be all right. And what else? How do we make sure? This value,

147:15 D: you can have, um, like something like an ID inside the struct.

147:19 A: This struct?

147:22 D: Yes, you can add like ID so, so you are able to track what to do. Exactly.

147:36 A: Okay, cool. So we use the ID as the,

147:42 D: as the

147:42 A: key. Okay, cool. All right, so next, should we do the implementation here, or let's do the implementation in an internal trait? Okay, let's do it in Anita now so we get fully used to everything, right? Yes. And I'll start our learning in the right track. Generate straight. Okay. So we are implementing private implementation of private implementation traits, and we need function_add. To do the same information. I need to return when you think I'm returning the main. Okay, so to implement adding to-do. What do we need to do? So call self.description, right? Self- sorry, what is the name?

150:07 D: To-do list.

150:08 A: Self.todo_list. .write. Now what are we writing? So ID, how do we track this ID? Can

150:35 D: be, uh,

150:36 A: 0. The 0?

150:39 D: You can start from 1 or 0.

150:42 A: We are meant to read from this. How do we read this struct? Can we read like this?

150:56 F: Yeah, you can actually, um, yeah, we

150:59 D: can do that.

151:01 F: I

151:02 D: said

151:06 F: self.todo_list. Yeah, from the storage.

151:15 A: This one?

151:19 F: Yes.

151:21 A: Okay, cool, cool, cool. So self.todo_list. .read. So what are we reading? To read, we still need to pass in the index, and I'm trying to get the index.

151:35 C: Okay, sorry, but if you want to do that, depend- and based on this, our- what do you call it- the way we are implementing it, we need to like have, uh, what do you call it now, a variable tracking this index.

151:51 A: This is what they used. We were using this to track how many people-

152:00 D: You can do this, you can have it.

152:03 A: Can you see?

152:07 D: Yes, yes.

152:09 A: Like they use this to track how many registrations had happened.

152:15 D: Yes, you can have it outside. So as we are In adding todo, it will be incrementing.

152:21 A: Yes, so to save us, um, stress, so let's call it todo_id. Todo_id should be a uint8. So At this point, we would be reading todo_id instead. Please, hope the rest are following me. Yes. Okay, so now we've read what todo_id is at this point. The next thing is to write So self.todo_list.write ID. What is, what is it taking? Todo_list is only taking

153:28 D: ID and destruct.

153:30 A: And destruct. Okay, so that is ID. Whatever ID is plus- no, no, no, it will be self. Sorry. Once we've read it, then- ID plus 1. Current, current ID, right? Equal to ID

154:13 D: plus 1.

154:13 A: Plus 1. So that is what we'll pass in here, current ID. Then

154:33 D: Can't we save, um, like, like using the key and we can say, um, let variable equal, uh, legacy and the todo list so that we will be able to initialize our variables? I think.

154:48 A: Yes, yes, as he instead, so something like This, right, where we said- where we called owner as the variable and calling-

155:01 D: yes, owner.name, owner.start.

155:04 A: So for here, but let's see. Okay.

155:14 D: We want to save it inside the variable first.

155:17 A: So what should we call it? Todo should be the Todo struct.

155:28 D: Yes.

155:30 A: Okay, so current ID, um, um, So do we need this ID here? So let me be sure what is going on here. We have another address, another name, and this takes in, um, todo list takes in This and the todo. So is it-

156:17 F: The second parameter should be the struct.

156:20 A: Yes, so that means we should initialize the struct first.

156:28 D: Yes, that's what I'm saying. First create, initialize the variable for the struct.

156:39 A: Equals todo, right?

156:43 D: Yes.

156:44 A: And then we'll just pass it. What is ID? Should be current ID. Um, description.

157:06 D: You have to bring back those arguments. That's okay. Todo.description.

157:15 A: Yes, or you can just do it this way. If not, we'll pass it here as What is the best way to- what is the best way to do this?

157:32 G: Instead of description, you can just say todo.

157:38 A: Yeah, todo.description, right?

157:42 G: Todo.column, todo.column todo.

157:48 D: But won't the 2 todos be shadowing each other?

157:55 F: Yeah, that is shadowing here because

158:00 A: we can- let's

158:05 D: see. There's a todo in our parameter.

158:07 G: Maybe we don't even need to add another like

158:14 A: this

158:14 G: and just bring in that one instead. No need of it to do. Dots, anything. Can just use the todo that is in the parameter.

158:24 D: Okay, you can just, yes, write it straight to the todo.

158:28 G: Yeah, write straight, yes.

158:29 F: Yeah, but, um, the current ID should be defined inside that struct.

158:35 A: Yes.

158:38 D: Yeah, that's true, that's true. That's another thing to consider.

158:46 A: ID. So we need to initialize that Todo first.

158:50 D: We need to initialize that.

158:52 A: So let's, let's follow this and see how they initialized it. It just wrote the address and name, and this owner only needed address and name, and this, our TodoList needs Okay, we need description and deadline. Okay, and Description and deadline. Description and deadline. Then we need, um, something else. ID and to-do. So our to-do list needs description and deadline, ID and to-do. Or we can make this a 2D mapping instead. So As a 2D mapping, it takes in, it takes in the- it doesn't need- it's not supposed to be a 2D mapping. So suppose if it's a 2D mapping, then that is when we can easily initialize this, then this.

160:48 C: But I'm sorry, but I think we can, we, we can just define the todo normally and then we'll just write it into the legacy map the normal way, self.todos.write, the ID and then the legacy map. But first of all, we need to define the todo itself. So maybe instead of passing the todo directly as a struct, except maybe you want to generate the todo inside the addTodo function and then pass the Todo struct directly, or we just pass description and the deadline?

161:24 A: Yes, let's see this first. So let todo be equal to- so I think, um, ID. So ID should be current ID. Then description should be description passed, and deadline should be the deadline passed. So here,

162:17 C: can just pass our todo here.

162:19 A: Just pass todo. This is supposed to work if everything is okay. This is supposed to work. Okay, so here Where we have add todo, we'll just call self.addTodo and pass description. That's what it needs. and deadline, right? And we'll return true because returning a Boolean. Ah, okay. Um. So, okay, so what next? Let me add a function. Let me add a normal function to read this to-do list. So this function is to get todos, but if we are returning it, if we are calling it, we need to add a key, right?

164:14 C: It's true.

164:21 A: If we are returning this, okay, yeah, if we are returning this, we need, we need the keys to be returned. So you, you get what I'm trying to say, right?

164:35 F: Yeah, we can actually create an array, an array that we can push this struct to each time we create it.

164:50 A: Cool. Okay, so the next one, let's just get todos. You need to get todos. Okay, so to get our todos- Sorry, remove this and this. So we need to import array. So use- I think it's for array. You can check it so that we are sure we are on the right track. So to get- okay, let's todos be array, create new, right? So initialize todos as an array. So the next thing is we want to read, and to read We want to use index to read, so we can do a loop. So i- or does it work without this?

167:12 F: It's just to define the keyword loop.

167:15 A: Yeah, sorry, Omo, my brain. Sorry. Okay, so we loop, and in the loop- so what are we doing? What's the next step?

167:42 C: I think we need to define 2 variables outside.

167:47 A: Yes,

167:48 C: one will be the total todo count, and then the second one will be the index that we'll be using to, um, reach the-

167:54 A: So what is the count?

168:15 C: Count to be self.read- I mean, self.use_count. I mean, how do we call it? Um,

168:31 A: to-do_id.read. Okay, cool. So what is the next

168:39 D: problem now? Is after our add to We did not increment todo_id.

168:42 A: Yes, we incremented it before adding.

168:51 D: Yeah, yeah, but it will not reflect on the todo_id in the struct.

168:57 A: Sorry, this was just reading. Okay, so that's the last thing. Actually thought this was self.blah blah blah read writes. Thank you for reminding me. The writes current ID.

169:24 D: Yeah.

169:25 A: Okay, so it's complete. So

169:32 F: Here, what you said?

169:44 A: Can anybody say something?

169:46 F: No, you can go ahead.

169:48 A: So, um, let me quickly check the loop function to be sure I'm on track. Is there anything for looping?

170:02 C: General programming concepts. I mean, common programming concepts rather. Number 2. Number 2.

170:17 A: Okay, thank you. Okay, so we'll be checking if index is less than, um, if index is less than current count, current count plus 1. Should it be current count plus 1?

171:15 D: You can use while instead. While is easier.

171:18 A: While index is less than- And just

171:22 D: say while, uh, index is less

171:24 A: than current count plus 1. So hope we are together.

171:35 D: No, while is another loop on its own. So instead of using loop, you can use while.

171:46 A: While is another loop?

171:49 D: Yes.

171:51 A: Okay, this. So while- okay, cool. I'm feeling, I'm feeling weird about this. Okay, while index is less than count plus 1. Okay, while index is less than count plus 1, append. Um, should it- should we append now? Let Let's read be equal to self.todo_list.read, right?

172:47 D: Yes, index.

172:50 C: And it's only the index we need.

172:59 A: Yeah, it's just the index. Thank you. Let's go read, then produce.

173:07 G: Oh, is read not a keyword? It's not giving us error.

173:11 F: It is.

173:12 G: Let's, uh, let's read to-do.

173:17 A: Okay, so the next thing is to-do. Dot append grid to do. Then there's no break. Index,

173:53 D: then increment. But I don't understand why we are doing count plus 1.

174:04 H: Plus 1,

174:07 A: you know, index is less than count, it will never be equal to count. Or should we put while index is less than or equal to No,

174:20 D: but when it gets to equal to count, it will stop, right?

174:23 H: Yes, it should stop.

174:26 A: If we use less than, it will never get to- it will never be equal to count.

174:32 H: But since index is starting at 0, why is she- why is it like +1 again?

174:38 C: I think the problem is coming from the way we actually implemented it. the index should actually even start from 1 from our implementation because the first ID we'll be having when we start is 1. So I think if we want to have it start from 0, we have to move the addition after the, um, this thing. So here we, we can stop at count plus 1 because that particular index at that moment is the last item on the todo. Because of you implemented it actually.

175:13 H: Oh, oh, oh, oh, I get it now. So the, um,

175:22 A: we didn't implement ID to start from 1, we just read it and just added 1 to it. Where whatever it is, array start from 0, index start from 0. An index in an array, country index.

175:43 H: Index starts from 0. Since index starts from 0, then we don't need to

175:49 A: plus 1. Do you, do you get what I'm saying? Yes, actually start from 0. But here we are passing the ID as 1, and we are setting it into this todo and into that, um, our, our storage struct. So if it is 0, it is actually not 1, and that is why I am adding +1. So once it's So whatever the last count is,

176:37 D: the plus 1 I was asking about was the first one in the while.

176:40 A: Yes. Now this, in this while, yes, that one we are reading. Okay, what is todo_id?

176:54 H: So index should be 1. Index, our index should be 1 in this, um, get to those then.

177:01 A: Oh,

177:01 H: since, uh, since our starting point is 1, we

177:04 A: started- Okay, this is where we started. Thank you. Yeah, we don't need it. We don't need the +1.

177:13 H: We need, we, we need it, ma. We need it based on, say, based on the fact that our index is starting at 1. Oh, oh, since it's an array. Yes, yes, yes, yes, yes, yes. Sorry, sorry, sorry, sorry. Yes, yes, yes.

177:31 C: I'm sorry, I think we're actually using this thing. I'm sorry, but we are actually reading from a legacy map. And like I'm saying, like I was saying, it is because of our implementation. That is why we are having needs to add this +1. Sorry, ma, please, if we don't, if we don't want to add this +1, right, we need to do this current ID addition after.

178:00 H: After, yes, yes, yes.

178:03 C: Not before. So if we don't want that +1, we just move this current ID addition downward. So we'll be using the ID as the ID of the todo, then after that we can update it.

178:14 H: Yes, yes, yes, yes.

178:23 A: Are we okay now?

178:24 C: You have to add +1 to the count.

178:27 H: We need the +1. We need the +1 now.

178:28 C: Also, one last thing, then you need to make index mutable.

178:35 A: Thank you.

178:37 D: Yes. data type because I discovered you cannot do greater than and less than with data type.

178:49 A: Data type of what?

178:53 D: The index, uh, index and count.

178:58 A: Okay, we did not set data type, right?

179:08 D: Yes,

179:08 A: data type of count. Is that what you are saying? Hello?

179:24 D: Hello? Data type of count and index.

179:26 A: Count is uint8. Okay,

179:31 D: okay, okay, okay. So we need to change index. We need to get it to you quick, you know, you'll not be able to-

179:42 A: Are we okay now? Yes. Why did I get error? Okay, so I just want to I just want to try to test this, just these 2, to addTodo and to getTodo.

180:09 F: But the append, the append you called actually adds-

180:17 A: Actually what?

180:26 F: I think it actually adds to an array, just the way we have push, they append.

180:32 A: Yes, yes, that's what it does. So what are you trying to say?

180:45 F: I, I thought we are actually Getting instead of inserting.

180:56 A: Yes, now we are getting, but to get is a mapping, so we have to push the items into an array so that we can easily read the array.

181:08 F: Okay, okay, okay, okay, okay,

181:10 A: okay. So we'll now return the array to be able to read what we push to the mapping.

181:20 F: Okay, okay.

181:20 A: Yeah, somebody raise your hand. Okay, so, okay, let's try this out. Um, we hope everything is okay. So once you've written your code, the next thing to do is to build. Okay, now this is the main problem- version conflicts. So we used, um, our smart contract version 1 cannot use StarkNet version 2.2.0 because it requires StarkNet version 2.6.3. So I need to update my stack in case you guys come Yes, this error, you need to update your SCAB. Oh, I think we have SCAB here. Okay, okay. Let me use this 2.6.3. Um, when is your- when is your next class? Next week, Wednesday. Next week Wednesday. Now, when is the class supposed to end? I can't hear you. 7. Oh, so I'm eating into your time. No worries, no worries. Thank you. Okay, so it's taking some time to Okay, so let's check. Oops. Okay, please work. Okay, so let's correct our errors. So our first- okay, so So for the return type of implementation function, ITodoListDispatcher.GetTodos is incompatible with ITodoListDispatcher trait. getTodos expected an array, actual-

186:35 F: Yeah, you can define the type of data the array will contain. Yeah, using the arrow.

186:49 A: So What should it contain? Todos. Or you want it to return todos? Is returning todos? Is returning To do. Okay, so

187:32 F: next type

187:34 A: what

187:36 F: also at the interface.

187:45 A: Type annotation. That's it. Type annotation needed. Okay, next. Array, array, array. Okay, so I think array is the culprit. Then what is this? Okay, so let's see if this works. It doesn't. We have to go and check how to call an array. Okay, so missing semicolon line 51. Am I supposed to- okay, and then todos.append, ref argument must be a mutable variable. This must be a mutable variable, the array. And what else? Okay, so let's Okay, variable not dropped. Oh, do you need it to be dropped? Guys, let's check how to call an array properly. I'm trying to see how to return an array. If anyone has seen it, please, please let me know. So don't waste so much time. Are you guys with me? Okay.

191:19 D: Yes, yes, yes.

191:57 C: I just sent a link to Cairo by Example.

192:01 A: Okay, okay. So I retreat, and this retreat new. Well, we are on track. We are actually on track with this. Um,

192:31 C: I think the reason why it's saying that dropped something is because that drop attribute- What? I think the drop attribute was added to the traits. That is why you need to import the traits to use that like array as a return type.

192:52 A: What do you mean import the traits?

192:54 C: Sorry, that use array, then just array. Yes, some of this supposed to work.

193:03 A: Yeah, so okay, so it's not an array. Um, so this will- it will be an array of Of different to-do. Why is this a problem?

193:45 C: Sorry, please can you go to your, um, your traits, first one? Um, you are not- you should use Todo, like in use Todo, um, Todo, Todo, the struct, because it does not know the struct inside Todo. module. So like the line, line 7, now this todo inside your array, it does not know it's this, um, your traits.

194:22 A: Oh yeah, thank you. Yes, yes, yes, yes. Wow. And I pointed that out. How did I forget? Okay, hey, okay, we did it! Thank you so much. So the error, the first error was my stub version. And the second error was because we're calling a function inside this mode, a function inside this module. And so we had to, um, reference it this way. So yeah, guys, so hope you, you understand what I just did, what we just did.

195:23 F: Yes, yes.

195:29 A: Okay. So next is- I would have loved to test this, but our time is really, really up. So maybe in our next class, if, if I have a class with you guys, someone else will be taking you guys on testing. So I think I should just complete this. There was no quick- there's no quick way to actually test it. We have to write another Testing 5, like another contract for testing, unlike normal Cairo programs. So I'm sorry, let's quickly update and then get. So to get todo won't be as tough as this because it's already taking the index. So to implement this, all we have to do is- all we have to do is self.todo_list .read, and we'll pass the index. And that's all. Do we agree? Yeah. Okay. Um, the ladies, are you still on the call? Yeah. Yes. Are you following? Or did you get confused? Um,

197:43 G: yeah, I got confused along the way, but I'll find myself.

197:47 A: Very sorry about that. That's the problem with Cairo. Um, Benjamin, you've not been talking. David,

198:00 C: um,

198:02 A: okay. Yeah, okay, true. Sorry. So you are following, right? Everything is going well. Then David. David, how is it going? Oh, great. Nice. Um, who was with us from the beginning? Ajay, is Ajay still with us? Ajay, are you still on the call?

198:37 F: Yes, he's still, he's still on the call, but his laptop's, um, mic got spoiled.

198:46 A: Wow. Um, Abel, are they focused? Ajeez, enough. Abel. Nicholas. Yes, Daniel. Daniel Joseph. Yes, I'm still on transit. Wow. Okay, Nicholas. Ah, all of you are getting it, so it's only, only Vicky that don't get it. You're going to write assessment though. I'm going to do a test. No, no, no, no. If you don't get it, better to say you didn't get it too. There's an assessment like immediately after this class. Okay. Okay, all right, it's fine, Abel. But people said you got it, why are you shocked? So, so the assessment- because I'm, I'm really sorry I'm entering into your time- so your assessment will be to implement the last function. updates. So how- what do you guys need? Should I, um, push this code to a repo and share the link in the disk- in the Telegram chat? Yeah,

200:29 G: you can put it in a GitHub gist.

200:31 A: Yeah, okay, cool, cool. So you guys should, um, implement the last function update. So you don't do everything from scratch again, and that will be your assessment. And I don't know, um, we were meant to do more than this. We're also supposed to do contract interaction, but I hope, um, probably if you guys have time again, we can meet before Wednesday. If not, we hope the class on Wednesday would handle it. But if you have time, you should just reach out to me and Sam so we just fix another class. So we, we tidy up this project we just built, we deploy it because we cannot- I don't want to write tests for it because you'll be doing tests in another class. So deploy it and try it on chain to see if it works as expected. And if not, we would brainstorm on what we did wrong, why it didn't work, and correct our mistakes. Hope that is fine.

201:54 F: Yes. Yes.

201:57 A: Then we'll do contract interaction. So we do- we'll build another contract and try to interact with this contract from that one in the next class, after making sure that this contract is perfect, the to-do list is perfect. So I would just move this to gist, send the link to Telegram. You guys should, um, work on it by- you don't need so much time, it's very easy. By 9 AM- 9 PM today, it should be ready. Submit your gist with your updateTodo function in it and Sam will track it from the list of those that have submitted there. Then you guys should talk together and fix a date and let me know. Let Sam also know so we fix a class and round off this particular project. I don't want to rush you guys because I really want you to understand what is going on behind the scene, how everything is computing. So immediately you finish this program, you start writing quality code, not just any archive code, real quality code that is production ready. That is my aim. That is my own aim. So I wish you guys the best. So I'll be posting on this. Have a nice evening, everyone. And I'll be hoping to hear your response for the next class. Bye everybody!

203:47 G: Bye-bye! Bye!

203:50 F: Bye, thank you!

203:51 A: Yeah.

More from this hub

Something wrong, or a video you want off this page? Write to wethem.xyz@gmail.com and it is fixed or taken down within 48 hours.