What's up guys, welcome to today's video. So today we are going to experiment with some red hair color. I'm really excited to share with you guys this technique. It creates tons and tons of depth dimension using red tones. And also I'm looking forward to sharing with you guys how intense the reds are in the Joyco Luma Shine line. So if you guys are watching this video anywhere other than the FSE Now app, you're watching it later than everyone else. If you would like to see these videos before they're actually released out to social media, then make sure you download the FSE Now app. That's FSE Now, or go to freesaloneducation.com. You can create a free profile, get yourself set up and you'll get alerts when all of these videos come out and you can see them before anybody else. All right, I can't wait to share this technique with you guys. Let's get started, here we go. All right, so to kick off this technique, we're gonna be using the Joyco Luma Shine permanent hair color, cream hair color, six NRG. That is a natural red gold. And then we're also gonna be mixing in the Level 7 RRC, which is a red, red copper. And it's got the J5 fade resistant technology in it. Cool thing about that technology is it means it's gonna last up to 30 washes and it's not gonna fade. So that's one of my favorite things about this red hair color. We're gonna pop in a technique of super vibrant red color with multi-dimension. And that's what I'm gonna show you guys today on this shag haircut that we did a few days ago. So if you haven't seen the haircut video, look it up and look for that shag with bangs or layered haircut with bangs and you can see that. We're mixing it with 10 volume and then I'm gonna prep the hair using Joyco Defy Damage Pro Series 1. This is a bond protecting spray. Yes, I said spray, you don't have to put it in the hair color, you spray it right onto the hair. Super easy to do. I take it section by section about one inch at a time, work my way up the hair, up the head and I spray it straight down at about five to six inches away from the hair. And that's it and it's ready. The other great thing about this is not only does it build the bonds in the hair but it will help brighten your blonde as you go through and do that. So to start off our technique, what I'm gonna be doing is zigzag partings. The reason I like zigzags because it creates an in and out depth within the hair color. So I'm gonna clip the top away and then I'm gonna work my way down the side and I'm gonna clip that away as well. So super easy sectioning in this time, in this moment of being a hairdresser, I think time is very, very valuable and we're gonna have to get our guests in and out of the salon. So these techniques are built for that. I work my way through.  I wanna brighten the front and then that zigzag that happens on the top is where I'm gonna put that level six, the depth all over the rest of the head and it's gonna fall over it and veil over it and you're gonna love this end result. So we start off painting our lightest color, our level seven. Now, I've talked about this before. I like to stay about a shade apart. That way you don't get too much separation in that level. So that really it's just about bringing tones together in movement in a haircut rather than having a super light tone and a super dark tone in the overall technique. So I paint that through scalp to ends. Nothing fancy here guys. This is the level seven RRC painted scalp to ends. I'm gonna paint it through around the face. I'm gonna paint it through the fringe and then right down the side on the opposite side as well. So just working that color through. Joico's cream hair color really has a nice consistency to it, really conditioning to the hair. So I paint that on, it goes right into it. I just make sure that I'm working it with my fingers as I go through. Now you'll notice I didn't do a ton of the fringe. So that's a key thing when doing this technique. Don't take too much fringe in it because I want the darker color to actually fall over. I don't want her to have bright bangs and then dark behind her head. I want it to blend. So just a little bit of zigzag in that front, maybe about a half an inch to an inch most and then pull that rest of that fringe in with that darker color, which you'll see it at the end. You'll see how that works out. So just working that color back and forth, painting mid-shaft to ends, swiping back and forth, working it with my fingers. Just you wanna make sure you have overall saturation. Now this is gonna be a much brighter result because we're doing it on blonde hair. So if you had somebody with like, let's say level five, level six hair, it wouldn't be as vibrant but it would still have a nice pop. So just think about that in terms of what do you want your client to have? What is your client looking for? If they wanted a really bright pop of blonde, I would go through and do some balayage first and then I would overlay it with this technique and almost use it as a toning technique. Okay, so just think about it that way. If she doesn't want it super bright then go with these tones and do it over her brown hair and do it that way. So now we're gonna work through the top. This is the 6NRG.  I did do a little bit of foil to separate. I don't keep that foil on the whole time. What I wanted to do is just make sure that I didn't completely get the, that RRC is a pretty vibrant color. So I didn't wanna get it on the mid shaft as I was painting through the top. But then once I get the hair all painted back, then it's fine and I'm not worried about it at that point. So then we can let it process. So once I finish up putting the hair color all over the head, I work it through with my fingers a little bit more. I'll even do a little color melting right at the scalp, kind of smearing everything, smearing is a weird word, but smearing it all together just to make sure that I have all that saturation at the base. Work it through the ends again. See the finished technique here. So just that zigzag, that depth that's gonna happen. I can't wait for you guys to see this end result. We're gonna let it process for the next 35 minutes. We're gonna make that happen real quick. And then here is our end result. Look at that pop, that beautiful, beautiful bright red tone. I'm finishing up with the Joico Beach Shake Texturizing Finisher. Builds a ton of texture into the hair. You can see that depth that falls over the top of the fringe.  So make sure that you work on that sectioning. Hope you guys like this technique. Let me know if you have any questions in the comments below. Thank you so much for watching.


