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 II

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 leads a session on Cairo contracts for Starknet, covering project setup, interfaces, importing types, internal functions, events and the dispatchers used for calls between contracts. They also show how to declare and deploy a contract to a test network, and take questions from in-person and online students.

Not by We Them Media Channel: Web3Bridge. Published Friday 31 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:01 A: Yes, I got it.

0:04 B: I'm going to share my screen.

0:34 A: Are you seeing the screen?

0:41 B: So today we are continuing with Writing Cairo smart contracts. I don't know what you guys have done in there before.

1:00 A: Now let's-

1:01 B: there are some few, uh, few stuff they sent me that I should take you guys. So have you, have you done anything on SCAB? How to install SCAB, set it up? Everybody's okay with that one? People online, I want to carry everybody along. There are some people online according to Sam, he said some people are joining online. So yeah, I want to like carry everybody along. And then I don't think this is connecting to the HTML. Yes, HTML is still here. You just need to view your screen. I'll let go for just a minute, please. Yeah, so let's continue. Like, just on stub, I want to like show us just one way of setting up stub very easily, then we continue to other things. So you're seeing the terminal, right? Okay, yeah, on my system. Have you seen this?

4:07 A: Oh.

4:23 B: So, uh, have you guys installed, uh, this SMForge? Yeah, have you installed it? No, like, have you- have anybody asked you to install SMForge, like StackNet Foundry?

4:37 C: Yes, it's for testing.

4:43 A: It's called Git Bash.

4:46 B: Oh, okay. So if you like, you want to create a new project, instead of you going to like do manual setting of SMForge and SCAP and all those ones, you can just run smforge init name of your project, and then it will scaffold everything for you on the scap.yml. So instead of that, you see your dependencies and everything. Set up already for me. Yeah, so like something like this, it has created already. So if you open So if you look at this, the POM file, everything is already there. So you have your, your SM Forge dependency, your stub package, and everything is there. Even the StackNet version is there too. Who is raising his hands? You can ask your question. If you have a question, just ask. Yeah, check the, check the chat. You see, I can't recall somebody. You can ask your question. Are you the person?

6:54 A: Oh, okay.

6:56 B: So I'm not going to go into configuring stuff for StackNet. I think everybody is already conversant with that one. I'll just be a time waster. So creating interface, uh, have you done anything on interfaces on Cairo?

7:24 A: No?

7:24 D: No.

7:25 B: So okay, it's just like normal, your normal interface in Solidity. The difference is just that it's now on Cairo, so it works the same way and everything. We're just going to do a simple demo. It's okay now. You guys know these ones now, like if you want to use, uh, if you want to, you don't want to use, uh, like that's what they call library binary and library. So some people use main instead of using library. They prefer to use main, like that's what they call main function in Rust. And you know that Cairo is similar to Rust. So this is just the basic. If you want to create, if you want to have multiple files, you go this route. So this one is just the name of the file here, mod before the name, then you come here and then you can do what you want to do. And it will now be connected to the system through the library that is here. So let's just write a small-

9:15 A: Do something.

9:16 D: Oh, okay.

9:18 B: Let's do a small interface, just something basic. So first of all, you have to like set an annotation. that you are creating an interface. That's why you have this, this first line. If it's a contract you want to create, this won't be- yeah, this can be a contract. Like instead of interface, I have a contract. So it's telling the compiler that, okay, we are creating an interface. It will now generate both your dispatchers and everything for you. We'll still come to that. So the name of the, uh, of the interface, maybe If you have any question, just ask. So this is the basic setup. If you have set it up like this, you can now define your function signatures. You know what is function signatures, right? So when you have something like this, you can now easily define your signatures inside this that you now use in the main contract. So maybe you have something like, uh, So I did something inside this, uh, inside this, uh, inside this function. I guess you highlighted this StackNet. Now give StackNet contract address. So contract address, we don't have it by default, unlike in Solidity. You know, when you are writing, so you don't have to import your contract address, it's there by default. Like, it's like a, a type, not contract type, it's like a type. So when you have your address in Solidity is the way you have contract address in Cairo. So instead of saying normally in Solidity, you just- but now in Cairo you have to import the contract address, use it. So that's either you do it this way, either you do it this way, or you come here. How many of you know Rust, like basic Rust? Anybody? Okay, so the same way you import modules in Rust, Yeah, it's the same way you import modules into a Cairo contract. So you do it, use instead of import. If it's Solidity, you begin import this one, the other one. In Cairo, you're using use. Just use, uh, what's it now?

13:14 A: So use StarkNet contract address.

13:21 B: So if you have it this way, if you import it like this, you don't need to add this thing here again. You can just do- you can just set the type without having to like include the stacknet in front. So that's it.

13:38 E: So, question. So, what is it? You know, is like this way we had it in Solidity where address is the type, right? Is that, is that what you're trying to explain?

14:06 B: I didn't really get what you're trying to say. The network was breaking up. Can you just repeat once?

14:13 E: Okay, contract address. Yeah, I don't understand this, um, address because you basically have address as a type. Yes, yes. So now is it that we don't have it as a type here, that you have to import it?

14:32 B: Uh, it's a type actually, but it's not there by default. You have to import it. So because the reason is because it's not- yeah, it's not all the time you might need to use a contract address as a type in your contract or in your program, because there's a difference between a Cairo program and the StarkNet contract. Do you guys know the approach to that one?

14:55 A: No.

14:57 B: Okay, yeah, so sometimes you might not actually need to use an address as a type in your contract. So there's- I think maybe later in the future they might add it as a default type, but for now I have to import it.

15:09 E: Okay, so this contract address now, is it pointing to the contract address for my own person that is deploying it, or I have to do some computation inside now to let it know that it's my own? Or like, wait, what am I even saying?

15:26 A: Okay.

15:30 B: The way you like, you know, okay, let's, let me do something. As we are writing solidity map, okay, I have to do share. Have I even, I don't still remember since. Maybe this is solidity map, you pass address, owner, share.

15:49 C: Yes.

15:49 B: Yeah, so the same way you pass this address is the same way you pass this. It's not like it's not pointing to anything specifically right now. You're just telling the contract that, okay, this is a contract address. You see where you have your integer and your maybe your boolean.

16:06 E: Okay, I get it now. Thank you.

16:11 B: Okay, so you're passing the address and then amount. So in Cairo, we have- we use unsigned integer.

16:33 C: I don't know.

16:33 B: Okay, no, so let's use uint. So instead of writing uint, we'll just use U and 256.

16:42 A: That's understood.

16:54 B: Yes, you mean this one I'm writing now?

17:01 A: Yes.

17:02 B: This is just an interface. Just if you, if you look here, you see it's just an interface. So we are designing the contract signatures, the function signatures. One minute, I need to like restart this, this VS Code. So inside, if you are writing interface, you don't- like, you don't need- you don't have this. So there's no implementation. I hope all of us know now, right? If you are writing interface, no implementation. Like, you don't have this public braces. So just finish and put your semicolon.

18:15 A: So maybe, uh, Is it here?

18:56 B: You guys are following along?

18:56 E: Yes, sir.

18:58 A: Yes.

18:59 B: So this is just an interface. You just remind, like, the basic, uh, maybe demonstration of what an interface is and how to write interfaces.

19:24 A: in Cairo.

19:29 B: Okay, let's just- let me just go for that. If you want to like use it in a contract, like, have you- you guys have done something on contracts, right? Like how to write contracts in Cairo?

19:41 E: Not really.

19:46 B: Are you serious? I thought they have done like a basic introduction for the brains.

19:54 E: So it's like small, but what you are doing now is making it clear so you can-

20:06 B: Okay, so let's just use this to contact functions in a contract. From the interface. Let's do something else. If you have a question, just ask. Are you following?

21:11 E: Yes, sir.

21:13 B: And interface, we don't have anything like mod- module. But now we have mod inside the contract because each, each StackNet contract is a module on its own. Sir, is it possible for us to write this contract inside of that place that we have the interface? Yes, it's possible. Okay, maybe we can just start it there, then move to the other file.

21:44 E: I think we can just continue with doing it in separate files.

22:02 C: So I was able to install it in my laptop with folder. So but in my VS Code, I mean, I'm now working directly, like say a project, a new project. I'm trying to get that universal compiler now. It's not, it's as if it's not reading it.

22:26 A: Is it the SCAB?

22:29 B: Is it SCAB? Like your-

22:30 C: Yeah, like I'm, I'm trying to do SCAB test, so it's failing with Universal- cannot find Universal C compiler. So, but I've already run it and installed it on the Mac itself.

