Introduction to the Ethereum Blockchain

Transcript

English (Auto-generated)

Okay. Um Welcome to uh introduction to the ethereum Blockchain. So in this we're gonna kind of go through the basics of what Blockchain is kind of our the kind of an introduction to the fundamentals, and then we'll dive a little bit into um the specifics of, you know, an ethereum Blockchain. Okay. So on the whole block chains, you know, basically what they are are distributed databases. So databases that are, you know, ultimately shared across, you know, multiple computers. And ultimately these computers are all synchronized to maintain a particular state. So you've got basically what you can think of is is a is a is a giant database, you know, and um it stores transactions and it's replicated over thousands, thousands of computers. The more computers that it's distributed over the more, you know, decentralized is um each of these blocks um it's it's it's actually made up of of a transaction, you'll see, you'll understand later on, kind of will go through um why it's called, why it's called a block and really kind of what it's kind of made up of. But for the purpose, you know, up to this point, I think it's just important just to know that each block is basically made of transactions and that's basically the data and these blocks are then connected to to each other. So, you know, as they're kind of chained to each other subsequently. So as they're connected, you know, they they have a connection to the previous block and you'll understand, we'll kind of go into why it's done that way. But basically the chain is in such a way that, you know, they're all kind of connected a certain way and that if there it kind of makes a tamper proof. So if you were to change data at any existing, you know, point in the Blockchain, it would break the entire chain, making the entire chain invalid. And that's why block chains have that, you know, really special property of once the data is there, it's it's immutable write it once it's on the Blockchain, it can never be changed. It's it's kind of there forever. So, but we'll kind of dive into that a little bit later here. Um what's important to understand when, when we're talking about Blockchain is that it's really based on this um the technology of of, of cryptography that that's really what drives this entire, you know, the base of this technology and um you know, a cryptographic hashes is basically, you know, an input going into a function and then it kind of outputs a, you know a hash hash value. Right. And what that kind of looks like is um you know, is this here um so this is an example of a shot to 56 hash shaw stands for, you know, secure hash algorithm. And basically you're we're gonna input some data in there, it's gonna give us back this kind of, this, this this string of numbers and letters and that's called the hash and the hash is unique to all the different types of inputs that you could put into it, so there's not going to be, you know uh you know, all hashes are going to be unique for all different types of input, so no input is going to know two different types of inputs are going to have the exact same hash. So here, here's an example, we could type in something like hello and we would get a hash like this, but if we were to change that, so let's say just add an exclamation to the end of it, the hatch would completely change. So you know, these hashes are basically identify years of data and what they're you know used for in in Blockchain is verification is to verify, you know, whether data has been, you know um data has been tampered or not and uh and and in in in this case we're just inputting one set of data into this hash function but you can have multiple inputs into it, which is what a Blockchain does kind of hash is a lot of, you know, data inside that block to a to a particular hash but for the purpose of this right now, I think, I think what's important to understand is that no hashes are created based on input data and it's unique to every type of input data. So if someone wants to to say, I'm gonna send you a hash of this data, you know, of this data set of hello exclamation mark, um and they said well and to say this is the hash of that, of that data, I could verify that on my end by putting that same data set and ensuring that it wasn't tampered tampered with, but if at any point, you know, I was this hash was to change to say, you know something else, like they added another exclamation point should be totally different and I would know that it wasn't, you know the original hello one exclamation point. Right, so um that's kind of what hashes are used for and another important aspect of of hash functions is that you you can't you can't generate the original data from the hash, so really it's it's it's it doesn't, you can kind of give away and say, you know, it did prove that something has not been tampered with without actually giving away the underlying data, which is very kind of an important aspect of this. Um So now let's go into blocks and kind of Blockchain, how are they chained? How do how do they all connected? Well, like I mentioned before, blocks are actually made up in a Blockchain. Blocks are actually made up of transactions, transactions are usually, you know, this person sending something to another person and just kind of a list, like like a ledger. Now, what's happened with now, what makes Blockchain is kind of unique is that they're actually chained together using hash previous hashes, so the hash, so so when uh when a block is made up of all these transactions, all of that is hashed into the block hash. Now the next block which will have, you know, additional transactions will actually have the hash of the previous block inside of it and that will be used to generate the hash for that particular block. Okay, now what that does is underneath it all is change them all together and uh and if you were to change the data in and in any of these blocks and keep in mind like the blocks that we're talking on block chains or you know, there's millions and millions of blocks um without having to actually go in and find out something has been tampered with. If the hash of the final block is was changed or was different or was invalid, you know, immediately that you know, the data was tampered with or the data was changed, so it's almost impossible to change, you know, existing data on a Blockchain and this is what makes it, this has with that ability of a mutability. Right? The the the ability that you cannot tamper this data, it's it's tamper proof and it's all based on this hashing. Right. Um So here's an example of of a block. So let's just this is not, again, this is not any specific to any, you know, current Blockchain out there, but this is an example of how hashing is used in a block, so we can enter some data in to the block. No, this is a no, I won't go through what these actually mean, like the block nonsense data just yet. We'll kind of get to that later on. But just for the, you know, just for this exercise, it's important just to understand that the hash that you're getting out, that this the hash of this block is based on all this data that's being inputted in. So even if we were to change this nonsense, we change this data. Hash has changed. Okay, so it's unique to all of this and we're gonna go ahead and do something, we'll we'll do it later, we'll mine it stuff and I'll show you what that is. It's it's not important to kind of know what, you know, how kind of mining works right now, but but once a block is mined, it's basically a valid block. Um that's kind of, you know how it's approved, but we will talk about that a little bit later. But this this when we're talking about Blockchain, we're talking about multiple blocks with with data inside of them that are kind of connected and this is kind of what it looks like. So If you look at block two and block three. Block, the first block doesn't have a previous hash in it. It has a hash hash function, but if you look at the second block the previous hash for this block is actually referencing, this hash Okay, so if so this hash is dependent on the previous block's hash, So if this hash is to change, that would make this block, that would, that would change everything, that would, that would mean that everything would need to change. So right now everything is green and it's all connected, so you can see the hash of, this is in here, this hash is in block three and then block threes hashes in block four Now, five was to go in here and just change something, so add some data and block three, it will totally invalidate, you know, all the blocks up to there. So Basically I just added one letter and it changed this hash and once this hash was changed this previous block hash is no longer valid anymore, it has to be kind of remind. So mining is basically kind of proving it again. So once the data has changed, you'd have to go in and re validate all of the blocks that are in the entire Blockchain. So block chains can be, you know hundreds of thousands or millions of blocks. So um we'll see that when we kind of get to the mining, when we start to cover mining that, it's actually possibly need a ton of computing computing power, which would be actually impossible to do, is to is to tamper with it and and and then remind everything, you know, all the previous blocks again and and in a significant amount of time to to to to to re validate. But basically if anything was you know, was changed in the previous block it would totally deemed that entire entire chain invalid. And so once we once we made a change here we added some data. It basically invalidated every single block after that. So you can ultimately, you know, the the advantage here is that, let's say we go to, you know, like I mentioned at the beginning of Blockchain is actually uh the database that's distributed, you know, across many different, you know, computers that are all synchronized. We've got peer, a peer, B and P. R C. Let's say, you know, the the Blockchain here was modified and and and somebody went and tampered. Block The Data in Block four. Well that would make all the blocks here and afterwards invalid. So you know you the the the the advantage of a Blockchain here is that you don't actually have to go through all of the blocks to find out that it's not it's been tampered with. All you have to do is just look at the last block and if the hash is not matching, you immediately know right away, something's wrong. Something's been tampered and this isn't right. So you know that's that's that's the key here is that it's it's very you can find out if data has been tampered or has been you know modified instantly. You know very quickly you don't have to kind of go searching through data what you would have to do and you know and and and say in in a traditional database right, you have to kind of go back and look at okay, where was this change? Where was the change made? You know, in Blockchain, all you have to do is just look and and and match up these hashes since they're all chained together using the previous hashes um you just have to look at the last at the last hash and if at any point a change was made that this would become, you know, invalid. So that's how that that you know that the tamper proof the immune to bility is is maintaining Blockchain which is a very, very important fundamental concept without this there really kind of just ultimately just databases. Um no different than any other database. So yeah, we kind of talked a little bit about decentralized change chains um that you know, you've got multiple peers and then obviously can validate blocks by just looking at the final hash, you don't need to look at each block right already kind of went through that. Okay, now he hears when we look at Blockchain, we didn't really kind of talk about this but but when we start getting into Blockchain like Bitcoin where people are sending money or the data actually is is transactional. Right? So this person is sending this person this many bitcoins um The question can come up well you know sure the block change. You've got the data you can check if it's been tampered. But how does once you know send you know assets or crypto from from from one account to another. And how do you prevent people from spending you know someone else's you know you know crypto how does that all that work? How does this that security kind of work? Like we've talked about the security of the chain and the data of the chain but we haven't really talked about well what about transactions when they're created. Right? So before they go into the block when transactions are created how does that security come from? And that's that's that's where this public private key which is also another cryptographic you know a concept and cryptography uh it comes in and then this concept of message signing. So um basically this public this private public key that this is the this is kind of the key here as as to how that how that all works. Every account will have a public key which is what you know anyone can send funds to. Now the there is something called a private key which actually generates a public key. Okay um and that private key is something that a you know whoever is an individual holder of that of that private key. It they should keep it kind of secret to them. Kind of like the pin to your bank account number right? You wouldn't tell anybody that. But you could give people your bank account number right? If they want to send you money, it's kind of the same idea. You can't generate your private key based on the public key. Public key is just kind of an address that you could send. You know um you know you could send funds to. Um So you know your private key is kind of your key and and the way you the the way you authenticate that it's you is you use your private key to sign the transaction. So um you use your private key and then you whatever the message is, it actually outputs kind of a message signature and and based on that message signature, someone can take that message that you know that you sent them whatever it is. Use your public key and verify that message signature that you that that individual was the actual person that actually sent that. So that's really powerful kind of technology as well to know that. Again that's going into more, you know we talked about the Blockchain and now we're talking about transactions now we're talking about the stuff that goes into you know the blocks, how do you you know kind of verify the the original person and and really it's this private key public key, private key message, you know, message signature kind of thing here. So I'll kind of show something a little more visual to maybe help with this. Um So if we look at something like public private key pair. So this is kind of an example of of what a public and private key would look like. So here's a private key and this private key outputs this publicly. Now. It's not important right now to understand how or why that that different block chains will have different ways that they generate this. But for the purpose of this, what's important to know is that this is the, this is the private key for this public key. So again, like your bank account, you could think of it, this is your account number and this is the pastor to your bank account. You'd never give anybody this, you'd never tell anyone that, but you would tell people, hey, you know, if you're gonna send me some money, send it to this to this public key. Now, what another really cool feature of public private keys is that there's no actual centralized authority that hands it out. So like your bank for example, they would be the one sending you, you know, your bank account numbers and stuff. These are actual, you know, kind of like hash functions, there's functions that are actually you put a private key into this function and it would generate a public key. So they're kind of, you know, it's, it's, you don't really need a central authority to to, to give you your to give you a public key basically. You could you could generate all of this um you know based on whatever, so based on whatever private key that you have, you put that in and it will generate a public key that you could use on the Blockchain that people can, you know, send funds to. So that's how the public key or private key, public key thing works. So now let's let's talk about messages and signatures now. Okay, so now here is a message we'll just type in Hello. And what we'll do is we will sign this message with our private key. Okay? And now this is our message signature. Okay? Now when we want to verify this, we want to verify this message. What we can do is we can send the message and the public key and all someone needs to do is send us this message signature and we can verify that that message of Hello was sent by this person. So we can take this message. We take this public key and we can verify it that oh yeah this is where it came from and it says, okay this is this is this is verified. So that's kind of how it's how block chains find out or can verify that this person, this person in fact was the person that sent this transaction, it wasn't you know anybody else um you know this this will prevent things like you know, men in the middle attacks, right? So from somebody, you know pretending to be somebody else right now. Again this is all contingent on the fact that they don't know your private key. If someone finds out what the private key is, the security of this entire thing breaks down and it's no longer valid. So it is all you know, contingent on the fact that nobody knows your private key other than the person who holds that account. Again, once it's once this is out, you know the kind of the the whole the whole system kind of breaks down. Um So this is kind of now I know I talked about you know, well you can ask how does this all kind of come together? How does this how does this work with Blockchain? You know this message, you know sending like hello, well you wouldn't send something like hello or data like that or Blockchain, it's going to be transactional data. Right? So um this is this is an example of of say a message right there sending $20 from this public key two or this public key which is an address to this address. Now the private key for this is going to be here. And we're gonna, what we're gonna do is we're gonna sign this, we're gonna sign this message, we're going to get that message signature. Now when now when somebody wants to verify it and say on the other hand, okay I want to know that this wasn't you know This isn't somebody else pretending to be you know this address this is actually was sent from this person and this person actually wants to send $20 you know to this address. We can verify that using the message signature. So all they have to do is is send us the signature and we have the message and we can verify that it was them. And again that was based on you know when we're verifying it, they're verifying it using the public key. Right? So that is that unique property of of of of public private keys and messages that you can actually verify um reverse kind of verify a a transaction. So again right We take that message so somebody sending $20 from one account to another and that public heat and then we could verify that message signature. All we need is that signature. That's it. Again that hash right that that's that's kind of where this all kind of ties in together. So those are you know again we're talking really about the basic fundamental concepts in Blockchain. There's a lot of other concepts as well but these are two you know I think really main important aspects to all block chains in general That are important to understand kind of how they you know operate you know under the you know the how the security where the you know the technological breakthrough is here. So you know I think the thing to take away from from this year is um number one blocks are chained together and that you know inherently secures the data. So you know you could, you know, you can prevent it from being tampered and the second is using public private keys and message signing, you can verify that the but you know that the person sending that message was in fact that person by just using things like you know the message that they sent you and their and their and their and their public key, you know right now, you know, and it's for example in your when you when you send someone you know money or for example they don't really know that it's it's you sending it could be anybody. Right? So there's really no way to to verify it. Right? So in Blockchain, you know that verification exists. So let's let's kind of move on to what you know, we're going to focus on here, which is the ethereum Blockchain. So a lot of the concepts that we just talked about, you know, sending transactional data, This this account sends that account $20 or you know, Bitcoin or whatever is really kind of more applicable to to the original Blockchain which was you know, You know, which which came out in 2009, which was the which was Bitcoin which is kind of a peer to peer uh you know, transactional, you know, Blockchain that that could that could securely send transactional assets, you know crypto from from one account to another without any intermediary ethereum is something that came a little bit later Around 2015. Right? That's when a theory and ethereum kind of said well um you know the whole premise is behind this was well I don't want to do just transactional data, I don't want to just send amount, I I want to make this thing programmable. And that was kind of like like how how how could I make a Blockchain program? And that's where ethereum came in. Right, so ethereum rather than being a, you know like Bitcoin which is kind of a database, a ledger of transactions, you know distributed across machines. The ethereum Blockchain is actually a distributed state machine. So it's kind of like a computer that's that lives on on that's distributed across many, many, many different machines. Um Now these machines are called ethereum notes. So really what ethereum did was it took the concept of Blockchain and said, okay let's make a, you know a world computer, you know that you know a computational machine that's synchronized across all these different, you know, all these different notes. Now you might have heard of something called smart contracts now and and and that is really kind of applicable and was kind of the the first the first Blockchain to have this was the ethereum Blockchain now, smart contracts really all they are is just programs, you know, computer programs, computer software and um they're they're kind of they're executed on this thing called the ethereum virtual machine. Now the ethereum virtual in the ethereum Blockchain, all transactions are actually handled by the ethereum Virtual machine. And it has, you know, the E. V. M. Has additional functionalities. Like it can actually do like logic, like if and not, and it can handle it. All transactions basically are computed on this ethereum virtual machine. Um So that gives this, that gives ethereum, you know, uh you know, much more rich functionality as compared to Blockchain, because ultimately, now what you can do is through this, you know, this distributed, you know, this distributed computer, you can now develop applications right? Uh on a distributed computer, you know, without any intermediary, right? Which is extremely powerful. Um Smart contracts. Again, they're they're they're written in a in a programmable language, which is called solidity. Um and uh it's basically it's compiled by the E. V. M. Into things like bike code and then and then ran um now the the the E V. M is an interesting thing. It it's it's it charges for, you know, it costs money to run on uh to run code and run transactions on it. So it's it's not free. So it's basically like a world computer and you know, and and it charges you and we'll get into a little bit of that later, but but but if you want to see, so we can kind of take a look at something like, so if you look at a Block Explorer like either skin, it will kind of show you where, you know, kind of what, you know, the blocks that exist here and and all the blocks in the latest transactions. But but but ultimately yeah, accounts also exist as well too. Um Now in ethereum since it's kind of like a World computer, um it's got the functionality of of Bitcoin where you can actually send crypto and and send into transactions like from one person or one account to another. But it also has that smart contract code as well do. So when we're talking about accounts on ethereum, it's not just addresses like Bitcoin, there's there's externally owned accounts. So something like this. So this is so ether scans against, it's just a Block Explorer that allows you to explore the ethereum Blockchain. So this is an example of an address or an externally owned account um that has a balance that you know that we can look at and you can look at all the different transactions that were done on this address um you know, where it came from and where it went to and then what the value was and then which block it was included in. But smart contracts. So these programs that are written on the ethereum Blockchain, they're also, you know, they also existed as an entity, they've also got kind of an address as well too, and no one really controls them. They kind of exist on the Blockchain as an independent entity as a program, you know, that you can interact with um that you can, you know, view. So here's an example of of a contract that exists. This is a, you know, a uni swap contract, so it gives you the contract address and this is the contract. Uh and and and the program that's written again, so you can see, like solidity, which is the language that this has written is readable, Like it's it's it uses all like there's functions, you can import libraries, um you know, there's logic. Uh So you can do quite a bit with this and this is where that whole concept of, you know, decentralized applications, you know, this is kind of where that where that comes from. Ultimately what these are, are just smart contracts, you know, that live on the Blockchain. Right? That that that's where they exist. So this is where that whole concept of decentralized applications kind of comes from, because no single entity actually controls these contracts, right? They just exist on the Blockchain. And anyone, you know, can interact with them, anybody with ethereum account address can interact with them, can can run, you know, a function on them, or there's no person or individual that really kind of, you know, controls them. Um So so that's basically the account now, like I mentioned transactions on ethereum are you can do a little bit more than what you could do on Bitcoin. Um so you've got the regular transaction so you know going from one account to another. So this is an example of that, so here's an example of a transaction where somebody sent I guess you know has sent some keith right from one account to another, right similar to what you could do on Bitcoin, but here's where it kind of gets a little more exciting with the theory is here's a transaction that shows a contract deployment so this is so a contract does need to be deployed to the to the to the ethereum um Blockchain and that's a transaction in itself as well too. So this is an example of, so this is the uh this is where it came from um which is a deploy a address and then this is the contract. Now this is kind of like you know you could say is kind of like uploading a, you know a program onto the, onto the ethereum Blockchain. And so now this this contract exists, it's got its own address and uh and yeah and you know other addresses can kind of interact with it depending on what they want to do with it um here's an example of an interaction with a deployed with, with an already existing deployed smart contract so this shows that you know this particular address interacted with this contract and I guess they did. Uh huh They did this thing meant um looks like this was probably yeah so it's yeah it's it's it's um this is an example of of of an interaction and again just like you know, just like we talked about before right, It's all part of a block and it it exists in the block but but a lot more, you know, you could see complex um you know, functionality with the theory of a lot more capability program ability with theory um than what something like Bitcoin would have. Okay. Yeah. So we we talked a little bit about the theory of nodes uh you know what these are so the ethereum Blockchain essentially is made up of these things called ethereum notes, which all you know are, you know, computers and machines that are running instances of the ethereum virtual machine which is the which is that computational, you know, which which actually you know computes, you know, does computational power. So that can do logic. Um Now this CVM verifies blocks and transactions and and these nodes, ethereum nodes, they they'll run different types of clients software. Now the client software will all verified transactions and and the way it's like you can say, well, you know, if if they're all different kind of client software, you know, it does that mean that there's different ways that, you know that the E V. M is. Well no it's a it's a client's software has to, you know, meet certain criteria and and kind of standardize how a, you know, what an E V M should do. But so the question, well, you could say, well, what's the point of running like different types of client software? Why not just make one software? No one client software that people can run on their machine and that's it. Right, Like uh you know, and then it's all standardized and that's all good. But the issue would come is that if there was a bug ever found in a client software like that, the entire Blockchain would be compromised, right? Which is not good. I mean, the whole idea of block chains is for them to be reliable and up all the time and you know, and no middleman, you know, no, no intermediary requires. So always always running, you know, totally decentralized. So the the idea of having different types of clients, software is actually better for the Blockchain. Um so here's an example of like all the different nodes that are kind of running right now, all running different types of client software and you know, it's um so this is saying like, you know, total of 55 nodes. So yeah, at different times, there's different nodes kind of running and uh and depending on, you know, where you are And then he talks about all the different type of clients. So as you can see like there's all these different types of clients like open ethereum and death and all these different types of client software and uh right now get is get is like 90% so this is something that ethereum is you know, looking to address right now, it is kind of dominated by one piece of client software but but that is something that you know that ethereum is looking to to change and and move away from um they are moving towards a different like you know, there's something called the merge that is coming up which I was looking to change to a totally different kind of consensus mechanism and then have different types of client software as well too. So, so yeah, but yeah, what's important here to to to to to keep in mind is that yeah, the notes are really what make up the the ethereum Blockchain because they're the ones who are you know, running instances of the of the ethereum virtual machine and they're the ones that are, you know um you know, verifying now some of them will have the entire Blockchain on them but some of them will not, I mean it's not really important now to kind of get into that but that's kind of the main idea now. What's very important to understand that this is different from mining. Okay, these are the nodes that that that actually are hosting the Blockchain but they're not the miners, the mining mining is a totally different thing and it's not the same as this. We'll get into that a little bit later here. But yeah, that's that's very important to to recognize mining is like validating transactions or not valid. It's like kind of like is it is creating blocks and and and and no posting them kind of to the network to then be validated, right? Which is totally different. So nodes do not create transactions. They don't create blocks, they just validate them. Right? The creating of blocks is actually done by miners and mining, we'll get into that a little bit later. But gas is another concept that is kind of thrown around a lot in ethereum. Um and and really all it is, is just a fee, a fee that's used for, you know, that is used to pay for computational resources, right? On the E V M um Again, this is to help complete keep the network secure, right? Like the whole idea is, what will I have fees, right? Why why not just make it, why not make it free? Right. It's like, well, if you made it free, you know, people would spam the network, right? They would just use it would be unlimited amount of computing power. Right? So gas Qfiis kind of have two purposes, like one is to keep the network secure and the other part of gas fees is is to pay people miners specifically to um to create blocks. Right? Because when a minor creates a block, it creates a successful and finds a successful block. Um, they're rewarded. And part of this gas, this, this fee, uh, is actually, is actually given to, to the minor as an incentive. Right? So gas kind of plays that, that important. And, and you know, the price of gas does kind of fluctuate based on the usage of the network. Um, but you know, the ethereum community is, you know, is looking at ways, you know, they've recently done a London, the London fork, which, which was was aimed to, you know, address some of these, uh, you know, these fluctuating gas prices, which at some point, you know, they were, they were so high, but we'll get into that a little bit later as well too. I mean it's not really important just to kind of as of right now, just to understand that there is gas is a fee and it's kind of basically used to, you know, pay for the, you know, computing resources on the A. B. M. Now. Now we're gonna get into the consensus mechanism. So how do all, so you've got these block chains, right? You've got all these different copies going over all these different computers I guess, you know, up to this point, there's probably at some point you probably ask yourself, well, how do you make sure that they're all saying the same thing. Anybody who's ever done any work with databases and multiple databases or you know, even for example having two different, you know two spreadsheets, you know copies of spreadsheets that are floating around. It's almost you know impossible even to keep Excel spreadsheets, you know, saying the exact exact same thing at some point something will get changed in one and not get updated in the other. Well, Blockchain, you know, it's it's a lot more important to keep the chain, you know, synchronized that the copy of the Blockchain remains the same. Uh that that that the the the the agreed upon state is synchronized right? Because at the end of the day right, it's it's it's transactional, right? It's money that that's got that's kind of that's moving around now the different types of senses, mechanisms that are out there are there's a lot but I'm gonna just talk briefly about two, we're gonna focus on the one that the theory is running on right now which is called proof of work. Um They are moving to proof of stake, We won't go into that as of right now, seeing that's just kind of an introduction but we'll cover the proof of work and kind of where this whole concept of mining really kind of comes from, proof of stake does not use mining, it uses something called staking, which is you know kind of different but but proof of work is kind of the current way that the that that is used to, you know to create blocks and keep the, keep the network kind of synchronized. Um Now the way that this works is that, you know, in a proof of work, somebody submits a transaction right? Um so so before any of this happens before a block is even created um a somebody will go and and and they will submit a transaction into, into the Blockchain, right? So exist. And what happens is before this transaction goes into a block, it goes into something called a meme pool. Okay, now what miners do is they go to this meme pool and they pick up transactions out of the men pool. Usually what they'll do is they'll, you know, if you're a minor, you want to maximize your profit, right? So you're gonna pick out the ones with the, you know, that have the highest gas, that's that's that's given to them, right? Or you know that that that maybe there's a says gas fees also can have tips in them stuff. So people can add tips to, to to prioritize their, their transactions. So miners will pick out transactions out of a meme pool and then they'll create these blocks. Now, once they've created a block before they can submit that block um to the Blockchain network, they have to mine it, no, this is kind of, you know, well what is mining? You know, they got, they got an ax and you know, picking a shovel and are they picking away and well, well, kind of, they're kind of doing that, what they're doing is they're actually trying to get a generate a hash of that block. So at the beginning here we talked about, we kind of went over that a little bit about the hash of a block. What miners are ultimately trying to do is change this nonce value to find a hash that would match the difficulty of the block that's set up. Okay, so what they're doing is trying different types of knots based on all the, so that they'll, they'll put all the, so if we look at something like this, they're going to bring all the transactions into a block and what a minor is going to. So let's assume that this block, you know, isn't part of the isn't part of the Blockchain. So what, what a minor would do is just keep trying different values of this nonsense right? Like 123 until they got like um you know, until they reach the difficulty now difficulty is a is based on how many zeros are in front of the hash and well, I'll show you guys what that, what that means in a bit here, but but it's basically saying that all the hash values that are above a certain, you know, as above a certain value that it will have to reach, that you have to get that before you can Sorry, all the hash values that are below a certain, you know, a certain value that you have to get that hash Now, the higher the difficulty, the lower the hash, the harder it is to get it. Okay, so as the difficulty goes up the harder it gets to to get that hash because it's a smaller number of of hashes that that you can kind of, that you could potentially guess. Now there is no algorithm to get this, you know, like like the the key takeaway here is that there's no algorithm to kind of or a trick or a code or you know, a function that you could use to to kind of solve this and get the particular hash that you need, you're basically doing what a minor does is you're taking a pick and shovel and you're just kind of just going around and digging and digging and digging until you maybe hit gold, right? Um and and until you just try a random, you know, a number of knots, you'll hit that, you'll hit that hash, then your block will be, you know, will be valid and at that point then it can be kind of, you know, submitted to the Blockchain to be validated by the nodes and once it's been validated then, you know, the miner gets paid. So again, miners, you know, need to generate a hash as per the difficulty, so what that is going to look like is as follows. So I've got something kind of set up over here um just to kind of take a look. So here's an example of you know of a meme pool so don't worry about how this is all set up, it kind of set this up before but but but if uh what we'll do here is we'll create a block ourselves and then we'll try to mine it and that's kind of exactly how a minor would would do it, you know in in in in the ethereum so in the Syrian Blockchain so take a block okay and what we'll do is will will feed all these transactions into the block so what we'll do is we'll be the minor and we're gonna take all these transactions. So Ive sent dave 64 then rob sent Alicia 32 then rob sent frank 10 so we'll pick up all three of these transactions will put this into this block and then what we're gonna do is we're gonna try to mind this block so again we're just gonna try to guess of value. Okay now this is gonna be the final hash and I will look at the properties now right now the difficulty is one so you'll kind of see what that means. So just keep that in mind when we're trying to mind this thing and what I ultimately mean by mind is just change that nonce value until we get a valid hash that is you know of of the right value. So what we'll do as well take this counter which is just gonna basically no count up connected to the nonce. Okay and um we'll just increment it slowly until we get a hash value that's valid as per the difficulty. Okay perfect So remember that when I said that the difficulty was one that meant that was 10 right in front. So once we hit that the block became valid. Okay so now this block is valid we just we we clicked on it until we hit seven and we got that value. So this is gonna be a valid block here. Okay and um what we'll do As we'll do the next one plate that move this down here. Remember the difficulty of this block was one. So this will be the first block. So we'll add another couple of more you know transactions here rob and we're just you know we're just just playing with this, we're just adding arbitrary values. Mhm. Had another value to that. Mental. Oh sorry we're just He said that one Steve to rob's you know to Alice to steve I'll make that at this. Okay so well do you know Alice to steve As well you know 96 so we'll create another block as well. Again we'll make this the parent, this will be the first block but this time we'll do something a little bit different will increase the difficulty. No it's not the parent bring those transactions in and remember the parent block for this guy is going to be this block. So what we'll do is we'll connect this to him, take a look at the harsh spring this over here so can be seen. And what we will do is we'll increase the difficulty of this block. Normally this wouldn't happen. The difficulty doesn't change like this, but I'm just doing this just for just for kind of illustration purposes just to help understand, you know, mining and how how that works and and how that's based on difficulty. And then what we'll do is we'll go through the same process here, we're gonna try to guess anons that's gonna give us that difficulty. Now again remember the difficulty in this block was 10, so once we hit something that was below that with the 10 leading zero in the front, you know, we, you know the block was valid this case. Now We've increased the difficulty to two. So we're gonna be looking for two zeros in the front so there's less of those. Um since there's less of those, it's gonna be harder for us to guess. Okay, so we'll just keep trying here until we can find now again there's no we're just kind of randomly trying, we're implementing the nuns by by one value but you know, ultimately and then again we're we're doing this way, slow down, right, An actual miner is doing this at a at an extremely high speed right where we're going, we've really I'm not really slowed this down to kind of to kind of illustrate illustrate this, but there is no formula or anything to how to get that successful. It's basically trial and error is how you're gonna go. We got one. Okay. So I believe it was um it was the nonce was 1 50 for that. Hit it. So you could see the the the the successful hash was two leading zeros. So that's how mining works. That's what mining really is. It's really just trial and error. Trial and error and trying to guess the value of of of that of a block. And then once now once you've successfully um a minor has successfully done this, that block is now valid and can be broadcasted to the network now you say well, how does that create security? Well, look at the process that we just did. Right. I mean we just basically clicking that button but imagine your difficulty is, you know, so I imagine the computational power, the resources that you would have to invest into into validating that it's not something that you could just fraudulently do. Right? And not only is it just one person, there's there's tons of miners out there all trying to compete against one another. Right? So it is in their best interest to get to a valid block as quick as possible. And once they've, you know, they've done the work, they've put the energy in which is kind of the whole idea of put the energy in to, you know, put in the effort and then it will kind of prove the validity that that's kind of how what what makes this whole process, you know secure in itself. That that's what's preventing people from, you know uh you know submitting you know fraudulent transactions, you know on on on the Blockchain right? Is that this whole process that everything kind of has to be kind of has to be basically validated right now in this particular one we didn't have the message signatures in there but you know, that's also again every every transaction like that these transactions are just showing kind of one person but these would also have you know, signatures in them as well. Which would also be, you know put into the um put into the hash as well. So um but um but yeah ultimately that that's kind of how that that whole mining uh you know process works and kind of where this is all about. So uh in this video we've basically gone through um you know what the basics of block chains. So we looked at cryptography and and and why it's such an important, you know, aspect where it where it resides in in in block chains and as you can see already, I mean we haven't covered, we discovered the real the bare basics and cryptography is pretty much showing up everywhere. But it's a very very fundamental thing to Blockchain technology um you know the the concept of of of of parent blocks of of of of embedding previous hashes of blocks you know Chaining blocks together. You know you you mess with once a block is mined and or it's in the Blockchain it's there it's permanent. It's it's basically you cannot tamper tamper it if you did be able to figure it out right away. Right Public private keys and messages are the ways to you know our again cryptographic cryptographic technologies as well. Um that is basically used to verify that the person who is you know is sending this transaction is actually that person right um against cryptography used there. So you know that those are kind of the basics of of all block chains. And then we kind of talked a little bit about ethereum, we talked you know it's you know Bitcoin came out first No in in 2009 with the with the with the white with the white paper and then after that ethereum basically built on top of Bitcoin and said well I just don't want to do instead of just having not just transactions they made it into a programmable, you know block block chain. Right? By building applications on it. Um uh So so they kind of took it took it a step further. I mean they have all the same fundamental features you know that that Bitcoin does as well too, but also have the ability to write applications and write smart contracts on on the on the Blockchain. So that's in a nutshell where we're at, I think, you know, in the next video we will kind of look a little bit at how these, you know, smart contracts are written and how applications are written and and kind of how that all kind of fits in, but but this is kind of basically a good place to start and and kind of go from here. So thank you very much.
37 Views 0 Likes 0 Comments

Comment
Leave a comment (supports markdown format)