Session 4 Testing with snFoundry and Debugging with Scaffold Stark
Starknet Basecamp 2026 · 55:11
A hands-on Starknet lesson uses Scaffold-Stark to deploy and debug a Cairo contract, manage token approvals, and inspect OpenZeppelin components. It then demonstrates snForge unit tests, assertions, caller-address cheatcodes, and fork testing against Starknet Sepolia.
Speakers
Topics
From Starknet Basecamp 2026, published by OpenBuild; community: OpenBuild.
Transcript
Hello everyone. Today we are going to continue on the next session of the base camp. This time we're going to talk more about Staret Foundry regarding to how test working on Staret how how can we interact and debug with the smart contracts using the scaffold start tool. So this is the team. This is me Jang and before it was also Richard giving some sessions. Uh on this part uh we're going to talk more about like how to test how test working on a startup and how can you interact with the your smart contract using the debug UI from scaff on this part uh as you remember before
you already interact and play a bit more with sncast that is one of the main commands to declare deploying b contracts if you want to use you know the CLI interaction No at the same time start fun provides you this SM forge that is mainly focused to you know to test uh contracts smart contracts in this part we're going to see more how scaffold start use this SM forge as you remember scaff is a framework a tool where you can build apps easily on star net deploy it build end to end apps it use a lot components but in now we will focus more on the kairo language
itself and the star foundry too why is stark because it's very important you know especially when you want to join to like hackathons and build MVPs or prototypes it's going to help you a lot in this part of like um uh how you interact or debug your smart contracts with you know easier to understand uh the UI is if you compare you know with the row CLI there are some documentation here that you can explore more about the starlet fun itself and yeah if you want to learn more about in general you always need to check
starlings to get what's the syntax of kairo then build some challenge solve some challenge using the speed span stark and now we're going to go into some live coding or live demo. We're going to use scaffold start as a main tool. So in order to install this template for example, you need to run this command. I'm going to run it. Um I'm going to open a terminal here for example on CD. I'm going to go here. So this file is empty. Okay. So I'm going to put this one here.
So, I'm going to have to create a project for my an iPhone, a project, my app. I'm going to put it I'm going to start some dependencies there. It's going to take a while, but let's see. Um, yeah. So, while we waiting for this, as you can see on this part on the Scaffar website, it has everything. It has the extensions where you can, you know, uh, create a basic a better template or a specific template for you. Uh it has the layer that is you know the speed run star that we we mentioned before where you can solve like a many challenge here and it also have the documentation that
is the most important one that we also will follow in in order you know how to interact with this app. For example, here after that we can go to w start to installation. Uh uh first of all we we must install all of these like node jar and g that you guys must have and we can go to the option number one where you we can install you know all the dependency that we need for specific for staret. If you follow the previous session you already use this strap also. So it will install all this like scar staret foundry sdf extension start net that you also play
before. Um and after that you have to run this command. Yeah create start later that is the same as we run it here. So in my case I I just jump direct into this one uh because I assume you already work on this. Okay. So I want to see my installation on this part. Everything is good. So what I can do is you know to jump into my app call your change your deploy and start but I'm going to go for this cd my app.
Uh I'm going to go with cursor to see I'm going to make it a bit bigger. This one. No need for now. So as you can see it's going to give you a basic template. The most important files uh I can say they are here in package we have nex and fun on foundry we have more everything related to the smart contract and back end side. So here one of the main file is um on contracts and we have the scapto that is our um uh we can see what version of staret of
kairo we are using that's 2.16 and as you can see also we are using like a staret u forge that is for testing and few more details that we will cover again and the main smart contract is in this this is the template the smart contract we are going to check. Uh so if we follow this part uh we will see okay uh cd j install you already have it and then you don't need to follow here for example in order you know to have all the required installations we need to check this with hdf install check if you have some problems otherwise just you know uh
check also this op option too if you want to run docker but we can skip it this Okay. Um the dependencies, the setup. Okay, we go into the next one. It's like a jar chain. So what we going to do right now in this part is we're going to interact direct uh we're going to start doing the debugging with scaffold stark. It's going to be like easier this way. So we're going to start doing the debugging. So in order to do that uh I'm going to close this. We need to run the jar chain. So I will go to my cursor.
Now always double check that you have the jar installed working because we did the installation before. Now it's kind of quick. So I'm going to follow the chain. So J is going to do is going to you know uh run a local dev net for me. Okay, I have a local demet here. it is going to be easy for me to test this smart contract because I'm going to deploy the smart contract on this deet on this dev net. So the next things I I can do is um to J deploy but first I will try to with J compile uh J compile is going to you know at his name itself is going to compile the smart contract and generate some like internal files that we can use it is
good of course if maybe I don't know if something is wrong here it's going to it's not going to compile I'm going to put here compile again and it will detect something is broken or here it's broken because I I mess around. So [snorts] I always need to check if it compiles right now. I'm going to run J deploy. What J deploy does is it's going to compile again. As you can see it's uh compiling and at the same time it's deploying on the on the local Devet. As you can see, this has been moving because it has deployed the smart contract.
Okay, good. And now what I'm going to do is like uh debug this smart contract. So I'm going to give this yarn start so we can start interacting and debugging with this smart contract. Even though we didn't have a you know a deep dive into smart contract, we are just going to start interacting and then you later can you know understand this much better. Okay, we have this uh running on this part. Um we can go to here to local to see if it is working or not. Mhm.
Okay, it's is live already. You see? Okay. So this is the main debug UI uh that we have. This is just the first page. So on this hub we have many options. Uh the facet block explorer, what is the price of a stark uh what is the wallet that has been connected here. In this case we have you know other options how to connect on on this part. We can connect to dep net with any of these but ideally we need to connect with the burner wallet. It's the the easiest one and we can choose any of this burner wallet
that that are linked to the deet to the local hosted. Um okay cool. So go to the main point. What we have here is like okay we have deploy a contract called your contract. How do we know that? Because as you can see this is the my contract name. Okay, contract is the same as the one that we have on on this parts. Deploy contract deploy ts here. Yeah, we have a a contract call it your contract that is the same as this one. So we right now when we deploy here with this J deploy we deploy this your
contract and that's what we can see on this par uh on your contract. Okay. So what happened here is like this your contract have some basic functions basic read functions. This is the read function that doesn't need any input you know parameter. So by default when we created this contract we assign this like a build unstoppable apps string. There is a premium variable that has a value of false. We have the owner of this contract that this is is this address that is the same as this one and I say we we have some right options.
So we have this grid uh grating but we can set grating means we can change this value and few more other values there that we can check as well also. So what can I do now is okay I have this uh value that has been you know uh that is has been set up by default but I can update it. So I can put like um uh hello open build and I can go send. So as you can see the smart contract now has been changed. It means like the value of the value of this like ging variable has been changed from building apps to hello open build.
Yeah. And this happened also on this part as you can see something has been changed on the deet. Um but yeah just now uh so we can keep you know uh creating more or uh updating more on this part. Something interesting about this is like okay how do we change this value because we don't have any [clears throat] set premium the way we change is like okay I have this option here also if I want to set this like u if I want to update this greeting value I can provide
also some like um star tokens to this smart contracts. It means like okay I can update this like u data and uh I can pass here some value that okay I will say I will transfer to this smart contract uh one star token. So with this I'm saying okay I will interact with this function I'm going to update the greeting variable and at the same time I'm going to transfer something here one token one start token and after that this variable will will be update to true
we will do that but as you can see we'll get the error because the thing is like if we want to interact or with the smart contracts there that are you know transferring tokens from here to there before everything what we need to do is to interact with the contract itself and request some approve it is more related to the how ERC20 tokens work here if you have a ERC20 token uh you always need to approve first and then later on you need to make the transfer in this case we are trying to do the transfer first um but cannot that's why we need to first to go to this part to the star token.
Remember the star token is uh is a smart contract itself. So as a smart contract um we need to uh get some approve that someone will spend some of his star tokens on some smart contract. So here if we go to a loop and this part we need to say okay uh this user this user this 064 user because he's the one that is interacting here. So this user will uh will spend some amount some uh amount of tokens uh when he's
interacting with this smart contract. So we need to pass what is the smart contract that this user will interact and will spend some uh start tokens. So here we need to pass the contract that we deploy. This is your contract. So we're going to copy this. Come back here. Go to approve. I'm going to paste this and and here I have to say okay I'm going to spend one start token. Yes. I'm going to go one complete the zeros because we need to put all of these zeros and then okay I just did the first step it means like u uh this user that this is me that I'm interacting with this
smart contract this user has a proof that he will spend some star tokens on this contract your contract okay so since we did this first step now we can execute this function because this function will try to spend some money from your site but you already approved this kind of like spending. So okay now we can try it one more time and it has been executed. Now the new value of getting is tah and we have this uh premium that has been updated to true because before it was like a false.
So this is the main part or this is you know like a overview of this contract interaction but now we're going to jump into the code. Okay, we did the interaction but we will jump into the code. So what we did is like we deploy this smart contract and we did some interaction but we will check more how is you know how does the smart contract looks like. First at all we have this first block. So on this first block we have this like we define like a public trade. It's where we is where we define the interfaces of our smart contract. So we have decided this smart contract will
have these interfaces like a greeting set greeting withdraw and premium. Um you always need to start with this annotation star net interface and then public because you know we want to read it later like a public trait the name of this like a interface and this is like a generic value there is something that we will deploy and instantiate later but we don't know yet so we just call it like a generic but it's going to be something related to the contract state of to the smart contract. Yeah. And when this part we say okay we're going to have a function greetings that is going to have a you know a snapshot a simple reference to the uh
generic value that I'm going to initiate here initialize it here and this function will return a bite array and a bite array is something like you call it like a string kind of like a a string a type it's not exactly a string but we can call it like a a string type set getting. Okay, we're going to have a a reference of [snorts] the a smart contract. In this case, it's still a generic, but the reference is going to be like a mutable reference. Okay?
Because we're going to change something here. This going to be like a set. So, we're going to change something. So, we're going to make a reference, a mutable reference using this keyword. So if we use this like operator here, it's going to do just as immutable reference. But with this part, we're going to do a mutable reference. Okay, we we will need to pass the new greeting and the amount of star that I will you know uh transfer on on this part. We have this withdraw function where we can withdraw the money that has been you know allocated into the smart contract and the premium that you know will return if it is user if the user is like a premium or not true or false. Okay I
have defined this interface later on I have to go into the next uh module I can say into the next like component that no let's skip the model into the next module. This is where the smart contract itself is going to be allocated. So we need to put this always like this annotation and then create a module with the name of your smart contract. This part I'm going to skip. It's going to take me some time. I'm just going to go direct into the storage. So after we create a module of our smart contract, the most important part is the storage.
So we need to you know annotate the storage with this part. Create a struct called storage. And then here on the storage we need to define what we're going to you know what are the variables that I'm going to uh use on my smart contract. We have the greeting variable that this is a bray by array. the premium that's going to store up true or false the total contract that it's going to store you know um how much uh how many times how many user have interact with this smart contract yeah user setting contract so I'm going to map um uh the the users you know how many user has been interacting with this
smart contract but this time I'm going to store their their their their address. Yeah. And something interesting here is like we have something called super storage. So this super storage is linked with this ownable. So here on this part I have a logic about you know how ownable work in this smart contract. Ownable means like uh who is the owner of this smart contract and who is actually able to you know to edit this or to create some like uh or to update this the state of this smart contracts and the variables. So all of this logic has been you know encapsulated and reduce it thanks to open sapling. So on this parag
open sling we are importing this ownable component that is going to have his own like a logic the ownable component has its own logic that is pretty similar to smart contract but it's not so in this part we are not going to we don't need to write this logic so we are going to reuse this component from open sink that's why we need to do a few more steps like I also you know complete this like um uh component with a path, a storage and event because this company itself is going to come with his super storage with some events that we can reuse.
Uh on this part for example we are saying that this component this own component is uh can expose some functions that has been defined on on his size and my my smart contract you know can also uh use it and expose these uh uh endpoints. So later the UI can read it. Here we have located saying that we will use some internal functions from the ownable component. It's okay. And as you can see we can create our in our smart contract our events but we can reuse this ownable event. Yeah from this part from this ownable component.
Uh but besides that we can create our own event that is uh looks like like this. You can have a look more. So yeah, so this is very important part because component is um it's one of the most like advanced techniques we can say and if you know how to use it your contract is going to looks very clean and very powerful. No and at the same time you will use you know something that has been audit from open sling. So you're using something that is very you know bar tested instead of using your or creating your own logic. Okay.
Okay. Cool. So we already have defined the storage with all of this. And what happens here is like okay we have defined a constructor and usually this constructor is going to be you know called once we deploy the smart contract on this escape. We deploy the smart contract. We call it your contract and we have to pass the you know the arguments of the for the constructor. In this case we need to pass the deployer address who is the one that the deploy account that the account that is deploying this uh smart contract is going to be the owner. That's what we saying. Um and we and we define the details of the function here. uh a
constructor it's going to be always like um using this annotation and using this name. Um here we say okay we have this variable greeting that may have like a nothing can be like a empty it's like a empty stream can be empty stream but we are going to deploy again saying okay uh building awesome apps in this case it's a bit different uh if we J if if we run here again for example J deploy It's going to deploy again the smart contract but in this case by default
this going to be the the the new value of greeting. Okay. So if I go to here you can see now now the new value is building awesome apps. Yeah that is different than the previous one. So and then yeah you can keep working and playing around with this. Yeah. And at the same time when I'm creating this the project this is my contract I'm saying okay I'm going to call this cells ownable that ownable is this component that you know I just like attach or inject here and it's calling this initializer but this initializer is I didn't defy anything on this part yeah
because I'm reusing what is done on the on the on the ownable component. So if you want to check more for example we can go to the open sling part here for example I'm going to go to this part open sapling open sling um let's go to this 2.0 zero. Uh on this part I can check on this uh components. You can check more about you know this like u how components work and how can you use it on your smart
contract. Uh we have this here accounts you see accounts no hereable component. [snorts] So this give me more you know details about what's going on with the owner components. As you can see um there is a function called uh initializer. So if this one yeah the owner component has internal implementation that is the initializer and as you can see it has implemented this here I need to pass the the owner who's going to be the owner of this like
a smart contract uh and I have to pass this data type a contract address let's see here also also emit a end that you can check more uh but yeah so definitely you can check more on uh on this part better if you just goes you know direct to the GitHub it's going to show open s contracts here on on this part this is more for the solidity one but you can check for the kairo kairo contracts Uh make sure you are in the in you're
using the the right that is the 2.0. Yeah. Uh and you can go into this one. Yeah. And then you can start working. You can check here how is the initializer. You can find this function and you know check more what's going on there. Okay. So [snorts] with this function that I'm reusing for the honorable component, I'm just going to say okay, this owner that I'm passing here is going to be, you know, this contract address is going to be the owner of this um smart contract.
If we go below, we are doing the implementation of the interfaces. On this part, we define the interfaces. But here below, we are going to u implement these interfaces. So in this case I need to pass a contract estate in this part not a generic anymore. So this contract state is going to be the smart contract um self contract state. So I just can read if I need a function greeting I just read the self greeting that is going to go to the storage and read it. set greeting is a bit more like okay there is more logic here because basically I'm going to say here if I'm going to give some amount of stark I'm going to change my premium to true we're going to
see if I don't pass any amount of stark I'm going to change this premium to false this user to false but remember yeah always if you want to transfer some like tokens of star tokens or need tokens here. What you need to do is to create a instance of this smart contract of or instance of of this token. So you need to create uh get the start token contract address that I'm getting this way and then you need to call a dispatcher that's going to help you to instantiate this start uh u token contract. So we have this here. So after this is instantiated we can execute a
transfer. Yeah. Okay. execute a transfer. It means like a get caller address. The user that is interacting with this um you know uh smart contract uh is going to transfer some star tokens to the uh contract address. Yeah, the get get contract address is the you know the address of this of this like a contract. So okay. So get caller address is going to be the user that is interacting with the contract and will send some amount of stark to the contract address that we interacting that is the uh your contract that's what we are saying on this part
to the stark dispatcher. So some the start u some like star tokens we will send um from this like user wallet balance to this contract address. Okay. And then we will emit a event also here. You can check how is it. We also have this like uh withdraw function that we can check it a bit later and premium. So yeah, this is just like a big overview how this like a smart contract um how is the logic of this smart smart uh contracts uh uh working.
Uh so the next part that we're going to jump now is the testing part. As you can see um there are some tests here that we had on this folder test contract. It's very interesting. So besides to deploy or to interact with your smart contract using the scaffold start debi you also can run the test. Yeah. And this yarn test what it's going to do is like internally it's going to run the commands of staret forge. Yeah. Or start forge.
As we can see we have defined on this part that we going to use star forge for our testing. Uh something has been failing here because maybe I changed something around should be the right message. Uh we will check this soon. Let me see if I updated something here. I have any ideas. Oh yeah, here I have update something. So that's why my test are failing.
That's good. So I'm going to remove this part. So my test will pass for now. Going to do jar test again. Oh, as I was saying. Okay. Uh we're going to explore more on this how this test working. So as you can see uh we are into this file. So the first thing that uh we need to check is like okay uh we have this like u this two tests that has passed. Okay, this two test has passed. I'm going to remove which one.
I'm not going to use a scuffle star UI anymore. So I'm going to remove this one to make it easier. I'm going to put this deet de also on it. Okay, as you can see there have two tests that have passed. First test is set greetings. So and the second test is okay some like a transfer. So I'm going to check this one. So in order to build this like a unit test uh first uh we need to do is like we need to create a instance of this smart contract that we have here the the contract. So in order to that we going to we need to create a internal function
called deploy contract. So this deploy contract will simulate you know the uh the deployment of the contract that you you want to work. So the details are here. I'm going to just leave this one to you to check more. So basically here I'm going to just say okay I'm going to deploy the your contract. Yeah. Um uh this can be any name actually. This is just like a you know uh a a bite array but in order to keep it consistent we're going to call just your contract.
So when I deploy the your contract uh it's going to just give me you know like a address and after that I have to also to get the dispatcher because with this dispatcher will allow me you know to interact or to get access to the entry points or to the functions. So this first step just going to deploy the contract but you just have the address you know. So with the address I cannot do that much. I just look at address but with the dispatcher I can access to the functions of this smart contract that's why we need these two steps deploy the contract get the address of that contract and then uh
instantiate a dispatcher. So with the dispatcher I can access to get to this like a greeting function that is this one. Yeah, that is this function. I can access to this this one because I have I have my dispatcher here like a live. So with this function I'm going to get what is the current value of greeting. Okay, good. And then I'm going to put this a bit more here. And then uh I need to test with what is expected value. Since I'm deploying I'm I'm you know saying that on my constructor this is going to be my string. So my expected value should be
this one. Yeah. And then I just going to jump into assert and and then it should it's going to compare yeah the current value of greeting with expected value and if it is not working if there something wrong I it will emit you know some like error message okay something happened here should have the right message same for here for example uh on this case uh on this first block I'm just checking if the you know after I deploy my contract the default value is the correct one or
no and then after that I'm going to update this greeting okay I'm going to create a better type I'm going to put in like a second um second like value for this or a new value for this I'm going to call the set greeting I will pass this you know uh value set greeting just give it the clone in case and here the set greetings we I need to pass two values here let's see here on this part set greetings I'm going to move a bit more this here I need to pass the new message and then the amount of stock that I'm going to
pass but this is a option value but in this case I'm not going to pass any any kind of tokens money and you're going to give it like no. None means like we don't transfer any star token. Yeah. Okay. And then again my dispatcher will read the the new value. Yeah. The new value of greeting. And this new value should be uh and then this new new value should be the the the same as this new new greeting. Yeah.
So that's why if I run this test, it's going to run like okay. Uh yeah, jar test is it's going to execute this this part. Yeah. Uh to test the first time is done. The second test taking longer because um I will show you how later why later. And then it has passed. I'm going to put this first maybe. Yeah. Um I'm going to comment this for now.
For example, like I I can see it's going to fail because before I put like uh awesome yeah build awesome apps that is different than build unstoppable apps. So if I if I like um call the test is it's going to fail. Yeah. Because he said okay should have the right message that this is the error message that I'm getting. I set up here. Yeah. So something is is wrong there. That's why it's not passing. So I'm going to sorry it should have the should have the right message on this part. Okay. So I'm going to just revert this um
on this part. Okay, it's correcting, you know, it's like uh we can see that test is is working well. Now we're going to go into the next part of the test is this one the we going to uh we're going to [snorts] enable. Now again this part is a bit more interesting because I'm going to fork the blockchain but on test net it means like um this fork is thanks to this part for example here on this part on this like a scar I'm saying that I'm going to use SM forge for my dev dependencies that's mainly for testing
and here I'm I'm I'm going to you know do some like a setting setup saying that I'm going to enable this fork for SM forge. I need to pass a URL of the RPC in order to you know to read this uh fork of the blockchain on Sapolia and I'm going to fork all of this until you know the latest block until the latest block has been you know like um produced there. Okay, that's good. Since I have this enabled, I can go here and I can do a test and fork. I'm going to say, okay, I'm going to fork this sepoleia blockchain. And what's going to happen is like, okay,
let's go one by one. I'm going to simulate that this smart contract is running on the Sapoleia. Yeah. On on Sapolia on Sapia test net. So for that, I will need a user, a user that lives or is live there on the Solia blockchain. So have this lead user that call it the owner on this case. So I'm going to go here. Okay, this owner has been use it also, you know, to deploy the smart contract. It's good. But what is the address of this owner is actually this one. Yeah. So this owner that we using is actually a real wallet deployed on Sapolia. So how can we test that? So we go to this part.
If we go to I'm going to start closing some some of them. I'm going to go to boyager. So on boyager that is you know the block explorer. I'm going to put here on sepoleia and I'm going to pass this uh user that. Okay. And as you can see what happens is like okay we have a account contract remember that on startet we have um a smart contracts itself but also account contracts. Yeah this there are like the the wallets that lives on on on staret and even they say okay this
is a ready wallet. Yeah because you also have braas wallet and few more others. Okay, this is a wallet address that is live on a smart contract since uh two years ago exactly almost two years ago and [snorts] it has some balance. It has some balance on ether and start token and and few more and then it's good. So I can use this smart this user that is on Sapolia to start you know testing my smart contract. So okay, I have this owner that is I have this user that is the owner of the smart contract because here
I'm passing I'm saying that this owner is going to be uh this contract address or account contract address is going to be the owner of this uh of the smart contract that I'm deploying. Okay. So that's why okay I have this lead user is going to be the owner. I'm going to deploy the your contract that has it's going to have the this user as the owner. I'm going to instantiate the dispatcher of your contract because I will need to call some functions. Then I will need to instantiate ERC20 dispatcher.
Uh in this case it's going to be the start tokens because I will need to transfer some star tokens. So I need a instance of this as my contract. So as you can see it's very useful. Yeah. I have a instance of your contract that's is this one and also have a instance of the ERC20 token that should be that this is this start token. Okay. And then I have defined this amount that I'm going to transfer. I'm going to transfer just you know something very little like a fiveway or 500 way uh and then this is important part the sheet color address remember this sheet color address and few more things has
been um has been like import from SM forge yeah so at this point we are using SM forge already as you can see SM forge we have um we we have import all of these that I'm going to explain most of them and on this part we have this cheat color address that is coming for SM forge there that is the tool that call it like a start foundry so what happened here is like okay what we going to do is like um we're going to call some approve yeah remember before in our previous manual example that we did with scaffold stock before we execute some transfer we need to do some approve
So in this case on the test you have to do some approve also and remember when you have to do some approve you have to go to the staret token contract. So what we need to do here is like uh on this testing environment we have to call this cheat color address and we will say okay uh now we have to interact with the start token contracts. This a minion we have to interact with the start token contracts and the one that will interact is this user that I have defined here and it will interact for a you know spam for a span of time of one. So maybe just one operation like like this.
So okay into this testing environment I need to set up this because by default when you do the testing you interact direct with the with this with your contract but in this case we need to interact with start token contract. So we need to call this like a sheet color user sheet uh color address and we have to say who is going to interact with this start token contract. Okay nice. So I have defined this and then I have already the instance of this ERC20 dispatcher and I have a a pro here. It means like this ERC20 token has a proof function that what it is to do is like okay the user this user is going
to you know approve that some amount of some amount of star token will be spent on their contract address that is this one. Yeah. So this is what we saying uh on this part. Okay. Is good. And then then we have to make sure yeah if this has been executed or not. So after that after this block has been executed we need to uh double check with allowance. So for allowance anyone can call this actually um allowance um because it's just a read function. you don't need too much setup. So in this
case I'm going to call again this ESC20 dispatcher um uh but in this case I'm going to call the allowance function. This is a read function that I want to ask okay how much allowance that this user come you know spend of this uh started contract on this like uh your contract that we we deploy and this approved amount should be the same but this amount to transfer that should be 500 okay that's that's why okay I I'm going to make this assert now so I'm going to um put like this to make it keep it
simple and I'm also going to keep like this. Okay, I just going to test this first assert jump test. It's taking a while. Okay, that's that's good. Something else that you can see here is like you can also use prints here. For example, what I can do is like I can print what is my balance here on on this part for example uh or what is
the what is this value even before I make the assert. So what I can do here for example I going to print my balance before so I'm going to create something let balance balance of user okay and I'm going to print and I'm going to do the third I'm going to print balance of user I want to put here just like this so I have this dispatcher I'm going to say balance of this user okay I'm going It's generate how much start tokens I have and then on this part this is I have this let approve it amount I'm
going to see actually how much is the pro amount print approve it amount okay here so you can also see on your test how much is it it's giving some warning because I'm not using this fork but as it's supposed to be used but it's Okay. Um, this part is good balance of user. So they say I have this amount of tokens in terms of star tokens and the approved amount that has been set here is 500.
But it's okay. That is the same as 500. That's why this assert has passed. Yeah. And so as you can see on this test we are reading what is the value of a wallet that has you know some balance on Saporia that's is very powerful. So we so they say I have 467 star tokens. Let's see here if I go to Boag if I have start token I had 467. Okay 3k start token. Okay that's that's okay.
That is the same I have here 4673. Okay. Um this part is okay. So I'm going to unc comment this part. So in this part the second part is like okay I'm going to uh set again a string but in this case uh since I'm going to transfer some amount of money again I need to call this cheat color address in order to set up again the environment that's saying okay the user the user is going to interact with the you know with your your contract with the contract that we we are using now
uh okay then after that I'm going to execute this uh transaction or this transfer I'm going to tell the dispatcher of your contract set greeting new greeting but in this case I'm going to pass the amount of transfer there that is a bit different than this contract for example I just call set greeting but I didn't pass anything here I just pass no like nothing empty But in this part I'm going to pass the amount of token to transfer and I'm going to make the assertive assert your contract dispatcher should be you know the the the the new greeting that um I'm expecting.
So your contract greeting greeting option. So here we trans for 500 ways. Okay. So I'm going to call again this um this this function [snorts] for example. What else I can do here is that for example since I transfer this you know this 500 way here I can check again what is my new balance here after I have this after I have executed this has now here and let user
new balance and it's going to give me the new balance of the user and should be you know this part should be like uh 47 like this. We're going to do it again because um on this when we executing this test we are transferring 500 way so my balance should be you know decreased. Yeah. So as here you can see 52774777 because I transfer 500 way.
Okay. So as you can see startet uh found is very powerful tool. For example, this part you can put just like a mainet mainet latest and you also can start working and testing how your app will behave when you interact with you know smart contacts that live on mainet. That's why it's like very very very useful when you want to build like you know production ready apps you need to do a lot of testing and this is one of the main important ones that we increase here. on on this part. Um, as I mentioned before, yeah, we have all
of these resources that expect you guys to can check more. As you can see on the standard founder, this is a very very huge uh uh huge like a book where you can find more ways to, you know, to play around. Um, you can use it. Yeah, like maybe use more of these things that you can read here. Uh bring it here live to the scaffold start like a base uh test files.
Okay. Uh that's that's all for today guys. We explore how to interact with a smart contract on uh scaffold stark and you know how scaffold stark use and make use of forge that is this tool that is inside uh foundry uh tool as well. Okay, that's all that's all for this video. See you next time.