22:46 B: How did you install it?

22:49 C: Did you root directly?

22:50 B: Like how did you use ASDF? SDF or just did normal?

22:54 C: Yes, I used SDF.

22:56 B: And you made it global? Like, if you're following the documentation, after the installation, I have to make it global so that you can access it from anywhere in the system. So please, who else can continue your question now?

23:14 E: Yeah, so I was saying that you can just continue doing it in separate files because the example that fits showed us, she did it in the same file. So it'd be nice to know that we can do it in separate files.

23:27 B: Okay, let's just do it. If, if we do both, okay, let's start with this, then we move it to the other side.

24:07 A: So we are going to need.

24:13 B: just 2, uh, 2 modules from this, uh, interface. The tricky thing is once you define an interface in Cairo, the compiler will generate your dispatchers for you. What they call dispatchers is like, uh, do you guys know anything about delegate call?

24:31 A: Uh-huh.

24:34 B: So if you want to make any external call in Cairo, what you use is dispatcher. Dispatcher is like- how to explain it- is like a system call that makes that call for you. So we call it dispatcher. You have a library dispatcher and contract dispatchers. So I think-

24:54 A: Okay, okay.

24:55 B: If you want to use, uh, you are calling a contract that's already deployed on chain, maybe on testnet or maybe mainnet, what you use is contract dispatchers. So just passing the normal interfaces, passing the address to the interface, then make your call. Yeah, then if you are calling an on- maybe you have declared it. If you have declared the contract but you have not deployed, have you done anything on how to declare contracts and deploy on StarkNet? Okay, all right, please go on with your question.

25:45 A: Somebody wants to-

25:49 E: no, no, no.

25:50 B: Okay, so if, if you have the contract, you- it's is declared. That's what they call to declare contract. To declare a contract in Cairo, in StarkNet, is when you want to- like, it's the first process before you can now deploy. If you declare, you are uploading the bytecode. You know what is bytecode? Hello, you know what is bytecode? Very good.

26:13 E: Yes, sir.

26:15 B: If you are declaring, you are uploading the bytecode to the StarkNet database, like the protocol. So now you don't- you have not deployed, you don't have contract address, but then the class hash, what they call class hash, is already deployed. Then you can make external calls to that class hash, access the functions inside that contract without deploying it. So that's, that's how when you do library calls instead of contract calls. But we are just- maybe later before we end, I'll show you guys how it works. So to use this interface that we have declared here already, use it in your contract, you just do a use Super.

27:01 C: Are we following?

27:08 B: Yes. Coming to your question, ask him there. So you have to use Super. Super is okay. Want to use other file that is not within this? Yeah, so if it's outside, I can't, I can't tell you. You use keyword Do you see uses there? No, it depends on how you use it. If you want to use- if you want to import it like this, it's okay. But then if you want to use it, maybe I want to like implement this interface, you can pass super here instead of importing it like this.

28:08 A: Yes, so I just-

28:15 B: yeah, yeah, I can hear you. Go on.

28:17 C: So my question is, how do you- if I'm to import from another file, will this super simple work, or if I'm just-

28:25 B: no, no, no, no. So what do I do? Just pay attention. After this, we just move to another file and I show you how to Import it in another file.

28:34 D: Thank you.

28:35 B: Yeah, so if you're importing more than one module or more than one function from a particular, maybe a particular file or anything, you open it with curly braces and then separate it with commas. Instead of doing it now in many files, many lines, you just do it in one line. Yeah, so use super. I need, uh, I need the dispatcher, the thread dispatcher, and then this. Okay, let me also bring in background. So you see, there's no way that we, that we declared all these things you are seeing here. There's no way that I wrote all these things. But once you, once you like form your interface, the compiler will generate most of these things for you. Emmanuel, please, if you have a question, just ask.

29:59 C: Let's continue.

30:30 B: So the reason this, this is throwing error is because I have not, uh, I've not declared my storage. Like, I don't know if, if it's composable in Solidity. But before, yeah, your, your StarkNet contract must compile, you must have the storage, uh, the storage struct. Like, you must have-

30:49 A: Yes, sir.

30:52 C: This, uh, IAsyncTradeDispatcher and IAsyncTradeLibraryDispatcher, are they like default, uh, modules that you are bringing here? Because I can see like You can define it in this output.

31:09 B: That's what I've been saying. Like, if you have an interface, like maybe you wrote an interface to use in your contract, the compiler, Pyro compiler on the backend will just generate all these things for you. So if you pass the name of the interface and then pass concatenate it Well, I don't know about like, let's say I'm not doing like, I'm not doing EAS 20 contract, maybe I'm doing some other contract. I can name it contract trade, anything you name it, it will just pick out that, that the title and then pass it like concatenate the whole stuff to it. So it doesn't matter the name. For example, if you come here and maybe remove this straight, it's running error already. So it works based on the name of your interface.

32:16 C: Oh, okay, okay. So this IRC20 has a dispatcher It has a library.

32:25 B: Yes, it's going to get for you automatically by recompiling.

32:31 C: How do you see the content?

32:34 B: Uh, you don't need to see the content actually, just have to like pass it. It's like what is what you're passing. This is just a function, I think. If you want, you can go, maybe you can go to their core library, the StarkNet core library, and then look at their core implementations. You see, again, these are just for making external calls, nothing else.

32:56 C: So I can see the functions inside that can be called and stuff like that?

33:01 B: Yes, all these things, once you pass this, it will show you this function that we declared inside this interface. So, uh, how do you, how do you set your, your this thing again in Solidity?

33:26 C: Yes.

33:46 B: So in Cairo, this is how we do it. So in Cairo, we pass it as a struct. But then we must annotate it with this storage so that the compiler will know that this is the storage variables. What do you pass in? Maybe owner. Now just stop what you need in your contract as the variables is what you're passing into the storage store.

35:12 A: Okay.

35:29 B: Okay, if you want to now implement the, the, uh, this, uh, stuff you have in the interface, the functions in the interface, you can't implement them just- no, let me just do it again. You know what this is, the function of this?

36:01 E: Make it external.

36:06 B: Yes, yes. This, this was what, what's her name? Now look, this is where I can either pass super and then add it, or you just use it from here. So this is this point now. You can do like this, super. So you see everything there. Either you pass it like this, then you don't have to import it from here. Yes, so either you do it like this, then instead of having- There's what we call generic variables, generics in ROS, right? So this, uh, this TContactState here is just a generic. What it does is just to hold- it's holding any variable you want to pass here. This thing is just holding it for you as a dummy text. You know what a dummy text is?

37:27 A: Yeah.

37:28 B: It's just a dummy text. You can use anything you like inside this place. It must not be TContactState. Some people use just T, just pass type, T for type. Then the important thing is to pass the contract state when you are implementing it here.

37:49 A: Do we get it?

37:52 B: You said, I think, yeah. Okay, but can you hear me, sir?

38:07 A: Yes, I can hear you.

38:14 B: Okay, you see this contact state now? Hello?

38:25 D: Yes, I see the state. I see the-

38:26 B: yeah, yeah. So I was saying that This, this capital T here is just a generic, what we call generic in Rust and Cairo. So it's just a dummy text holding any, any, any data type that you will later pass in when you declare it in your contract. So for instance, now this T9, you can change it to maybe TContractState, right? It will still work. If you like, you can just maybe do something like this. It will still work. Anything you put here will work. But then when you want to like use it in your contract as an interface, you want to like implement the interface, what you now is you must pass the contract state. So instead of having this thing here, instead of having the dummy text here, now pass the contract state inside. just replace this one with this one. Is it clear now?

39:23 A: Yes, it's clear.

39:28 C: Good.

39:30 E: Oh, sir, can you hear me?

39:31 D: Yeah.

39:32 E: So this contrast state, where is it coming from? Also from the core library?

39:36 B: I think if I'm to guess, I've not really looked at the core implementation of these stuffs, but this, I think this is just maybe a kind of a struct or a function. I think it's a struct because it's passing the- it's passing everything, like everything inside this storage struct and all the implementations in your contract. So once you're passing the contract state, you can access all these stuff here. And then you just pass self. Don't you still come to that self dot? Once you call self dot, you are referring to this contract state. And normally what we implement as self in Rust and Cairo is destruct. So it might be confusing. Yeah, it might be confusing, but then just know that this is just- this will pass the whole contract state to self. So instead of using maybe contract_state.amount.read, you just pass self.amount.read.

40:31 E: Okay, thank you.

40:36 A: Can you see this?