Hopefully everyone can hear you now, Hannah, just let us know here in the chat. Okay. All right, so I'll recap what I said there, the short version, apologies for the delay. That was my fault for messing up the daylight savings time shift. But here we are. We're at Unit 7. This is, again, this session here is based on the assumption that you already have some familiarity with the content in Unit 7. And as always, please ask lots and lots of questions, drop them in the chat. I'll pause periodically for questions. And Mike will let me know what you are asking. Today, what we are covering, well, the Unit 7 topics, right, are what's in a transaction, typically looking at fees. The transaction timelines, what happens, you know, as the transaction is created and broadcast and goes through the mining process, etc. And then the really big topic for this unit is scripting. And that's what we're focusing on today is learning a bit about Bitcoin scripting. So I'll pause here just to make sure Mike, everyone can hear me. Am I getting some people to conduct? We're good to go. Okay, cool. All right, so scripting. And if you're, you know, a developer, and you're used to building things in PHP or Python or JavaScript or Golang or something like this, you know, Bitcoin scripting is going to look really foreign and really weird. It's basically kind of a very old school sort of simplistic way of doing things, right? It's not like a modern programming language. So it can be a bit difficult to follow along with what's happening. It's kind of written backwards and we'll walk through it and we'll look at lots of different examples. And then we're going to go use a Bitcoin script simulator and, you know, walk through different examples to try and just get a feel, try and get a picture in our head of what's happening here and how Bitcoin does things, right? And then we'll touch a little bit on some advancements right at the end. We'll just walk through a couple of advancements in Bitcoin scripting, but for the focus for today is really to hopefully give all of you just a good picture in your head of how Bitcoin handles what this Bitcoin script looks like and how Bitcoin processes it. Cool. So let's get started. First, though, we're going to go over some notes on a couple of other parts of this particular unit before we really dive deep right into the scripting. So we're going to talk about fees. Now, last week, if I remember correctly, last week is when we went and set up a little reg test node and when we actually created a transaction and then signed it and broadcasted and went through all of that. And so there we got to look at fees and how their input into a transaction and how they work, right? So first on that, if you remember what we did is that these aren't directly specified in a transaction. These are what's left over, right, between the inputs and the outputs, right? So you have a certain amount of inputs and that goes into a certain amount of outputs and then you should include a fee, right? And that difference are going to be some small difference between that and that's the fee. And again, of course, remember we try and put absolutely as little data as we need to on the blockchain. So because the just having the inputs and outputs gives someone else enough information to calculate what the fee is, we don't need to clearly, you know, separately specify it because there's enough information there to recreate it. We never put more information than we need to in the blockchain, right? Because space in the public blockchain is scarce and expensive, right? So we don't do that. All right, so a few other notes here on fees. All right, fees serve as a security mechanism themselves by making it economically infeasible for attackers to flood the network with transactions. So let's think about that for a minute. It's kind of like a spam prevention mechanism, right? One potential attack on the Bitcoin network is to just flood it with fees, right? Just absolutely fill up all of the blocks with these just frivolous or, you know, depending on your point of view, right? Just frivolous transactions for small amounts, right? Just fill up the blocks, flood the network with that data. It's like a DDoS attack, right, on the blockchain. And you could do this now, but what would happen because of fees is it would be incredibly expensive for you to do that. And as you attack the network, the fees would rise and rise and rise, making it more and more and more expensive for you to do that, right? So in this way, it serves fees serve to protect and secure the network, all right? They are an incentive to include or mine a transaction into the next block, right? So there are way to signal, right, sort of space in a block is like, you know, this market space, right? And if you have a transaction that's really, really important to you and has to go through right now, you can include a really high fee, right? To entice a miner to, you know, and it's the software doing it, right? But their software will look at it and say, oh, that transaction must be really important. It's got a really big fee. I like fees, right? I'm programmed to go get as much fees as I can from this mining process. So that one's definitely going into the next block, right? Well, in contrast, if you have a transaction that doesn't matter if it goes through now or next week, you know, whatever you just want to get it on its way and not think about it. And, you know, then you can set really low fee. And, you know, at some point when the block space, you know, the mem pool is way down that transaction room, waiting room is kind of empty than that transaction might get thrown in there and included in the block, right?  All right, as we discussed fees are implied as the difference between the sum of inputs and the sum of outputs and transaction fees are calculated based on the size of the transaction in kilobyte and not the value of the transaction in Bitcoin. This is interesting, right? And this is an interesting characteristic of how Bitcoin operates in Bitcoin does things. I think we're very used to thinking about fees in terms of sending money as a percentage, right? You wire money or if you're using MoneyGram or something like this, generally that fee is some sort of percentage of what you're sending. But for Bitcoin, on the main chain, not like the Lightning Network, that's a bit different, but on the main chain, fees are based entirely off of how complicated that transaction is, right? Which makes perfect sense, right? Because again, this is another sort of attack vector where I could just create really, really complicated transactions that everyone on the network has to validate. So it's going to consume the computing power of everyone on the network. And I could do that by just sending out lots of really, really complicated but low value transactions. And if the fee were based on the units of Bitcoin being sent to you, this number of satoshis. All that fee would be low even though we're consuming a lot of resources on the network, right? So instead, these are based off the size of the transaction. And so if there's a really, really big complicated script that's going to this transaction, which we'll talk about shortly, then, you know, with lots of signatures that have to be validated and all this sort of stuff, then you would expect that you would pay a much higher fee for that transaction, right? So I could send a super complicated transaction that's only sending $50 worth of Bitcoin. And I'm going to pay a much higher fee than if I send a very, very simple pay-to-public key hash, pay-to-public key hash like transaction that sends, you know, a million dollars to the Bitcoin. The fee on that $1 billion transaction is going to lower a very complex $50 transaction. And that serves the purpose to prevent misuse of the computing on the network, right? But it's very interesting. And sometimes that's, you know, counterintuitive to how we're used to thinking about fees on payment networks. So before we go into notes on before we dive into scripting, I will pause here and see if anyone has any questions on fees. So there's still some lingering question that you have about how this works. Now is a great time to type that into the chat. And Mike, let me know if we have any questions there. How are we doing, Mike? All right, we're doing okay right here. I'll give everyone a chance to put their questions down there. I will say, we lost your internet there for saying, did you switch your internet over? Maybe he's gone to get a cup of coffee. Okay, so we'll carry on. Oh, sorry, but I'm sorry, they heard me. You didn't hear me. Sorry about that. Yeah, now everyone should be hearing both of us. Sorry about that. So we're not, we're not seeing any questions yet here in the chat from I can see. So I think we will go on at this point and I'll do the other thing I mentioned on the back end. Okay, cool. All right, so we're going to move on to scripting. So I'm going to try to go through this very slowly and it's probably going to be a lot of repetition of ideas, but again, like so many things with Bitcoin is that it's, it's often very new sort of a concept so it's hard to relate it to something that's, you know, if you haven't studied like old school computer programming then this is going to be sort of new stuff and kind of confusing and hard to read and so we're really going to go through it slowly and we might get kind of repetitive but hopefully that really helps embed, you know, the structure of what's happening here. Okay, so notes on Bitcoin script. All right, it is a fourth slide like reverse Polish notation stack based execution language. All right, and when I first read that thing about Bitcoin that made absolutely no sense to me. And the first time you read it right unless you studied you know, old school programming probably isn't going to make much sense to you either but maybe that stack based right you know computer science students right we'll understand what that's talking about. But basically it's saying hey this is kind of an old school way of doing it we're using like reverse notation so things are kind of written in like the opposite order from how like a human is used to reading it. And it's stack based so we have the stack, you know information and you know instructions pile up on the stack and then you know, get taken off the stack and we'll talk a bit about that. So, you know, this is technically what Bitcoin script is it's something a little bit different we'll walk through it step by step. It's a very simple language that was designed to be limited in scope and executable on a range of hardware right. So the simplicity is a deliberate security feature right. So there's a lot of people that wanted to build really complex things on Bitcoin and found they could not because the Bitcoin script just doesn't allow for that level of complexity. This is you know to go do some Bitcoin crypto history you know this is actually how theory and started is you know Vitalik and some others were trying to build some complicated functionality on Bitcoin and realize that it's just you can't quite make this thing do what we want it to do it's not flexible flexible enough right it's very rigid and limited and so they went off and created a theory right which does have all the bells and whistles and is this really complicated you know has you know sort of more you know much more complex functionality than Bitcoin does right and some people and I really don't think people like to do the Bitcoin versus Ethereum and I that to me they're Apple and oranges right they're two different systems chasing different goals. So for Bitcoin you can think of it as a drawback that it doesn't have a lot of this functionality or you can think of it as a feature right because because it's so simple in what it's doing it's much harder to sort of manipulate or views or have things go wrong in Bitcoin because you know there's no loops it's not turn complete like it's very simple so with you know Ethereum you know how Ethereum processes things you know and the smart contracts that go on there you can see all sorts of crazy bugs and weird hacks that happened on different smart contracts and stuff and that's enabled because it's so much more complex right. So it isn't this isn't necessarily a drawback this is just like different design choices chasing different goals right but Bitcoin no doubt is very simple and that's limited in many ways. Alright, turning in completeness so there are no loops or complex low control capabilities other than conditional slow control so that's all very computer science see we can sum that up and say you know you're not going to do loops in Bitcoin right many Bitcoin scripting is going to happen there's not going to be loops right so if you're a lot of and if you get to the point where you're building you know scripts or you know Bitcoin does have you know what you might call a smart contract like you can build all kinds of programs on top of Bitcoin and using Bitcoin scripts but you have to build it. You know very differently than you would build something you know say in Python right it's not watching base. So it's important to keep in mind the very specific rails that this stuff runs on. Alright, this prevents infinite loop or other form of logic bomb that could be used as a denial of service tack against the Bitcoin network right. So, and if you had right like if you enable loops in Bitcoin scripting Bitcoin transactions, then one potential thing that could happen is that someone could just write an infinite loop into a transaction and sort of all of the computers all the nodes on the network that are trying to validate that transaction could just get stuck in that infinite loop. Now there are things you can do about that you know Ethereum deals with this by you know their their gas fees right you can only expend so much computing power while you know processing a transaction. So there are methods of other methods of dealing with this but what Bitcoin has done because it's got a very simple goal that it's chasing right it's not trying to be the Swiss Army knife of crypto it's trying to be Bitcoin right. So it just, you know, loops aren't allowed. Right. And so we don't have that problem. Alright, stateless. So all of the information needed to execute a script is contained within the script so basically not having to keep a track of all the different states of different things. It's just keep a track of the blockchain. Right. Alright, before we get into locking and unlocking. That's a lot of information there. Mike, do we have any questions at this point. Alright, you can hear me right now. I'll just check it first. I can hear you now. We're all good. We are. I'm not seeing any questions yet down in the chat. Someone says it's basically a programming language with the looping stuff with stuff like looping missing, which isn't really a question more of a statement. But yeah, I mean that's basically correct. It's like a very simple. It's why they sort of call it scripting, you know, it's very, very simple. But yes, when you go to write it. You look at you like you get a very specific and much smaller than you might normally have like set of kind of functions, you know that you can use. And you can't do looks right so you can think of it as just a very, very simplistic programming language. Yeah. That would be a helpful way to think about it probably. Yeah. Alright, awesome. Well, I'm not seeing anything else down there. But again, of course, if anyone has questions anytime, feel free to put them down in the chat and I'll let you know. Awesome. Alright, let's move along to the locking and the unlocking which we have been through many, many times now, but it is just as relevant as it was the first time we talked about it. Alright, a locking script is a spending condition placed on an output. It specifies the conditions that must be met to spend the output in the future. Right. So we know that we talked about UTXOs you have inputs to a transaction and then what comes out of that is the output which are locked with a specific locking script. And there are UTXOs unspent transaction outputs. They exist there. In the future, perhaps we can unlock them and send them on somewhere else right there potential to be spent they have the potential to be unlocked. The locking script is a script that solves or satisfies the conditions placed on an output by a locking script and allows the output to be spent. Cool. So we lock it with a certain criteria and then an unlocking script satisfies that criteria.  We put more stuff on the stack right we process it that the final result comes out to true it's like a unlocked spend your, your Bitcoin can go on its way to its next home. Go get locked somewhere else. Alright, so let's look at this and again, we will come back to this in some depth right so we're going to keep cut sort of coming cycling through this example. So here we have a very standard pay to pub key hash transaction. Right. This is our locking script. This is what it looks like. This is do hash 160. Here's the hash of a public key. This is equal verify and this is checking. Okay, and these are our off codes and we'll look through them in a minute in all the Bitcoin off codes generally start with OP underscore DUP right for off to right. But this image is taking taken from the mastering Bitcoin book and what happens in that book is because off is at the front of all the off codes. It's redundant so it's kind of just removed for simplicity, but we'll go and look in a minute at some of the available off codes in Bitcoin scripting. Okay, so here we have this is the locking script. He says hey duplicates hash. Here is another hash of a pub key. We're going to check that they are equal with a verify that the book, the unit seven covers sort of what the verify is some of the off codes have this verify on their kind of additional step. We'll leave that for the book. Right now we just want to get the flow of what's happening here down and check sake. Okay, so this is what a locking script looks like. This is what the unlocking script looks like. Here's a signature. Here's a pub key that unlocks this at the moment, you know, if you haven't, you know read through this chapter of mastering Bitcoin three times already you might be looking at this going but like how does that unlocks that what's happening there. Right. And so we'll walk through it step by step. Okay, I apologize because I sort of ran out of really nice pictures to use for the course. Normally I like to have lots of nice pictures but I was I was this for this unit I resorted to using some Wikipedia Wikipedia images. I made a note for myself to, you know, have my graphic designer create a nice image to try and explain this concept. So this is a stack of plates. Right. We all probably have this sitting in a cabinet in our kitchen. Right. But I show you this because it's kind of can be helpful to visualize this while you're thinking of what's happening in a Bitcoin script. So we have some data right and we'll walk through what goes on the stack, but you can see we have some data and it's like a place and you put it down. Then you have some more data and you put the plates on top of that and then you have some more and you put that plate on top of there and it can stack up to this sort of pile of dishes right. And we talk about if you there's a really, you know, in the course there's a really excellent video of Andreas walking through sort of a scripting workshop, right, where he talks about push and pop and walks through a pay to script slash transaction. It's really an excellent resource for understanding this stuff. And they talk about push and pop right so you push data on to the stack and you pop data off of the stack right. And this happens in the last in first out right basically means you always have to take from the top of the pile right. So we have this giant stack of plates and I try and pull a plate out from the middle and the whole thing might crash and break right so you're always going to take like the plates on the top right you start on the top work your way down it goes up and down like that throughout the scripting transaction, you know validation process and that script gets processed and run. Okay, so any questions on this this image will again, we'll walk through it we're going to have there's this great website that lets you try out different scripts and sort of visualizes it for you going on the stack and right pushing data on the stack and popping data off the stack. It's really, really helpful for the visualization of it so we'll walk through that. Mike jump in and let me know if there's any questions here. Yeah, well I can first jump in and say, I think I have that exact stack of plates. But I'm not seeing any questions coming up in the chat right now, but of course as always, if you do have questions you can leave them there in the chat and if you're watching later, you can leave them in the comment section below. Okay, awesome. Okay, so let's move along and we are going to go look at this. I think this one. Yes. Okay. So what we are looking at here is the list of. The exact same thing, right. Bitcoin uses the scripting system for transacted the fourth light script is simple stack based process from left to right. And this is, you know, a good resource to you can read through this it's going to, you know, we're covering what's in here is basically what we're covering now but a little bit more technical details that we're not really going to dive into today back to your bikes and how many bites long etc blah blah blah so lots of technical details, you know if you really want to dig into that.  So let's see if I can here we go up Duke, this is one that we're going to look at today. Duplicate the top stack item. So sort of pops off whatever's on the top of the stack duplicates it and pushes and pushes it on two of those right now there's two of them. And that's what it does there. What else can we look at. Oh, splice interesting. This is a decent amount of, you know, options here, you can use for all kinds of different scripting, but let's look at op equal verify. The same as op equal but runs off verify afterwards right up equal returns one if the inputs are exactly equal otherwise zero. Okay, so it's like, are these two things equal. And up verify, where's up verify. What is that. Okay. Marks of transaction as invalid if the top stack value is not true. The top stack value is removed. Okay, so I think this is just with verify at the end it's just like if you fail we're just stopping processing, like we're done. So we could go through and you know dig through all of these. And if you really get into, you know, working on something that requires Bitcoin scripting, then you really want to be aware of this resource. There's a whole list of op codes out there you can come here and you know dig through what each of these does some of them are very simple, like op add. Hey, you add two things together. You subtract one thing from another, etc. And then some of them can get really complicated, right. So here's check say which will be using a lot which you know hey check the signature. But here is check multi sake which we won't dive into today but hey that gets, you know, we'll talk briefly about multi sake but hey that can get kind of complicated, right. So all sorts of different options you can use all sorts of different op codes which you can think of is just like a function you would run right like do a writing something in Python Python would come with like a certain set of functions built into it and you could just use those functions and so you can think of Bitcoin scripting kind of like that these are the sets of functions that you get to work with. Alright, so let us come back over here. And let's walk through. We have a question real quick. Yep. Now's a good time. That's a great time. Let's do it. All right. Question here. So sorry if they missed it, but all the, sorry, all the data the script operates on is included in the script itself. So the question is, is all right, it's all, yeah, you got it. Yeah, so it there's not. So all the data that it's going to operate with is included in that locking script, or is maybe like referencing something in, you know, the previous transaction, right so you can go and look at the previous transaction where that output came from. You can either look there, right, so that might reference out to like the blast transaction that that output came from, but basically like if it needs to, you know, validate the signatures of pub key or something. It's generally correct to think that all the information you need is contained in that locking script. So you need the locking script, and you need the unlocking script, it's possibly might want to reference something in a previous transaction. Yeah. Okay, awesome. Well, let's know that answered your question and I'll let you I'll let you keep going and I'll let you know if there are any other questions. Okay, cool. All right, I tried to make this a decent size and hopefully it's not too small of a font for us to read here you might want to put your, you know, YouTube on full screen for this one. But here, let's walk through a pretty simple script, right, that we're just going to process, right, just for a simple example. Okay, so we have, this is our script, two, three, add five people. Right, so again, this would actually be off add and off equal. And we could go back to that website that lists the off codes and look up exactly which one's doing if you're ever reading a script, and you're not. I'm sure how to process how to understand what's going on there. All right, now, because I've, you know, read through this stuff many, many times, I can look at this and read this and go okay right that simple it's taking two and three and checking adding it and checking that it equals five. Right, but it's kind of written backwards and it's confusing so let's walk through it slowly and look at what's happening on the stack. We have our execution pointer right take this number two. Boom, we push that onto the stack. Right. Okay, we then move along the execution pointer goes to three. Boom, and we push that on to the stack. If we go and look at off add, I believe it pops two parameters right off the stack. So let's just go and look at that. This one come back that minute. I just do up add right. Okay, input. Right, so it pops two parameters off the stack and pushes one on right that you expect think I'm reading that correctly. Okay, so. We get down here to the off add right so we're here we have two parameters or two bits of information on the stack then we get to this off add up add pops the type top two items out of the stack and adds them together. And then operator add pushes the result five to the top of the stack. So it just takes those two numbers right pops them off the stack adds them together takes that result which it gets is five and pushes that back onto the stack. So now this is what our stack looks like. It's just five. Our execution pointer moves along to the number five. That's just some data so it gets pushed on to the stack. So now we have five and five. Then we get to equal, right. What does equal do right operator equal pops the top two items out of the stack compares the value five and five. And if they are equal, equal pushes true true equals one back to the top of the stack. Right. Boom. This is to start off with a simple example. You can see we ran through this whole script and when we get all the way to the bottom of it the only value remaining in the staff is true. That means that this is a valid script right we successfully executed the script. If something had gone wrong, we might have just stopped execution during the script if there was like an equal verify or something inside this script somewhere might have just stopped if not, we're done here this isn't any good. Oh, we might have gotten all the way to the bottom and have false at the bottom in which case not that did not execute successfully. So if we just stop execution or if we get to false all the way down at the bottom. Then we failed at unlocking our locking script. Right. But this is a simple example right we don't have locking and unlocking just have this very simple math. So, let's see if we have any questions before we move on to actually trying out with some simple math will try this simple math before we move sort of a more realistic unlocking script. We got we got one down here they say this may be a bit off topic we might have discussed this track in a previous video, which of course you can check out a little bit will say you can tell us. It's the question is about about why a signature is necessary. The public key is enough to prove the transaction is sent by a certain person. And then the follow up question is, is there any way for someone for someone else to send a transaction with their public key. Okay, so I put public key I guess, right. So a public key is not enough to validate that the transaction came from a certain person. So let's walk back to this image here, right in this locking script sort of locks this transaction to this particular pub key right here it's the hash of the pub key and the idea being as this is locked to this sort of address which is created from a pub key so that only the person or the entity that has that corresponding private key can create an unlocking script. So when I lock this bit of Bitcoin that's in this transaction so I've got one whole Bitcoin in this transaction right, and I lock it to the hash of this pub key, right which is formatted specific address. And this is Mike's pub key, and we would presume and hope that then only Mike has access to the corresponding private key. So that means it wants this Bitcoin that one Bitcoin is locked to this address with this locking script right that that's then Mike's Bitcoin, and if he wants to send it in the future. Well he has to present this unlocking script, which includes his pub key but also his signature. And I think it was a unit three I can't remember which one where we walked through signatures and verifying signatures so we know that with the current state of cryptography right that only Mike, who is the only person that has access to that private key can create this signature can create a valid signature here right on this data. And so that way we can lock funds to a pub key, but only a person with the corresponding private key is capable of creating a valid unlocking script. So that's how that works. And if there's any, you know if the picture in your head of signatures and valid signatures. It's a little fuzzy then I'd recommend going back to the unit where we covered that one. I hope that answers the question Mike you have anymore. I'm not seeing any more right now but I will let you know. If they show up. Okay. All right, so now we're going to try it we're going to go to this website and we'll try some very simple math. So we'll walk through the exact example that we just went through just so we can visualize it which is fun and then we'll do something slightly more complex. So I'm going to exit screen. Oops, I hit the wrong button. Sorry Mike, let's go back to. Okay, sorry, I hit the wrong button. Tell me when we're ready to proceed Mike. Okay, excellent. All right, just keeping Mike on his toes today. That's what we're doing. Hope you had your coffee. All right, so we're going to take this very simple script here. And we are going to drop it into this script simulator. Again, it's going to go to three. Here it shows up as op add and use op equal right again in the examples from mastering Bitcoin the op is dropped because it's redundant. That's fair. By the way is there's a valid way to note it but when you're actually writing the scripts right I think you need to include op. Okay, so we have our animation speed we're going to turn it super low so we can watch as this happens and let's run it. Okay, we add two to the stack. We add three to the stack we take both of those parameters off because we're adding them and then we return the result, which is five. Then we add five to the stack then we take those two off and check if they were equal and return to a false back to the stack and return one which is true. Yay, we successfully ran those scripts. And you'll note again all the values start with 0x right that's like hex notation right. Okay, cool. So now we did that. Now we're going to look at this and let's I'm going to copy this value, but you all want to take a second. So look at this to seven op ad three op sub one op ad seven op equal any idea what that's doing right you kind of got to read it a little bit backwards, but let's take a second to just visualize what might be happening there. Okay, two and seven ad, but then three subtract one ad seven is equal right kind of a difficult thing for a human to read right made for computers not for humans. But let's take that and again let's turn our execution speed. I won't stop sharing and more. Okay. All right. So let's take this again execution speed pretty low here. And let's run through it and see what happens. Okay, we add two to the stack. We add seven to the stack up we're doing op ads and we take off those top two items and we add a result back to the stack. What do we get what's the result nine. Okay. We also add three to the stack but then we're doing op sub so we subtract think three from nine return the results to the stack, which is six. Then we add a one to the stack and we pop off two items for op ad and add this seven and the one or the six and the one together. And then we get the result seven, then we add seven to the stack, then we pop those two off for op equal and see if they are equal to each other. And tada, they are equal to each other. Okay, so that was a very, very confusing way to do a very simple bit of arithmetic. I hope that kind of walking through this, you know, helps you visualize, you know, you just got to get used to it right we're going to be working with this stuff right you just got to get used to reading it and how this stacking goes. All right. We had a question real quick, Anna. Let's do it. Our negative numbers supported. Um, good question. I want to go with no, but I would have to double check that right I haven't ran across that scenario. So, I would have to go consult this year somewhere to double check on that one for you. Nice question. Okay. Cool. Any others Mike. Nothing right now but I'll, I'll let you know. Cool. All right, we only got about 10 more minutes left so let's just get through this last example right finally we've led up to this this is again is our pay to pub key hash walking and unlocking script and want to see how they get run sort of together. All right. Let's walk through it. All right, so first you can see like let's look back here we have signature pub key up to up hash 160 pub key hash up equal verify object sync. Right. That's what we got. And if we look here, we just line them up. So we start on this side, first with the unlocking script, then walk through the locking script. All right, so it's kind of. This is confusing, right. So let's start with this first thing the execution pointer starts with signature, put signature on the stack. Right. Then the execution pointer moves on to the pub key. So moving to the right with each step, the value pub key is pushed onto the top of the stack on top of signature. The off dupe operator duplicates the top item in the stack and the resulting value is pushed to the top of the stack. So we have pub key, pub key, because it took right it pops off this first one, which was this pub key item duplicates it pushes that on now we have signature pub key pub key. Right. Now we move along further to the execution pointer moves to this off hash 160. The hash 160 operator has is the type top item in the stack with ripe md 160 shot 256 pub key right so the pub key. First gets run through shot 256 then right then d 160 the resulting value pub key hash is pushed back to the top of the stack right.  Stay with me here. We're getting to the end. All right. Now we move to this where it was the pub key hash, right that that was in the locking script right there we're now right in the middle of the locking script. And it says the value pub key hash from the script is pushed on the top value of on top of the value of key hash calculated previously from the hash 160 of the pub key right. So once we went to this operation we had a pub key hash there now we're going to take this pub key hash value put it on to the top of the stack. Now we get to the off equal verify all right this operator compares the pub key hash encumber encumbering the transaction with the pub key hash calculated from the user's pub key. If they match both are removed and execution continues right. So if they match hey we're good to go if they don't match I think in this particular script like we would just stop good. No, no point in continuing what this is no good. All right. Now, we've checked that both of those match now all we have is a public key and a signature. And so we get to this next. This is a really important part all of it's very, very important but here's you know the finale is we do off check sig of the check sig operator checks that the signature right this very important signature here which is cryptographically created with the private key corresponding to this public key checks that signature matches the pub key and pushes the true on top of the stack if true. Okay, now you might have spotted something here right through really following along keenly if you already have some familiarity with this. In order to check a signature we need the data that is being signed right the transaction we need a pub key, and we need a signature. So here, the data that is being signed is this whole transaction right and we're not explicitly stating that that sort of supply so that's something to keep in mind there. And so if we then go about take the data from the transaction, check that that is signature take the data from the transaction and the pub key and then check that data against the signature to check that it's all valid and it comes back as valid. Then we have successfully unlocked this UTXO unlocked that one Bitcoin locked here, and we can send it on to wherever Mike was trying to send his transaction right. And if we look at this, we can see that what we just all the way after we do all this other stuff we get down to the original values checked here and because we had already duplicated this right and and then used it in other parts of the transaction that this pub key provided here is the same pub key used hashed and used here, etc. So once we get through this and you can come back here and walk through it slowly and think through various sort of stuff to just satisfy yourself that this is indeed a very good way to check that this pub key and signature matches appropriately with that locking script. So that's a lot. Let's go through and check it out right here. I have written this in a number of different ways right because it it's difficult for a human to read but here we're looking at the situation where Bob right is trying to spend this transaction. So sorry Mike here we've replaced you with Bob. So, this is we have what I know. Here we have Bob's unlocking script, which is just a signature in this pub key, then here's the locking script and I tried to put some of this in bold to kind of make it a little space it out of it to make make it a little bit easier to read these op codes are sort of in bold. We have off do off hash on 60 years hatch like this is some data off equal verified off check say we can also read it like this sometimes you'll see it written out a bit like this opposite. I'm sorry, Bob say Bob pub key off the bot hash blah blah blah right so just sort of give me the idea that sometimes you'll see it notated like that. Okay, so let's go and try it. We only got five minutes left but we can get through this alright couple things to note here pay playing with scripts can get pretty complex and need to get comfortable with heck and be very careful to get your formatting correct etc. So let's simplify things a little bit here by removing the complexity of checking the signature because it can be you want to try and use this scripting simulator. If you can give yourself quite a headache trying to get formatting just right while you do that. So, for simplicity, for this example, we're going to remove the headache of formatting the signature exactly correctly. So we'll remove Bob say and off check say and we'll give you on the values to run so I sort of simplified it so we don't have to mess with that headache today. Right, so we have Bob pub key off do off hash hash off equal verify so we're sort of skipping checking the signature which you would never do in a real Bitcoin transaction right, but obviously here just to get familiar with how this process works. That's okay, we're going to do that. Alright, how do I hold on just a second. Hold on just that I've hit a slight snag. Mike, can I stop share for just like one minute while I go find some data. No problem. You're good. Okay, give me just a moment. I'm going to drop the fancy data I had for this. Here we go. And I'm back copy this. Okay, and where are we with the zoom, I will resume my share. Okay, cool. Let's continue. Okay, cool. All right, so I'm going to paste this information in right again, formatted slightly differently, instead of going a long ways we have lots of data so I'm stacking it. It's off the bottom on just to simplify for us humans right. So, Bob, pub key off do do off hash pub key equal verify. Let's see how we go with this. So we take that pub key, then we. Oh, hold on. I fell behind on this I'm going to run it again so I can help you walk through it. What are we doing. Okay, so we're going to run it again. Okay, pub key. We duplicate that. So we add another one to it. All right, then we do off hash. And we hash it. There we go. Then we take that other hash that we had, and we pop that off and check that it is verified. We get one back on the script and as returned and so this script executed successfully. Right. All right, so we're a bit low on time. Yeah, two minutes. Um, so you all can come back to this website here to it's in the exercise for the course so you can play around with this. Again, be careful with the signatures for many correctly can be a headache but it's really fun to play around with different off codes term this animation speed right down low. Have some fun with it or you can just run through things really fast one get yourself a headache and try and follow along with that. There we go. Okay, so I'm going to run through a couple more things on here really quickly before we do questions right couple things I just want to note. So what we covered here is, you know, scripting but actually a fairly simplistic script right there's pay to pay to pub key hash right, but pay to script hash is something that gets covered in unit seven of the course and is really important. It is a way to do much more complicated scripts where you're locking funds to the hash of a much bigger script. Right, then you might want to just add directly to the locking script so then you can do all kinds of multi sig stuff which is really interesting which is M of N. You can say hey, I want to lock these funds to the script and what validates what you know unlocks the script is to have a signature from N of M different keys right so I can say that's two signatures from a potential of three or three signatures from a potential of five different keys etc. This is really important because multi sig is used in so many different applications in Bitcoin it's really cool stuff we could do an entire session just on multi sig, but something to be aware of there quite cool below, you know, book dives into that. Alright looks like an address that starts with three and might look like this so that's a pay to script hash address. Yeah, they get so many more options with that some drawbacks wallet needs to remember if that was used to create the hash. We'll dive into that but there's you know benefits and drawbacks as there are with everything in life right. Here's what multi sig kind of looks like this way I picture it in my head is your sort of locking funds and sometimes people use it a bit like an escrow service right. You know lock funds here and you know, two of these signatures two of three different signatures have to agree to move the finds that right you can have like two different parties and some sort of arbitrator media maybe mediator or something of that sort you really cool interesting thing. Okay, two things that are not directly covered in the course, because they're much newer things to Bitcoin I just want you to know exists is segwits. And segwits is segregated witness is basically just a different way to store, you know, transaction data and signatures for it started kind of separately in the, in the blockchain data right signatures definitely still they are right but it's just stored separately, they separately. There's so much history behind this and why this happened. Again, the entire session on that it fixed this problem called transaction malleability, and which allowed for the creation of the lightning network so it's a very important to sort of the scaling wars when there's all kinds of disagreements about how to scale this technology. So really, really impactful bit of change to Bitcoin very interesting to dig into that the moment, be aware that that's a thing. And then just last year we had the activation of some functionality called tap root which provides for the option to do scripting a bit differently and it also allows to make it more complex, right, which is more options and there's also more complexity for wallets, etc. So that was quite a lot. Mike, do we have any questions. Okay, well I'm taking a look at the chat right now. I'm not currently seeing any questions I'll do. And remind everyone that we'll be back here next week to go over unit eight and of course if you haven't seen any of the other videos of the series you should go back and watch those and they are of course a supplement to Bitcoin for developers course which you should take also which because this is a supplement to that I of course want to thank everyone for joining us and of course join everyone in the chat and thank you, Hannah for taking us through get another unit here. But I'm not seeing anything coming through the chat right now so if any question comes up, you think of a question later you can put it down in the comments or save it to next week may ask you to start next week's unit. Oh, here we go. We got a question coming in right here. There we go. What, what is the maximum script size. Great question. I can't remember it off the top of my head so absolutely are limits, there's limits to the amount of outputs you can have on a transaction 483, there is some limits to that I'm not going to pull it off the top of my head right now with santo so it has to maybe I can drop it in the comments I'll go go find that data for you and drop it in the comments on the video. All right, well, there we go find it for you. But thank you very much. Thanks for the questions. Thanks for the thank yous in the chat. And again, thank you, Hannah, but so we'll see everyone. Same time unless you know other countries change their times also who knows some will see you a time next week everyone next week I will have gotten used to the time zone shift so we should be good and next week is the last one right last unit unit eight. Sounds great. Thank you everyone. Thanks for joining us.