40:57 B: So it's already throwing error because we did not implement these 2 stuff That's why I'm seeing this, this red, this thing. So remember, to make this, uh, this error go away, just import the contact address. Same way you did it.

43:16 C: Professor, this implements IAS 43, that name IAS 43, is it a standard name or is it something that-

43:24 B: You can use anything you like. Just even if you like use name of anybody from the village, it will pass. This is still paused. So it's compiling now because we are done with the, the just the skeleton though. We're not doing any major work here. So that's how the interface works. And the funny thing is, in the newest versions of what they are using now, StackNet, You cannot write a contract without interface. In Solidity, it's not compulsory. In Solidity, it's not compulsory. But then if, if you write only contracts in StarkNet, you're not like- it will compile, everything will compile. But then the problem you have is until you want to deploy it or declare it You will not see any class.h to declare, you will not see any Sierra file to declare.

44:58 C: You just get into-

45:01 B: If you remove this and then comment, like remove all these ones, these implementations, leave only these 2 functions here, it will still work. You get? But then if when you go to your this file here This is the contract class, it's a JSON file. So if there is no interface, when you come here, you just see like one or two lines. These things will not be here, and then you cannot declare your contract or deploy it without this file, without this- all these figures here. So I don't know if they told you guys Cairo is a provable, like, it's a ZK language. So majorly they are using Cairo as just, I think it's just to make it simpler for us to write provable programs or contracts. So these numbers here, I think there may be proofs or anything from the contract that I'm not going to pass. I think this is 2S hereafter. Let me explain to you guys. What's your eyes? Cousin. Yeah, we have Sierra, I have cousin. Yeah, you have to like pass it through CRF test before now go to CASI.

46:48 A: So we are done with this.

47:01 B: Let's do this on maybe To the other file. Let's do it on another file. So the first thing you do is to import the interface. So the interface is inside this file ABC, inside file ABC.

48:01 A: Remove this.

48:09 B: It's not 500, it's 2. Let's look at this error. It's saying that this interface is not visible. So we can't access it from this file, this file, because it's not public. So if you want to use your interface or you want to use your contract or maybe your struct in another file, like if you're building a complex project and you want to be exporting your functions on your files, you have to make them public. So this now I have to add Have to add pub at, at the beginning here. Are we together?

49:19 E: Yes. Good.

49:24 B: The error has disappeared.

49:42 C: Sir, this use projects, this project, is it because you are in a project directory?

49:46 B: So it's how you import, import your modules in Rust and Cairo. So you set the path, like the path of the module from the beginning of, from the folder down to the this thing. But then ignore the src though. You're not passing the src, just the name of this thing and then the file. So this is how to use it in another file. First of all, the importance. Any questions so far? Online guys, can you guys still hear me?

53:43 E: Yes, sir.

53:47 B: Okay, so no questions so far?

53:55 A: All right, let's continue.

54:01 B: So I don't need to start talking about private functions and public functions, have you? Yeah, but then there is what you call internal functions though in Cairo. You guys know how to write work on it. Like, if you want to write internal functions now, can you do it comfortably?

54:22 A: Yes.

54:24 B: Let's try some. Assuming that you have this, your normal- okay, let's do something like this. So assuming you have maybe a helper function, you don't need to make it, uh, make it public or external. So you can just pass it here and then Outside, outside this implementation now, outside this scope, like this implementation block. So this generate_thread is also like other-

55:43 A: Generate an internal thread.

55:51 B: It's for like working with internal functions. So if you want to do an internal, like internal thread that is not, you not import it or not inherit it. You can just regenerate straight. Implement, uh, it doesn't mean we are only using it inside this particular- this particular file, inside this place. Okay, yes, yes, you cannot call it outside. It's not accessible outside this. You know, in Solidity, you still have your internal functions and your private functions. Instead of making it maybe, uh, public, this one, that one, just leave it empty. You get- so if you don't want the function to be called from maybe from outside the contract So this is another, like, interface that is internal. So just like run anything you want to do inside it. Still, you can also define your contract without this. So just write your normal function without this external annotation, you get. So if you just do it like that without this, it still works, but then it will not be accessible outside the contract. So it's an internal contract or private contract- sorry, function, not contract. You can have something like this.

58:43 A: All these ones are inbuilt modules and functions on StackNet.

59:02 B: The way you have your global, uh, What they call that instead? msg.send and the rest of them.

59:09 C: What?

59:12 B: So these ones are the equivalent on StarkNet. They have get caller address, get contract address, many of them. So get block, block number, timestamp is get block. Instead of doing block.timestamp, You have get block timestamp. Then instead of doing msg.sender, you have your get caller address. So I'm doing address this. Where is the address?

59:43 C: This?

59:44 B: Yes, it's address this. So that is get contract address, this one.

60:11 A: Let's do some- this is after 5.

60:49 B: See that, uh, if it's Rust, okay, it's also the same thing. There's what we call inference. Inference is when you don't have to pass the type. So like the compiler will, okay, guess and pass the appropriate type for you. So like this owner now, you can leave out this and then do- let's run an example to maybe self.contact.read. So now the compiler knows that, okay, this is contact address. Are you seeing it?

61:31 C: Yeah. Without having a set function to set Can this function work?

61:46 B: There's what you call UDC. Do you guys- did they teach anything about UDC, Universal Contract Deployers? Yes, yes. So when you deploy a contract, if you did not pass the If you do, if you do a constructor, uh, owner is the get caller address. If you pick the address of that UDC and pass it for you as the owner, because that's the address that is calling, that is deploying the contract.

62:24 C: That is the address of the address of the That means you have to do that set and get function.

62:33 B: You have to pass in the contract, like the address, in the constructor. Yeah, I think you have to- if you have time, you look at ownable function contract. There's an ownable contract by- it's a component actually from OpenZeppelin.

62:51 C: So use it to write a contract. What are you saying?

62:56 B: Good thing is, like, all these companies have- you know, the mines have some, some teams dedicated to StarkNet. So OpenZeppelin too, they have, uh, their contract base, all the Solidity contracts that they have, they also have it on StarkNet, and they are releasing new versions all the time. So, uh, maybe if there is time This one is after 5 already. I was thinking that, you know, you know, it's going to take 30 minutes. So let's do constructor. You still mark it, then do FM constructor. Then of course, you know that you must pass your, your type. If you are passing arguments, you must add the type. So it's the same way it's in Solidity. It's also the same thing in Cairo. You must pass the type. That's why you're having this contract address.

64:25 A: Self comma.

64:39 B: So this is how you assign the owner of the contract, chief. Yeah, if you don't do this and then pass, maybe you pass get caller address as, as the owner, it will pick up the address of the universal deployer and then you have lost that contract and you can deploy a new one.

64:57 C: What I was saying with this, yeah, for some builder I saw that they purposely defined the set function. Now what the set function does is sets- it fetches the address from the contract address, something like that. Fetch the address and set it, right? To save self-loss, like you put it in the storage. Contract address. So therefore, that will be that owner.set- That's right, right. Now go to get function and return the address. So that's what I'm saying. I'm like, without doing that set address, can we use- can we still get the deployer's address?

65:58 B: Without doing that, once we do this stuff now, this wants to pass this in your constructor, and you have your owner defined in your storage variable. It's already stored like this, so the owner, you don't need to set it again, especially unless maybe you want to like keep changing the owner. Can I use that setOwner and be updating it?

66:19 C: So like this? Yes.

66:26 A: How many of you write TypeScript? Everybody that-

66:45 B: I want questions. If you have question, ask.

66:57 E: Okay, sir, can you hear me?

67:02 B: Yeah.

67:04 E: Yeah, you said something about universal deployer losing my contract. Can you go over that again?

67:09 B: Okay, the thing is, on StarkNet, there is what we call a universal deployer. The contract is, I think, is a sequencer itself. It's address of a sequencer. The job is to just be listening to deploy syscall. There's what they call deploy syscall on StarkNet. It's a function that deploys all the contracts on StarkNet. So once that function rings on StarkNet anywhere, it will pick up that contract and deploy for you. So it has an address If you don't, like, if you, if you come to your own, maybe your contract now, instead of assigning this owner to the, to this person, like, you don't pass, you do not pass the owner as an argument. Let's say you did something like this, and then you did self.owner.write So from here, if you do anything like this, instead of, instead of you passing your own address as the person deploying the contract, The, the Starknet will pass the address of the universal deployer for you because it's not you- your account is not the actual account that is deploying the contract, it's the universal deployer. So do you get that?

68:52 E: Yes, that makes sense. That makes sense.

69:15 B: The way you do require, um, solidity on StackNet, what you do is assert. So if you want to check that the person calling this contract is the actual owner and you have your owner here, have read, like, you have gotten the owner's address from the state, uh, this thing, and then the person- this is the person calling the contract. All you need to do just to confirm that owner is equal to caller. Then if it's not equal, that means it will throw error, it will panic. What do you call panic in Solidity?

69:48 C: Error.

69:56 B: I said that-

69:57 A: So it's as simple as that.

70:13 B: This line will be checking that the person calling is the owner of the contract. So assuming you have this in your contract now and you go and pass the universal deployer as the, as the owner of the contract, that means you have lost access to the contract. You get that? So you have to be careful.

70:31 A: This balance is supposed to be-

70:53 B: it will be this time of contract interest.

71:14 A: That's correct.

71:15 B: So this is mapping, the normal mapping in Solidity. What we use is legacy map. So you're passing the types. I think in Solidity all you have to even do is Address of the owner and the balance. So owner is address, the balance is integer.

71:53 A: 256. Yes, yes.

72:05 B: Like legacy map, you can just first to start with, you cannot use mapping by this legacy map. You can only use it inside storage struct, so you cannot use it outside your storage struct. If not, it will throw error. So outside storage, you cannot use your, uh, your dictionary, 252 dict. So now you do- see, they told you guys it's not advisable for you to go and start writing your own token contract by yourself. I hope you know.

72:49 A: Uh-huh.

72:52 B: You don't know. It's not advisable for you to go and start writing your own token contract by yourself, both, uh, NFT or token like normal ERC-20, because it's more secure and it's audited. But let's say maybe you want to now maybe change some things, but then if not, just use OpenZapier.

73:25 C: Sir, you teach us how to use OpenZapier?

73:30 B: Okay, sir, we teach about to use OpenZapier. Let's just be going ahead, maybe. And the funny thing is, I think- I don't know if anybody's going to teach you guys components. OpenCPN, normally they don't have contacts again, and certainly they have components. So it's not difficult anyway, just like import it and then use. Maybe before I try to touch on it, before I do so, so Balance.

74:24 A: But focus.

74:51 B: Any question? You understand that? Online people? Yes, we fly, we understand, sir. Very good. I hope you don't say another nice thing now, sir. You still understand that?

75:41 A: Hello?

75:43 B: I understand that.

75:45 A: Very good.

75:46 B: Let's continue. Just a normal- you can make it. So it's not like you're paying things. So you add to the person that is being paid, deduct from the person that is paying. Have you?

76:06 C: Yes.

77:22 D: So, quick question, sir. Can you hear me?

77:24 B: Just one second, I'm coming. Okay, well, that's the macro sign.

77:36 A: 34. If-

77:41 B: let me try something. If you put this, this thing like return error, that is not- you are not supposed to pass string literal. So I have to- it has to be double quotes. It's the same thing, but if you are using macro, the string inside the number on double quotes instead of single quotes. I think they started this one when they started using byte array. So we have normal string on StarkNet now, the one that is within 32 bits long, and we have something that is the new one. Now you can use any arbitrary amount of numbers, of letters. So it's now byte array that is longer. You have str in Rust and you have string. So string is smaller, like I think it's 32 bits or so on StarkNet. But if you want to now use longer, maybe you want to deploy NFT and maybe the URI is long, you can now use byte array. So let's do this. So I've seen it now, the error has cleared. So I noticed something when I was like writing this function without using the generate thread. It was throwing error here, you notice.

79:17 A: Wait.

79:27 B: The function, the contact could not see, like this function could not see this function down here because that nothing is exporting it. So I have to like define it inside this internal thread so that it can see it. Are we following?

79:49 E: No, come again, please.

79:50 B: Like, if you want to like write internal functions in Cairo smart contract, you have to like pass in generate the trait. So you must pass annotated with generate trait and then implement this private trait or internal trait. If not, if not, you cannot call this function inside your contract. Because these ones cannot see us. Is standard for private trade? I think private should be arbitrated. Private trade must be used. Let me try something. It still works, right? But then anything, I think anything is changing, I should try an error. Funny enough, it still seems okay. Okay, it's because of this generate trade. So yeah, I think also you have this generate trades.

81:06 A: Yeah.

81:06 B: Anything you write will pass because this is actually the thing that is doing the actual work, is this. So assuming you have deployed- have you done anything on dispatchers? Okay, yeah. Sorry, someone had a question before. Please, who is that person? Who was that person?

81:35 C: Was about to implement trade, private trade, you just did now, so answer my question already.

81:46 B: Okay, that's- you have gotten the answer now. Hello, are you cleared now, Emmanuel?

82:00 D: Yes, I am.

82:01 B: Thank you. Okay, cool. Let's continue. So have we- have you guys done anything on dispatchers? Contract dispatchers and library dispatchers? 5:25.

82:14 A: No, no, another contract.

82:22 B: Nice. Let's quickly touch on how to emit events. So this one is just simple, just follow. There's no need to- there'll be no confusion on this. So let's emit events. No question, Abhi? Yes, let's continue. If that person asked, You understand, Davy? Hello?

84:39 A: Yes.

84:41 B: Any questions? Yes, it's an event. No question, Davy? Let's continue.

85:00 A: You say it's not so straightforward?

85:04 B: Actually, I, I'm not a core engineer. I don't know why they have to do it like this, but then it's how it is. Just follow it. So first of all, I have to show that it's an event with this annotation here. then you have to derive. Have you seen this one, Algarost? Yeah, this particular line. You have to like- what you do with derive is to import the traits you need to run this struct and the enums. So drop is- there's what they call ownership in Rust. Have you?

85:46 A: Uh-huh.

85:47 B: So each variable in Rust has an owner. And once it goes out of scope, it has to be dropped. Yeah, so that's why you have this drop. Drop is just a function to drop this enum or struct once it goes out of scope. The reason is because they don't have- we don't have a default implementation for it. If it's other data types like string, integer, boolean, you can drop them automatically. But then this one, I have to like call, like annotate it with the drop so that they will know that they're supposed to like drop after, after they are done. Then this start event is just to mark it as an event, nothing else. Then first of all, pass all your events, like the whole event that you're going to be passing in that contract, all of them should be inside this enum. So assuming I have maybe transferred allowance, all this of type allowance, all these ones, then also I have to now come and write a struct for it too. So we are following. Are we following? It's just the same, only the only thing is that inside this enum now we are defining all the events are going to be emitting in the contract. So now you now start to like define the events one after the other. Then if you want to now emit the event Okay, inside here now we have finished writing the logic. What we just have to do is do self.emit. I'm going to emit transferred. Let you know that it's a struct, so you have to like- is it the structure you call it or what?

88:47 A: Like we have just do this.

88:52 B: The first, uh, the first, the first variable here and the first argument is sender. Then you have receiver and the amount. So come here, pass owner, receiver, amount.

89:28 A: Oh, yes.

89:28 B: That's the point. So it's the exact word. You have to pass in the exact word inside, inside the struct for it to work. Are you following?

90:04 A: Good.

90:06 B: But then if you don't want to like start duplicating this stuff If you don't want to write, come and write sender and then write maybe owner or anything like that. This one is sender bar. We have sender, have receiver, and we have amount. What you can just do is come here, change this, your owner, to sender, then receiver. You can just come here and clean all these ones off.

90:38 A: And you are good.

90:58 B: It doesn't make sense to- for you to stress yourself and be writing the sender, now put colon and start writing owner again. Just like use the same words and pass all of them once. Easy for you and it makes it more professional. Any question? No, Abi? Let's continue. So I'm done with the events and how to handle events in Cairo. Let's do a discussion. Dispatchers, pump-out dispatchers, and ladder dispatchers. Then we know that almost- how many hours is this supposed to last? Are you serious?

91:39 C: 7 hours.

91:55 B: Let's continue. So we are done with the, just the basic contract and interfaces and the events and how to emit them. Uh, let's just like, let's just assume that we have deployed this contract.

92:16 A: Okay.

92:18 B: Uh, Let's assume that you have deployed this contract and they want to like make external calls to it. So I told us before that if you want to make external calls, what we use is contract dispatchers, especially contracts that you have deployed already. If you want to call contracts that you have already deployed, use contract dispatchers. If they are calling class hashes, like classes, they go to call classes and start connecting. They are trying to use web-based such as they are trying the contract but they have not deployed the contract. What they are just following is how they explain it. It's crazy actually. That is why StarkNet is far more advanced than Solidity.

93:11 C: No, I can't compare Cairo and For instance, now all this stuff, it's actually making sense in some ways.

93:20 B: It's complicated. There is nothing you want to tell me that I go back to Solidity again. That rubbish should be shedding. Every small thing you do, you just be getting stuck too deep. Any small thing is contract size is max R, but no. I can't do Solidity again. Are you saying Solidity is more difficult than Cairo? Actually, it's simpler. Solidity is simpler because it was built on purpose to be simple. So it's simpler to learn and write than Cairo. If I want to do events in Solidity, why are we doing all this struct and all these ones?

94:09 C: Thank you.

94:10 B: Now, each one is having their own proposals. Wow, so long it's going.

94:56 A: Nice.

94:56 B: Hey, Andrew. Hey, what are you looking for inside this car?

95:10 A: My balls.

95:12 B: What are you here to do, this guy? You understand delegates' call well, like all of us are doing delegates' call very well. Wait, we have people that are not from West Africa. A big issue, they cannot understand Pidgin, please identify. Wait, yeah, Nigeria since how many weeks? I be month. Can't understand simple Pidgin English. No way. When I went to Kenya, I was speaking like Kenyan people. So if you come to Nigeria, speak like us too. So to make external calls to contracts, we are using dispatchers. So if you look at this, you know, I did not import the thread itself. There's no ERC-20 thread or anything there, just dispatchers. So we imported dispatcher and dispatcher thread.

97:32 C: This dispatcher, what are they exactly?

97:35 B: There's like, they make underground, uh, external calls to contracts. The same way you do your interface in Solidity, you do IERC-20 contract address dot transfer or anything. It's the same way this works too. Yeah, so instead of you doing the name of the trade dot call dot transfer, you pass this dispatcher, you pass the contract address. Where you can make your calls. I have something like maybe this one is old one. It's for people just starting. You can say it's new edition.

98:33 C: Update.

98:38 B: Yeah, let's just- all things are faster. The way I'm doing this is that you guys can understand that it's also possible to write pass this direct without having to import it. Are we together?

99:23 E: Uh-huh.

99:25 B: Normally I should just import it and then do what I'm doing. I'm just doing the extra stress. This is a dummy text. Of course they hear me. That once I write this inside the contract, you just like- I want to just pass address inside there. So you just like to show you guys, okay, this is the way to do this.

101:01 C: So Since 1234 is an address that goes to 252, why are you trying to-

101:14 B: 1234 is an integer.

101:17 C: I don't think you do not give it in type.

101:28 B: 1234 is an integer. If like if I remove these ones, numeric, are you seeing from numeric literal? So he's seeing it as integer, not as address.

101:45 C: If it doesn't get, I can say OS. You have to do that, try into-

101:57 B: that's trying to do this, like just to convert your normal field.

102:04 A: Yes.

102:04 B: Okay, so you have to do it. So if you, if you look at inside these modules or functions, inside this place now, you find that, okay, you have transfer here. You have transferFrom. So even without importing the trait from the other file, you've already seen the functions inside that trait. So you have access to all the functions. This is what they call a contract dispatcher calls, passing the contract address of that contract. Maybe if it's ERC-20, just passing the address of the ERC-20 contract that you deployed. on another contract, and then this dispatcher will be making calls to that contract.

102:51 C: So, so I understand that this house- this dispatcher now is what we're going to be using to interact with the contracts from where we're sitting, from where you're communicating with me. And because I understand that this, um, I was doing that originally with The interface was written like-

103:17 B: We don't even need- the funny thing is you don't need a contract or any- to import a contract here. You don't need to import any, any stuff. The only thing you need is just this dispatcher here.

103:34 C: Yeah, yeah. Or is it-

103:39 B: I don't think it's an interface. I think just maybe a function or a module that is doing the syscall behind the scene. Yeah, so passing the argument, everything is fine. So any question on this?

104:14 C: Okay.

104:14 B: When you have deployed your contract on Starknet, you have your contract address. Then if you want to make call to that contract that you deployed already, what you just need is to import Okay, we have normal ERC-20 dispatchers. Even you don't even need to write it, it's already on OpenZeppelin. You can just import it into your contract and then write a function to make a call to that contract.

104:44 A: You get-

104:46 B: once you bring that dispatcher, pass the address of the contract, you can call that. You can call any function provided it's an external function. You don't send your token address? Exactly, that's the function signature. Don't finish, that's just the same thing. Okay, call contract syscall. Apart from, uh, apart from dispatcher calls, contract and library dispatcher calls, there's another low-level syscall. That's the one you're talking about now. So I think that one also- I think they also pass- is it class H or something? Yeah, I think we pass to that one. make the call. It's another- it's advanced, kind of. Not advanced, it's not what they're asking to- not asking to teach you bits. Let's understand these ones first. Okay, let's just do these things together. Hi, I'm 23. So I mentioned earlier, the difference between contract calls and library calls is for contract calls, you're using contract address. This one now for library calls, you are passing them the class hash. Class hash is like bytecode. Let me just break it down for us. Class hash is like- it's not bytecode, they say, but it's like bytecode. What it means that when they upload your- when you declare a contract on StackNet, they upload your contract bytecode. the protocol, and then they return like one- what they return to you is like a contract address that is not an address. What they call it is class hash. They just hash the key of the place they stored the class hash and return the hash for you. What we call it is class hash. Any question?

109:32 A: No question.

109:33 B: Let's continue. So that class hash is what you pass here. Pass the class hash here because when you are doing write bytecode, you are not making call to- you are not making call to the contract. So the only way you can access that class hash, the contract write code, is using the class hash. Do we get?

109:53 C: No.

110:05 B: I'm trying to like bring it down to understand it. They do get it.

110:13 C: Yes, I understand. So you call it like this kind of call, you call it library call?

110:24 B: Library, like library call we are making? Yes.

110:28 C: Not so like this one now. For this point now, it's not like normal transfer contract.

110:34 B: No, like it's not like normal external calls. You know, you do normal external calls in Solidity, but yes, this one now that you're talking about, it's not like your normal external calls because when you make external calls on Solidity, you are used to passing contract address of that contract.

110:51 A: But yes, try to remember.

110:55 B: Yes. Good. But now when you want to make library calls on StackNet, instead of passing contract address, you are passing class hash.

111:05 C: Class hash?

111:09 E: Yes.

111:09 C: Why pass class hash? Why not just pass contract address?

111:16 B: You have options. Either I call you, maybe I don't deploy your contract, or I not deploy it but it's declared. Maybe for safety purposes. You cannot hack a deployed contract, but you can hack a deployed contract to get shared data. So some people might think, okay, it's safer for us to just declare it and then be making library calls to it. You don't, you don't have access to their contract.

111:42 C: So this one, are we the one declaring it or it has been declared already?

111:46 B: It has been declared already.

111:47 C: Yes.

111:49 B: I don't think OpenZeppelin declared the contract. They just, they just have library. OpenZeppelin is just library. Check, you know, it's not a contract because they are not deployed. Yes, but then the reason you cannot make library call to OpenZeppelin is because they are not deployed. Are you getting it now? So unless maybe you import it You create by yourself, you can now start making calls to them. I think that you can create OpenZeppelin contracts on StarkNet because they are just components, they are not real contracts. And I don't think you can deploy components, it must be embedded. Okay, there's no time. Can you hear me, sir? Yeah, okay, I'm hearing you.

112:42 D: Okay, so a quick question. Line 5, you are trying to- inside that file, you are doing the IERC20Dispatcher, the DispatcherTrait, then the LibraryDispatcher.

113:01 C: Yeah.

113:01 D: So my question is, these dispatchers you've imported here, did they were created as a result of using the traits in the file ABC. Am I correct, please?

113:13 B: Yes.

113:14 D: So lastly, on line 6, you did use StarkNet. Then you said you are importing multiple things: contract address, class hash, and then class hash. Um, this, um, I think this- should I call them constant now? Is there a place where we could get a list of all these constants and like there are many so that we could use them?

113:41 B: Have you checked Cairo Book?

113:49 D: Oh, okay, I'll check, I'll check that.

113:53 B: Just try and see if they are listed there, but I don't think so.

113:57 D: Okay.

114:02 B: Okay, another question.

114:03 D: So, um, this, um, implementation now, you said we are trying to use the class hash because when you like declare to generate a class hash for you and that's what you use. So if in a case I'm to like do a testing situation and I'm not like trying to declare first Is there a way I could like call, get the class hash within the file to like run my tests?

114:35 B: Ah, there are 2 things you might do. One is to declare the contract on testnet and then fork testnet. You guys have done fork testing, have you? Hello, sir, do you have any idea about that?

114:51 D: We have not started, we've not started testing yet. The reason why I mentioned it is because you did something as such in the previous file, so that's why it just occurred to me now. Not done testing yet.

115:04 B: The second way you might want to use it in your testing is- ah, I can't enter testing now, it will take my time, but let me show you something. There's one contribution I'm doing on Stack Overflow example, and it's on this library course. Let me just open it and show you guys something. So look at this test. Can you see it?

115:48 D: Yeah, I can see it.

115:52 B: Very good. If you are testing your contract and they're doing library calls, maybe you don't want to deploy- declare the contract, or maybe it's too much stress for you, you can use this setup. This TestClassHash is, is, uh, a default test class hash on StackNet. It's just for testing. So this is the name of your contract. So pass the name of your contract, of the contract, then you pass this testpass hash, and then you unwrap it. This will give you like a test environment for you to like test your library calls and know whether they're actually making the calls. But then if you want to recheck that, although there's no way for you to recheck, I think this will just- this, this works just fine. So if you want to test your contract, you can use this, but then this is not- this is beyond what you are doing now. I think the person that will take you on test will still touch these stuffs. Okay.

116:48 D: All right, thank you.

116:51 B: Very good. Back to business. So it's simple to just to pass in this. So instead of using normal dispatcher, we're using library dispatcher here. We are following a loop. Then open your curly braces.

117:31 C: So this is the case we are using, right?

117:36 B: Open your right braces, pass in the class hash. We are good to go.

118:05 C: In the, uh, contract of hiring, you didn't implement those changes?

118:12 B: I implemented it. All this AI stuff, you better- ah, we don't finish now. Deploying to testnet. I'm not going to deploy to testnet. I'm going to give you a link to my articles on stacking So you guys can do that one on your own. If you have any question, you can contact me on WhatsApp- no, not WhatsApp, Telegram or Twitter.

118:56 C: Hello, Mr. Olusegun sir.

118:58 E: Why not?

119:03 A: Yes, I think what I have here is my, uh, I think someone tweeted.

119:14 B: All right, I'll send my username in chat, in this call chat. So how to deploy to testnet? And also, this is connecting our database. So I was telling you guys that Solidity is like a bed, a cash bed. You put it inside cage and lock it. So it's like a caged bed. But then with Cairo now, if maybe you deploy a contract, there's a bug or a mistake, you can easily like upgrade it natively. You don't have to go and deploy another contract or deploy that one contract. You just- there is a low-level syscall. Just go through the article if you have time to explain everything.

121:44 C: So, so meaning that I'm using a contract to get this money and go back, complete the contract, to pay.

121:54 B: It's your money, enjoy your money. No, let's say I read the contract for this class, they put money, I be- you're not upgrade the contract and collect very, very easy.

122:06 C: No, I'm not saying because you're just-

122:08 B: no, but then how many, how many projects Have you seen on something that that's for their their investors? It just it's not about question of technology, it's about question of people, the people behind it.

122:21 C: Yeah, I know. I mean, it's just made this one just really.

122:23 B: It's even simpler because if you know that you're is upgraded, you know that people are watching you. But then if you say you deploy none of available contracts and then you go behind it and still steal people's money.

122:35 C: But you know all of them once they speak to and they see that they don't look.

122:42 B: Even the ones that, that they are audited by Nethermind and all those ones, they still will approve. When you write a contract, there must be somebody that has rights to withdraw or transfer out money, otherwise it will block forever. Oh, sorry. I tell people, it's not about the technology. Technology is just there for us to use. It's now the mind of the people that are using it. You have gun, everybody have gun. It's now you that you carry it and shoot another person, and then you say gun kill people. Meanwhile, it's people that kill people, something like that. Oh, so I think we're almost done. Any questions so far?

123:30 A: Yes, sir.

123:35 B: My question, man. Do you know anything about Dojo?

123:53 D: What?

123:54 B: Dojo. Yeah. So they have, they have this tool called Katana. Katana is, is like a sequencer. No, it's a sequencer.

124:18 A: Yes.

124:26 B: Have you people not done StackNet architecture? How many of us, how many of us did the best count?

124:38 C: For me, I'm not going to predict.

125:02 B: What, what, what he meant about mempools?

125:05 C: Yes.

125:05 B: Mempools, you know, all of us know that.

125:09 A: Yes.

125:10 B: So, fine, there's no time. On, on EVM, you have mempools. That's okay. Miners will now be- validators will now be picking transactions. On StarkNet and other L2s, we have sequencers. So on StarkNet, there's no mempool. There's no like, okay, we are looking for the transaction with the highest gas fee. All of us understand that. I'm not speaking- No, no, no, there's nothing like we are looking for one with highest gas fee. Everything is like first come, first serve on StarkNet. So what happens is once you initiate transaction, sequencers will now pick it up and then, okay, check, check, check, everything is intact. Maybe they're checking for maybe signature, gas fee, and make sure that everything's intact. They will now send it to EasyProof and now the execution layer will be waiting to record. But then- It's whether I was saying, you know, that it would pass itself and then Once, once they send it, Spencer picks it up, checks it, and make sure that it's well arranged. And then they'll now emit it to- they'll mark it as accepted and then emit to the next, uh, I think it's the priver.

126:22 C: Abi?

126:23 B: The priver will now do the normal sequencing and then send to verify like that.

127:01 A: So, uh, let's just like-

127:04 B: I'll show you how to install Katana. Then I think you follow the article and then you might run into some errors. Yes, you can use it to run local nodes. It's like Foundry, Hardhat. You can Like, use it to run local node. It will give you some account with refunded ETH and all those ones that you can use to make transactions. Yeah, so are we, are we seeing the screen? So this, complete this. Once this one passes, once it finishes, you're gonna run the job. Are we installing this?

128:07 A: Yeah. Yeah?

128:11 C: Yeah.

128:11 B: This one?

128:12 D: Yes, ma'am.

128:12 B: Oh, oh, okay.

128:17 A: You copy, you copy the host also.

128:42 B: Not only the link, apart from the core, then end with the batch. Copy everything together. Do you guys know how to use, how to use ASDF installations? No, no, I don't know what to use. Ah, ASDF. Uh, I think I'll send you the, the, their link. In short, use Find. You go to find.com, find.com, then how to type how to install ASDF on Ubuntu. Follow their listing, just be copying and pasting. It will work. Then after installation, you can now start using it to install tools and other stuff. So if you're using SDF-

130:12 E: Hello, sir.

130:14 B: Yes.

130:14 E: It has installed, but when I run the job, it didn't work. Am I supposed to put something before the job?

130:24 B: Another tab, another terminal, and then run the job.

130:28 E: Okay.

130:30 B: Supposed to work.

130:32 A: Oh yes, it works.

130:47 E: Thank you.

130:55 B: So if you finish your installations, run this command.

131:17 E: So what does this command do? This is the same thing, eh? This command that you just sent now, what does it do?

131:25 B: Run it first. If I finish the installation, just run the command.

131:31 E: Okay.

131:32 B: Has anyone run it? Are you seeing something? You know, like when you have the web page. Yeah, good, good. So if you run it, you should be seeing a contract and account for testing. This is like your local node, it's just for testing purpose. So if you are here, that means you have reached the end of the You say you have to confirm, follow the procedure, you can deploy contracts on Cardano. Do you have Stacking? Do you guys have Stacking installed? Stackline? Stackline? Stacking?

132:27 A: Anyone?

132:30 B: Anyone? Are you serious?

132:33 E: We are doing it from the browser.

132:39 A: Stacknet CLI.

132:44 B: Yes, have you guys installed it? Like, you have not done anything on Stacknet contract before? Okay, Stacklight is for, is for declaring and deploying contracts.

133:52 A: Let me see.

133:57 B: Have you finished? Installed?

134:01 E: Yes.

134:01 B: But it cannot show up?

134:03 A: Yes. Let me see.

134:05 B: Yes, yes. If you scroll up, you see Katana at the beginning.

134:18 A: Open another terminal.

134:25 B: Yes. I will send you a link.

134:53 A: Okay.

134:55 B: Yes, follow that. That there is another way you can install it. Do that one and see if it works. I don't get money and there is Mac. Now big man, big man, big trouble. Okay, I'm coming. Let me send you the I need to confirm this is working.

136:18 A: Okay.

136:57 B: So you use the link I sent now to install the command, the Stackly. So if you finish, just run Stackly up.

137:10 C: Yeah. Which new link? No, this one is saying- no, like I was telling you, the new link is not for-

137:32 B: it's not for Dojo.

137:33 A: It's for-

137:34 B: don't worry, let me get the link for you.

137:46 A: It's not working.

137:53 B: Permission denied. Put sudo. Are you using Windows?

137:57 D: Yeah.

137:59 B: Okay, put sudo before if it's permission denied. Let me see.

138:16 A: Saying what?

138:33 B: Everything, man. What do you copy? From here, all these fields. And the same one. Permission denied. The question why you need to do- I said student name, it's, it's waived. Is there any other person having the same issue? Permission denied for the Stacklight. It's still the same issue even after using sudo. Okay, it's only with a certain- that means it's denied from your system. Okay, so we have finished installing Stacklight. You don't install Because of what?

141:10 A: That's-

141:10 C: you've not seen it.

141:45 B: Check, check, boss, check the link I just sent. Use it and try and install. Is this done now? Yes.

142:26 C: I think it's successful, right?

142:33 B: Yes, just then simply run Stack Overflow.

142:37 C: So don't mind this one?

142:38 B: No, no, no, just open another terminal and then run Stack Overflow.

142:45 A: Yes.

143:25 B: So now it's time for questions. So if you have any question, just ask now. I'll be done in 4 or 5 minutes. How do the laptop data range?

143:47 C: No laptops, software installation.

144:18 B: Which which which lemons which lemons that you might use? Is he is he? Oh wow. Yeah, Emmanuel, go on, go on.

144:53 D: Okay, so I've successfully installed, uh, StarClay. And I've run Stacklight Hub and installation is successful. Downloaded everything from GitHub.

145:06 C: So what next?

145:08 B: Oh, okay. I will send you documentation for Stacklight. So it's just for if you finish writing contract, you can use Stacklight to declare, you can use Stacklight to declare or deploy. Oh, I see. So it's just a CLI, it's command line interface. for declaring and deploying contracts on Stacknet. Do you get that?

145:31 D: Yeah, I got it. So is that- is that- will that be all for today? There's more?

145:37 B: I'm almost done. Yes, I sent- I sent some links to you. So if you maybe- your practice- you have- you have a contract you want to like test, deploy, or declare. I have- if you want to deploy on testnet, Or if you want to deploy on local mode, see this deployed on Katana, follow the article, you deploy on local mode. So if you want to deploy on testnet, follow the first article, deploy on testnet or mainnet. It's, it's like straightforward like that. Then if you have any issues, ping me on Telegram or Twitter. Yes, Victoria.

146:14 E: And so do you have an idea when the masterclass is ending?

146:19 B: I'm not sure, not sure. I have to like check. I think they have some of those details in their Telegram channel. So Emmanuel, any other question?

146:38 C: No, I'm good for now.

146:44 A: Thank you.

146:50 B: Who is having issues? What, what are you facing now? Which one are you facing now?

147:00 C: Wait, some of this I think-

147:04 B: Chief, come. Before you can run some of this, this stuff, we can install some of Athens Curve and the rest of them. You have to have Cargo installed in your system. Cargo, like Rust compiler.

147:17 C: This Cargo that I've been talking about, it gave me an issue. Then, you know, I installed Cargo, but now I'm trying to use Cargo to run, it's telling me that Cargo not found.

147:26 B: When Peter get problem with Emmanuel, Peter get problem with Paul, the issue might be from Peter actually. So check your laptop.

147:41 A: Check your laptop.

147:45 B: So guys, uh, we are going to end it here for today. So let me just drop my, my Telegram username in case you have any question. I can just ping me on Telegram.

148:02 C: But I don't think they're going to now get any more.

149:02 B: See, one house, one house. I want to see if you can deploy one contract on testnet.

149:09 A: Are you okay?

149:17 B: Just one. Probably one contract, then we call it a day. You can still see my screen? Yes.

149:28 A: Okay, let's, let's do this.

150:02 B: So, I don't- I'm not sure, but normally you need a Sierra file, like you need your contract to be compiled to Sierra. So before, before, I'm not sure about now, you have to come to your UML file and then add it. So what you do is just to type Sierra like this. So once you do it, then compiler will now know, okay, I'm supposed to like compile to Sierra, then compile them to Casio. So you save. Next thing to do is just to compile your contract using Scab. Just build it. So if you see here, you have- we have a new folder here. the target folder. Then if you open it, you see the dev, like this is where all your files, the Sierra files and everything is. So it will generate all these JSON files for you. Now what we are interested in is this, uh, contract class.json file. This is what we used to write both declaring and deployment, is the contract class file. So, but first of all, you have to like, you have to set your account. Like, account is like, okay, you have to set the, the account you're going to use to deploy the contract. Because you know that every contract I'm deploying on any protocol, it must be from an EOA. Like, wait, what's an EOA? So if I deploy, it must deploy from an EOA. So for you to set it up, you first of all like set both the keystore. Instead of going to do the env, normal env that you used to do, and then import, you just Import the file directly. It's encrypted, so import the key store and then import the account itself. We'll now be passing them on the CLI.

152:28 A: Sorry.

152:53 B: Masha'Allah, this is good. Then let's do something like this now. I think so. So I'm throwing that. It's just simple. If you also throw that screen, you just You get everything right. Is that a control room? So this is to import the keys that you're going to use. Like, it's encrypted first, then it's the details of your account. Like, instead of you going to pass your private key here, that you know is not advisable, it's not safe, so they encrypt the details they need from your account and pass it by themselves.

154:10 A: Come again.

154:19 B: I think it's kind of a simulation, pseudo simulation, because you are not passing. It's not going to collect your private. Once you pass your private key here, you can use it to create, generate chats with those keys, and they are encrypted with cipher and ciphertext. It's just more parts and jargon. So if you click on this, it will request a private key. So now Yes, I want to see my private key. Let's just use one private key from, from Katana is built inside Dojo.

155:26 C: Because the installation you gave me is Katana.

155:31 A: Yes.

155:34 C: So if I install Katana now-

155:36 B: You have to install Dojo, then Katana is embedded inside it. Like you have Sopree and Katana. Anyone you use, just I know, you just type the name.

155:49 A: Okay, like, it's only Dojo.

155:53 B: How do I explain this? Inside this laptop now you have CP, have maybe disk jacket and all those ones, but it's still inside this laptop. Inside Dojo you have Katana one side, you have Sozo one side, so you must install it with closure of, then the one on the 9 minutes we want to use, we now like pass it from the command line. That one will come up.

156:19 C: That's what I'm saying. Like now, where I'm going, let's say it's the activity that I want to do now, do I have to now say-

156:29 B: No, no, no, just pass katana. I'm going to paste the private key, but you will not see it here. Like, you will not see it pasted. I don't know how they did it. Don't ask me questions. I've pasted it. So it's asking for a password. It's not your laptop's password. It's normal that it must be your laptop's password. You can just pass any number or anything you like. When you want to deploy it, you ask for it. So it has created a new file for us, keys.json. Have you seen it?

157:22 D: Of course.

157:26 B: You can see that. Open it. You're going to find ciphertext inside. So look at the content, it's only jargons that you see here. Me, I don't know anything inside it. I just pass it and do my work and go. I think there are just 3 marks. This mark here now, I think it's the hash of either the system CPU serial number or anything. They're hashing things from the laptop, then combine it with the salt to generate the secret key for you. Just anything you can remember, because you're still going to pass it when you want to become- so next, next is Yes, actually this may not work. This will not work. Are you still seeing my screen?

159:39 D: No.

159:41 B: Don't worry, don't worry, don't worry, I'm coming.

159:48 A: It's not like I don't trust you guys.

160:13 B: Exactly, exactly. You get it's for security purposes. I'm back online, I think.

161:17 A: Yeah.

161:24 B: So after you have added the keys, you have to fetch the account that you're going to use. So the way to fetch it is to follow this command. The way to fetch the key, the account, is to follow this command here. This one now will require an RPC, so we are going to pass an RPC. I'm going to get- just go and get one from Juno. So I think this is one of the most reliable algorithms that makes this one MetaMine. So I just send the link.

162:16 A: Did you get the-

162:32 C: Yes.

162:33 B: So it's free and it's very fast. One of the most reliable altcoins on Stacknet. So if you want to deploy on mainnet, use the first one. If you look, you see that they write mainnet inside. If you want to deploy on Sepolia- all of us know now, Gwily is no longer, uh, working, so it has been deprecated. So you now use only Sepolia. Copy this link. This is what I was talking about before. So for you to like declare contract or deploy, you have to use Stackly or Stackly. That's why for the The keys now to import the keys now we have to use Stacklight. Now to even import the account to the Stacklight that we are going to use. Accounts, search, then search, you paste the address or your wallet address that you are going to use to deploy. So I copy my address. Let's see. I hope this will fly.

164:21 A: So are we seeing it?

164:41 B: If, if- okay. I think your Starlink is going to go off. Okay, it's not going off.

164:56 A: Oh, okay.

165:01 B: So first thing here, if, if the account you want to use to deploy your contract is not- it is not deployed on, on Sepolia, you cannot fetch it from here. Because they are only- only deployed accounts can be fetched using the stack live. Do you get it? Yeah, because before you can use any account on StackNet, actually, in all the accounts on StackNet are smart contract accounts. There's nothing like EOA on StackNet. They have told you before, yes or no? Yes.

165:38 A: Good.

165:39 B: We don't have externally owned accounts on StarkNet. Everything is smart contract account. So before you can use your wallet to do anything, you must deploy it first. So this one now, this one worked because I've deployed it already. So if you want to deploy, if you want to deploy your wallet, do we know how to deploy? If you just created a new wallet on StarkNet using maybe Agent or Bravos, Do you know how to deploy it? So I don't know how to deploy it. Just send- okay, go to any faucet. Uh, if you go through your wallet, you see that the right, like, deposit fund, follow it, you see faucet or anything, go to the faucet, then get some test tokens.

166:25 A: Let me see if this stuff is here.

166:28 B: I have- see, now if you're using Bravos Get ETH or STAK from Staknet token faucet. So if you click on this, it will take you to their website so you can get some testnet tokens. How did you get to this place? Okay, just click on deposit. Do you get it? The person asking the question. Yeah, I, I clicked on the message, but I can't see what you're seeing. Are you using Agent? I'm using Bravos. Are you on testnet or mainnet? Check, check if it's on Sepolia or mainnet. Okay, Sepolia. Yes, if you see it, unless maybe you're using another different version. But then you can still just Google, uh, Google StarkNet faucet.

167:33 E: Okay.

167:37 B: So the way to deploy your wallet is just to send small money from- maybe the easiest thing is to create 2 accounts. You have account 1 and account 2. So from your account 1, just send like 0.0001 to To your account too. Once you send it to another another wallet, it will deploy your wallet automatically for you.

168:04 C: I doubt.

168:22 B: Money? Yes, it's not expensive, just like it's less than $1 or something.

168:29 A: It's not expensive.

168:35 B: There's no time, I only have like 5 minutes. So after you have imported your account and after you have set your keys, the next thing is to Deploy the contract. Next thing is to deploy the contract. So just use package, use deploy, then target. This target dev is, is this file, this folder here. Are you following? Passing the target because what you want to actually deploy is this file inside here. So you're passing To access this file, you set the path, you pass the folder name, pass the second folder, then you get the stuff inside. So target dev project ETH2023.contract.json. I said before, what you need is the contract class. Just this. So these ones, I think they are for other purposes, but the one you need is this.

169:53 C: Copy.

170:04 B: That's, that's just- Yes, the path. Yes, so the project you are seeing here is the name of this folder. Yes, so the name of your own folder is okay. Just follow this, follow this thing like this. If even if you hover, if you see the, the, this thing, you know it. Yeah, so So this keystore now is asking for this, this key here.

170:56 A: Do you get?

170:59 B: Pass in the flag, the keystore flag, then keystore, you put this piece that you imported, then do account flag, then gact. You can use any name you want. It's not that it must be either keys or account. If you like, you can do- write account in full or write keystore in full. Anything you want, you can put there. It doesn't matter. The only thing that matters is that you pass the exact thing here on the CLI. Are you following?

171:37 E: Yes, sir.

171:40 B: Okay, it's not asking for password. So that the password that you used to set your keys on is now that you're going to need it. Pass it and then replace. Class actually created. Are we seeing it now? Let's say you want to like do library calls to this contract. Just copy this hash, pass it as a parameter inside that function, and then make the call. But then the normal library calls is like delegate call. I don't explain it well. Library calls on StarkNet, they are like delegate calls because the contract here, this hash, is not deployed, so it doesn't have any state. You know what is state?

172:33 A: Yeah.

172:33 B: All of us know. There's no state for any class hash. The only time state is assigned to any contract is when it's deployed on chain. After deployment, then I'm- So it's only after you deploy that you get your state, otherwise it's only class hash. And then one thing I'll do, I don't need to even stop myself about delegate calls. All of us know about delegate calls. The context here on delegate call is not the contract they are calling, it's the caller. I think 2 of us, 2 of us. So when you are making level calls on StackNet, the state that is being updated is not the contract you are calling. This is the contract that is making the call. Are we getting it now?

173:31 A: Yes.

173:36 B: So the class hash has been deployed soon. It has been uploaded on the protocol, on StarkNet network. Yeah, you can access it, you can do everything, and you can deploy this particular class hash a million times. Like, once you have a class hash, you don't I don't have to like start defining it again. One class action is deploying any number of contracts you want. Do you get it? For a particular contract, but then deploying contract, you can deploy it as many times as you want. Same contract, same bytecode, different contract addresses.

174:33 C: Why would you deploy?

174:35 B: It's your business. Now what concerns you? If you want to be deploying your contract, I use something different contract addresses. So the thing is here. Let me just break it down. It's like, it's like, okay, the same, maybe you buy 10 packs of sugar, you put all of them on the shelf. This one now, okay, this one, this is the location of this one. You return, maybe you write location 1 on it. You put another sugar pack, location 2. The same way you are deploying different, different addresses, the contract hash. Are you getting it?

175:13 A: Yes.

175:15 B: So that address you're seeing, that one, you're right, is just the hash. They hash the location and bring down the contract address for you.

175:24 A: Yeah.

175:38 B: So you tell people when you change, when you change the code base, go and tell them that, okay, this is the same address calling the same contract but different logic totally. I'm talking about when you update it now.

175:58 A: Yes.

176:02 C: Can I copy this address? Can you copy this address and send to somebody?

176:07 B: No, you can, you can also have the cross hash. I can copy any cross hash online and deploy on my system. So watch now, wait. Deploy now is accepting the class hash that we just declared. Are we seeing it? So we are now passing that. I just copied it, paste. We are passing that class hash as an argument on the CLI.

177:00 D: Is there a time?

177:57 B: Oh, you see, I had not passed the contact address of the owner. That's why it's returning error. No, no, no, you have to deploy. No, the API will not change because what, what we have in the constructor is not a concrete variable, it's just a parameter. So the API still has that, okay, you are supposed to pass parameter here.

178:43 E: CLI.

178:47 B: Yes.

179:01 A: Are you using this one?

179:03 B: It's the same one. If you let a guy hack testnet account, you just suffer in vain. So the contract is deployed. I just passed, passed the, the arguments and then want straight away to deploy it. Okay, so, ah, you know, it's stressful. It's not stressful for me. So in one, this thing, so if you have arguments on the constructor, you have to pass it in the CLI. So it's simple like that. If it's string, like if it's felt data type, I think you have to put this to indicate that it's felt, like double quotes. If it's integer, just pass it like that. If it's address, just like that. You don't change. Any question, online people?

180:14 C: Yes, yes.

180:19 B: He's there to control himself. I can't even carry all these things in my head. I have family problems. Any other question? Online people, if you have any question, now is the time. Our time is fast now. I'm on now. Who is laughing? I can't believe this has been three hours. No question, ba? Good night, good night, sir. Ah, good night, good night, good night.

181:01 C: So after only this, so I also want to see a light this morning.

181:09 B: Just follow the commands on that.

181:10 C: Just write that down. No, don't leave that.

181:28 B: This is satellite. Follow that, uh, my, that my article. You will see steps to install Stacklight. It's there too. Good night, everybody. We are done for today. So, uh, this is my first and last class, unfortunately.

181:55 C: Unfortunately.

181:59 B: No, you don't need it. If you like, shall I put it? But I think it's still wrong.

182:04 E: Drop your Twitter.

182:06 B: Oh, okay.

182:12 E: So the username you sent to the chat that time, is it Telegram?

182:16 B: Yeah, it's Telegram. Okay, so actually it's not simple because I'm not going to see again. So I'm done. Uh, other guys will continue from where I stopped. Thank you guys for coming to my TED Talk.

182:43 E: Thank you, sir.

182:46 B: You're welcome.

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.