Mining rewards & transactions - Blockchain in Javascript (part 3)

  Рет қаралды 191,434

Simply Explained

Simply Explained

Күн бұрын

Пікірлер: 244
@stevenrossi293
@stevenrossi293 6 жыл бұрын
Can you do the next video on how to make a peer to peer network!
@GeeksOasis_
@GeeksOasis_ 6 жыл бұрын
yeaaa please
@vlad981
@vlad981 6 жыл бұрын
Amazing! Please, keep up making this series!
@digitalart321
@digitalart321 6 жыл бұрын
Excellent! You made Blockchain comprehensible for children
@javierpernasalvarez2997
@javierpernasalvarez2997 4 жыл бұрын
I would say one of the best points of the tutorial are your comments on how things world in real life (Bitcoin) and the relationship with what you examplify here. Nice job!
@leonhardeuler9839
@leonhardeuler9839 6 жыл бұрын
I followed the series until this video, now my mind is actually blown up.
@HomesteadAce
@HomesteadAce 6 жыл бұрын
Awesome series! Just a note, in your minePendingTransaction method you forgot to set the previousHash of the block as you did in the addBlock()
@curious_one1156
@curious_one1156 3 жыл бұрын
Yeah. Exactly, why did the function still work ?
@dotkoon
@dotkoon 2 жыл бұрын
​@@curious_one1156 In this video he didn't validate the blocks. But in the next video, the code has been fixed.
@nathanstroud4879
@nathanstroud4879 2 жыл бұрын
@@dotkoon Defiantly weird, I am getting an "invalid array length" error, so this is because of the isChainValid() or mineBlock() function?
@olegwarkentin2993
@olegwarkentin2993 6 жыл бұрын
is this series go on? like "how to create a wallet" or synch with clients? :)
@OmarJIBAR
@OmarJIBAR 2 жыл бұрын
Amazing series 👍My area of interest has nothing to do with blockchains but your series captivated me. Thanks a lot.
@PeterBatah
@PeterBatah 3 жыл бұрын
Thank you for sharing your time and expertise with us. I will definitely be going to bed a little bit smarter tonight. Have a safe and wonderful day!
@desireco
@desireco 6 жыл бұрын
Thank you, this series have been awesome. I am familiar with bitcoin but didn't expect you will be able to cover so much in such short time.
@ollimac73
@ollimac73 6 жыл бұрын
amazing, please continue with these great video tutorials. Thanks for the ones you have done so far.
@Loschcode
@Loschcode 6 жыл бұрын
Absolutely great and simple explanation to how blockchain actually works. Keep the good work !
@Angelosanto
@Angelosanto 6 жыл бұрын
These videos are perfect, it would be awesome if you continued the series.
@itcrespo
@itcrespo 6 жыл бұрын
thanks for these videos, the simplest training for blockchain I've found
@mattha3787
@mattha3787 6 жыл бұрын
Please do more, love it.
@malowwang6211
@malowwang6211 6 жыл бұрын
Thank you for sharing, savjee! Great videos! Expect much more videos from you
@AbrarAhmed5
@AbrarAhmed5 6 жыл бұрын
These videos are amazing! Please keep them coming.
@frediopratamad2349
@frediopratamad2349 3 жыл бұрын
Thank you savejee, your explanation was given from heaven :D Amazing
@wildtigers1210
@wildtigers1210 6 жыл бұрын
I think `getBalanceOfAddress()` should also check the balance of `fromAddress` ? before deducting coin from it ?
@thejoker585
@thejoker585 6 жыл бұрын
Mining reward should be added to the current block being mined. It is logical to think that a miner would like to get paid the second she verified the block and not wait for the next block, otherwise theoretically she will have to pay a fee (in BTC network that is both expensive and time consuming).
@thejoker585
@thejoker585 6 жыл бұрын
But otherwise a great tutorial!
@frknbasaran
@frknbasaran 3 жыл бұрын
Thanks for this great series. I just joined your channel but you definitely deserve more.
@Chino747747
@Chino747747 6 жыл бұрын
great vid and tutorial, please keep on adding to these. I'm sure they'll be very popular
@dec41rus
@dec41rus 6 жыл бұрын
Savjee, your explanation is great. Thank you very much
@yuichibencoolenhrs5527
@yuichibencoolenhrs5527 6 жыл бұрын
Thank you for this video. Please continue this series and I look forward to (Part4) (Part5) and so on.
@AkhileshJain0605
@AkhileshJain0605 6 жыл бұрын
Great work Savjee. Would really love it if you explained the ethereum blockchain in your videos!
@rleevzlno
@rleevzlno 6 жыл бұрын
Yeiiii I was waiting for this! Thanks for keep uploading :)
@ongxa888
@ongxa888 6 жыл бұрын
Thank you very much ! Your explaination is simply and easy to understand !
@wrekktime
@wrekktime 6 жыл бұрын
you left "this.index" in calculate hash :)
@simplyexplained
@simplyexplained 6 жыл бұрын
Yep! I fixed it on GitHub together with some other issue's... Sorry about that!
@sauro28
@sauro28 5 жыл бұрын
where can i find it?
@MenOfPurposeHQ
@MenOfPurposeHQ 6 жыл бұрын
Please add more to this series!
@Jonathan-br8dn
@Jonathan-br8dn 6 жыл бұрын
Hi, fantastic series, I am eager to see new videos. regards!
@mahdipakravan676
@mahdipakravan676 4 жыл бұрын
This is Fucking Best Quality OF Learning Blockchain !
@josephnyc
@josephnyc 6 жыл бұрын
I wish everyone in life was explained in OOP, damn fun to watch. Keep it coming, create a Wallet class Savjee! I’m curious, did you make all properties and methods public just for the tutorial? The Chain and Block classes are so exposed it would be very simple to alter, no? IMHO the properties should be private at the least.
@simplyexplained
@simplyexplained 6 жыл бұрын
Yes everything is public. Javascript doesn't have 'private' properties.
@josephnyc
@josephnyc 6 жыл бұрын
Savjee I’m aware, didn’t literally mean public/private, I meant public as in own property, and thought there were ways of achieving private properties with symbols, closures, weakmaps, etc., was just curious to your thoughts on this. I dunno. Love the tutorials!
@rorythewriter
@rorythewriter 6 жыл бұрын
@@simplyexplained How do you make properties that can't be changed in Javascript then? Sorry, I'm not used to js, so not having private seems counterintuitive
@simplyexplained
@simplyexplained 6 жыл бұрын
There isn't a good way to do that in Javascript. Most people prefix private variables with an underscore to show that they shouldn't be directly accessed.
@daniellaerachannel
@daniellaerachannel 6 жыл бұрын
Excellent man! great tutorial
@ryankdavidson
@ryankdavidson 6 жыл бұрын
Great video series, short and sweet
@ThomasOrlita
@ThomasOrlita 6 жыл бұрын
Nice video! I don't need to create a blockchain in javascript, it's just interesting to watch it... Subscribed to catch new videos! :) Btw you forgot to update this.index and this.data on line 21. (ok I see that it's fixed on github)
@sikwee
@sikwee 3 жыл бұрын
Can you do a video on how to implement proof of stake in a javascript blockchain?
@owaisali124
@owaisali124 3 жыл бұрын
so basically when a reward is given to a miner, it is added in pending transactions, but on second iteration it again adds reward for the miner and this will not end, the whole chain will look like reward of the miner of mining his own reward
@darrenlefcoe
@darrenlefcoe 6 жыл бұрын
works, well done. good education... look forward to next video.
@swapnilgt
@swapnilgt 6 жыл бұрын
Nice demonstration. Thank you!
@curious_one1156
@curious_one1156 3 жыл бұрын
The previousHash is not included in this code. He removed the addBlock method with the minePendingTransactions, but did not assign previousHash before mining the block. Besides, he did not remove the index from the hash calculation. He is surely running git code, not this one shown. This would generate an error in the hash function.
@yourlifeonpower
@yourlifeonpower 6 жыл бұрын
Bro! Please develop this tutorial into a course package! I will be very happy to pay for your course and learn from you!
@yourspanishstories
@yourspanishstories 6 жыл бұрын
Thanks, now I'll go make my own crypto currency.
@simplyexplained
@simplyexplained 6 жыл бұрын
Please don't...
@disnelson308
@disnelson308 3 жыл бұрын
I love your tutorial. It is simply t]one of the best here. Please can you build a UI to interact with the application. And consider adding a P2P network too. Thanks
@adlvlaw
@adlvlaw 6 жыл бұрын
Very clear, top quality videos!
@Glosoliful
@Glosoliful 6 жыл бұрын
Loving video! You really know something only if you can explain it to your old mother or you can code it!
@rd9055
@rd9055 6 жыл бұрын
Great video! Please make a video on Tor in simply explained series
@ceorecdeclec9774
@ceorecdeclec9774 6 жыл бұрын
Will you add private/public keys and how can you implement the peer to peer network
@Metachief_X
@Metachief_X 6 жыл бұрын
Hey Savjee. Can you make a more detailed video in depth about how to actually do peer-to-peer trading?
@5906646
@5906646 3 жыл бұрын
Fabulous! Great Work! Tahnk you
@joeysipos
@joeysipos 3 жыл бұрын
So a bitcoin block is basically a big block of transactions... ah ok, makes sense. Didn't know that before.
@dawnthomas1723
@dawnthomas1723 3 жыл бұрын
The getBalanceOfAddress returns 0 for every transaction. I have checked the code against the code in the video and it does not return the balance as your sample code. Are you running the sample code from the video, or are you running the code from git?
@curious_one1156
@curious_one1156 3 жыл бұрын
See, the previousHash is not included in this code. He removed the addBlock method with the minePendingTransactions, but did not assign previousHash before mining the block. Besides, he did not remove the index from the hash calculation. He is surely running git code, not this one.
@as269
@as269 2 жыл бұрын
the same issue i face did you resolve it?
@PendemiGod
@PendemiGod 6 жыл бұрын
Great work thanks so much!
@priteshvaviya6076
@priteshvaviya6076 5 жыл бұрын
Hey why haven't we changed the calculateHash function??
@IbanVan
@IbanVan 6 жыл бұрын
Exellent, one question, How i can save the blockchain (transactions) filesystem or DB ?
@AhmedAdel-ql5dt
@AhmedAdel-ql5dt 5 жыл бұрын
I followed your steps and I am facing the problem , I can't reward the miner and after mining the second block it gives me your balance is 0
@sunjiangkang5353
@sunjiangkang5353 2 жыл бұрын
Thanks for your explaination
@marcellorinaldomartina5593
@marcellorinaldomartina5593 6 жыл бұрын
Have you forgot to update block.previousHash in minePendingTransactions?
@Leoninmiami
@Leoninmiami 6 жыл бұрын
yes, he did. I created a "printBlocks method in the blockChain class that prints all the blocks to the console. The blocks are missing the previous hash. printBlocks() { for(const block of this.chain) { console.log('====================== ', JSON.stringify(block, null, 4 )); } } I fixed it as a param when creating the block in the minePendingTransactions method ... minePendingTrasactions(miningRewardAddress) { let block = new Block(Date.now(), this.pendingTransactions, this.getLatestBlock().hash); .... I'll probably need to change it in the next video ... but I'm happy with my solution, for now.
@BulentSvr
@BulentSvr 6 жыл бұрын
Dear Savjee, Can you do a Simply Explained Video about "EOS"
@agr__7
@agr__7 6 жыл бұрын
amazing man, amazing! Good job!
@18Maxic
@18Maxic 6 жыл бұрын
Excellent man , thanks you
@blackmennewstyle
@blackmennewstyle 6 жыл бұрын
Once you started mining crypto-currencies, there is no going back unless your electricity bills become way too salty...
@Deetoya
@Deetoya 6 жыл бұрын
This really Helped.... LOved iT...
@asolomon15
@asolomon15 6 жыл бұрын
This was an awesome tutorial
@myhandle364
@myhandle364 3 жыл бұрын
Wow, this is what I'm looking for on youtube. I'm still curious on (6.38) how p2p network a fool proof?
@marcwyss8100
@marcwyss8100 6 жыл бұрын
Noob question: Line 52 when you create a new Block: are we not missing the parameter for previousHash? Because when I „console.log“ the blocks, my previous hashes are all at the default ‚0‘.
@marcwyss8100
@marcwyss8100 6 жыл бұрын
Default value being ‘ ‘ and not 0.
@rijumukherjee5280
@rijumukherjee5280 4 жыл бұрын
Hey Savjee I dont understand the concept how miners get out of the loop,Say 'A' transferred X coins to 'B' and now say 'C' mined for this transaction and now again another transaction i.e. reward transaction is obtained and so this will again be mined by 'C' so again it will create a new transaction.....This will continue...So how to break this loop....
@desireco
@desireco 6 жыл бұрын
There is one more thing. address1 doesn't have anything to it, so I added a transaction to genesis block which resolved the issue.
@ShogunWarrior36
@ShogunWarrior36 6 жыл бұрын
I really enjoyed this 3 part tutorial. Nice work! Xavier, do you happen to be Flemish by any chance?
@simplyexplained
@simplyexplained 6 жыл бұрын
Yes I am ;)
@dipanwitachanda444
@dipanwitachanda444 6 жыл бұрын
Waiting for your next video
@scarlettcrofts3168
@scarlettcrofts3168 4 жыл бұрын
How do I solve the TypeError: block.transactions is not iterable ??
@frankr.3413
@frankr.3413 6 жыл бұрын
Great! I wish I could coding like you.
@aigerimiskakova963
@aigerimiskakova963 4 жыл бұрын
Good Explanation!
@beunmin6
@beunmin6 6 жыл бұрын
Awesome! now i can make an ICO
@caochihai
@caochihai 2 жыл бұрын
Thanks for your video, it was really helpful for me. Can you explain why we don't have a balance in reality? Why do we have to calculate it by going through all transactions? Thank you so much
@simplyexplained
@simplyexplained 2 жыл бұрын
Keeping track of balances would waste storage space without any benefits. Remember: blockchains are immutable. You can't change something that's already inside. If you want to keep track of balances, you would have to do that in every block.
@jamiegabbay7232
@jamiegabbay7232 4 жыл бұрын
Apologies, but why is that two transactions are set initially (the add1 to add2 of 100, and the add2 to add1 of 50) yet the 2nd transaction seems to be skipped over? Shouldn't both transactions be completed before xavier recieves his reward?
@liatris69
@liatris69 3 жыл бұрын
This is gold!
@rosseaux
@rosseaux 6 жыл бұрын
Can you also make a tutorial with a proof-of-stake variant?
@chrisreilly85
@chrisreilly85 6 жыл бұрын
Can you explain how luck factors into this for a miner? If I understand correctly, the miner is simply changing the nonce until the block difficulty is met (please confirm if I'm incorrect here). If so, wouldn't every miner start at nonce 0 and work up by 1 sequentially, therefore whoever has the most computing power would solve every block? Or, is it more efficient to randomize the nonce? Thanks for a great video series.
@javajava7475
@javajava7475 6 жыл бұрын
Please make a series on making a wallet for our cryptocurrency
@DeepakSharma5
@DeepakSharma5 6 жыл бұрын
Great videos! Helped me a lot in understanding block chain. Correct me if I am wrong but I think this new block chain will not be valid because you are not setting previousHash while creating new block in your minePendingTransaction function.
@niter43
@niter43 6 жыл бұрын
He forgot to pass it to constructor, yes.
@brianjianzhao3238
@brianjianzhao3238 4 жыл бұрын
Hey Savjee, why we still need to have prevHash as a property for each block and as part of the input for the current hash calculation? It seems to me it never gets used in this video's implementation.
@stormhess8622
@stormhess8622 6 жыл бұрын
Thank you for taking the time to make this video...how would I implement an html frontend interface for it? Since it is to be highly secure, is there any specific calling conventions from html to the script or is as simple as an onClick() event to trigger the transaction? Cheers.
@jackjangdude
@jackjangdude 4 жыл бұрын
He deletes the addblock method that assigns the previousHash argument to the previous hash, but when he replaces it with the minePendingTransaction the block that gets pushed never includes the previous hash. Maybe I missed something...
@nileenaj3964
@nileenaj3964 4 жыл бұрын
In the description box, he has mentioned that he made a mistake and forgot to add the previous hash value.
@gaborzsoter
@gaborzsoter 3 жыл бұрын
Hey, if you continue to run mineTransactions() again and again you actually mining your reward and get rewarded which you can mine and get rewarded infinitely? What am I missing?
@jayantkhandelwal7326
@jayantkhandelwal7326 4 жыл бұрын
Hi, I have a doubt, as we have removed the reference to previous hash when we removed addblock method, then how are we implementing a blockchain without having previous hash value? Please help me in clarifying my doubt!
@curious_one1156
@curious_one1156 3 жыл бұрын
IDK myself. Maybe he ran the code from git, and not this one.
@adhoom
@adhoom 2 жыл бұрын
I don't know whether this changes in the upcoming videos or not. But, something that is really bothering me is that the user specifies the index for his block. Why is it not controlled by like a static field that keeps incrementing when a block is added ?
@simplyexplained
@simplyexplained 2 жыл бұрын
Good point. In fact, that index isn't needed at all. It was deleted from the GitHub repository but unfortunately I cannot update videos. github.com/Savjee/SavjeeCoin/blob/master/src/blockchain.js
@chregig7967
@chregig7967 5 жыл бұрын
Wow, thank you so much, I've been struggling with understanding how bitcoin, mining and the blockchain as a whole worked for a couple of years now and your videos finally cleared up so many questions! Now, if someone reads this, I have a question about one aspect that I am not too sure I understood correctly. You said the mined amount will get added with the next mined block, but in reality that would be very counter productive, would it not? Otherwise, nobody could actually make any transactions, because all of the blocks are used up to pay the rewards...? Or am I missing something?
@simplyexplained
@simplyexplained 5 жыл бұрын
Ah, well there is only 1 miner that can mine a block. So each block creates just 1 'reward' transaction in the next.
@masoudkhoda9161
@masoudkhoda9161 5 жыл бұрын
Nice job. only one question. In your codes, as I checked, you set previous Hash by creating a block. Suppose that, "L" is the current last block in a chain. Block "A" and "B" are created at the same time. So they set their previous hash with the same hash e.g. Hash of "L". What happens by mining when both of them are mined successfully, but B was mined faster. Therefore normally the previous hash of "B" is correct, but the previous hash of "A" should be changed to the hash of "B". What I want to reach, I think assigning previous hash by creating a block is not necessary, but by mining. Am I right?
@denislupookov7895
@denislupookov7895 6 жыл бұрын
OMG! It is something amazing!
@ru42112
@ru42112 6 жыл бұрын
Have you done a video explaining the difference between pow (bitcoin) and pos?
@simplyexplained
@simplyexplained 6 жыл бұрын
Yes I have... It's going live later today 😂🤐
@ru42112
@ru42112 6 жыл бұрын
Simply Explained - Savjee that was quick I'll be looking for it thanks. I also don't understand why all crypto projects have to have a coin or token involved in it.
@der-lotse
@der-lotse 5 жыл бұрын
So pending transctions aren't secured by the blockchain before mining. They are "just there" in the system right? They will get commited by a miner when his mining is succesful. Did I understand it correctly? Why could a miner not change the transaction before the mining is complete and therefore no hashing for the particular transactions is established at this point?
@simplyexplained
@simplyexplained 5 жыл бұрын
Yes you understood correctly. However each transaction is digitally signed with the private key of the sender. When a Miner changes the transaction, the signature becomes invalid and the Miner can't re-sign it because he doesn't have the correct private key to do so.
@g_pazzini
@g_pazzini 6 жыл бұрын
I have a question. Ideally, does a block contain multiple transactions or only one? if it's multiple, are the transaction grouped by certain parameter (e.g. contains transactions with the same fromAddress), or just random?
@VoTinhThuong
@VoTinhThuong 6 жыл бұрын
Hi Savjee! I see in this video you said that you have fix the problem about minePendingTransactions() method in Github. But when I use your code in Github, it still have an error about reward like in your video. I still have to mine twice so that I could have receive the coin??? Why I can't reward the coin in the first time mining?
@g_pazzini
@g_pazzini 6 жыл бұрын
it's not an error... at the first time mining, you processed those 2 initial transactions. you haven't got rewarded.... after 1st mining, you got a reward which is posted as "pending" transaction and it's not in the block yet. that's why you need to do 2nd mining to have it in the block.
@shandonanderson3967
@shandonanderson3967 6 жыл бұрын
Can we expect to see the other videos uploaded for this series?
@simplyexplained
@simplyexplained 6 жыл бұрын
Yes, but not in the immediate future. Sorry about that! But you can help make it faster. Checkout the code on GitHub, make a pull request with new features and I could make a new video about it (and give you full credit ofcourse)
@yuefeima6201
@yuefeima6201 6 жыл бұрын
great videos, thanks
@williamokano
@williamokano 6 жыл бұрын
Hi Savjee, but why not instead of leaving the balance of the miner to the next block you can't auto insert this transaction into the pending transactions plus setting a new property called "minedBy" to show that the miner really put some efforts into the mining? With this you can ensure that the token will be "instantly" transfered and anyone that can check the chain can build correctly the miners balance.
@simplyexplained
@simplyexplained 6 жыл бұрын
Sure, you could put the mining reward in the same block. However there is no need to add the "minedBy" property. You know who mined the block by checking where the mining reward went to ;)
@ringoyip0901
@ringoyip0901 6 жыл бұрын
This is amazing! The only question I have is: once a pending transaction has been resolved, will it get deleted? Do we need to create a method for deleting a resolved pending transaction?
@simplyexplained
@simplyexplained 6 жыл бұрын
When a transaction is added to a block, we don't have to keep it in the pending transactions. The code does this by redefining the pendingTransactions array
@j8577798yt
@j8577798yt 6 жыл бұрын
Very good!!!
@softtech5630
@softtech5630 5 жыл бұрын
Hay un error en el codigo de muestra que calcula el Hash porque está así: calculateHash() { return SHA256(this.index + this.timestamp + JSON.stringify(this.data)+ this.nonce).toString(); } Y DEBE QUEDAR ASI: calculateHash() { return SHA256(this.previousHash + this.timestamp + JSON.stringify(this.transactions) + this.nonce).toString(); }
@rliy001
@rliy001 6 жыл бұрын
In a"real blockchain", does it really keep adding the mining reward to the pending transactions list; and then another miner has to mine that transaction? Wouldn't this create an endless cycle of rewards, which of cause keeps introducing new bitcoins to the system. What I thought happens when someone mines a block is that the mining reward is added to the same block that just got mined. Is that right?
@rja_live
@rja_live 6 жыл бұрын
One block keeps many transactions, so it can includes one more transaction to reward previous miner
Signing transactions - Blockchain in Javascript (part 4)
18:40
Simply Explained
Рет қаралды 123 М.
How Much Tape To Stop A Lamborghini?
00:15
MrBeast
Рет қаралды 235 МЛН
快乐总是短暂的!😂 #搞笑夫妻 #爱美食爱生活 #搞笑达人
00:14
朱大帅and依美姐
Рет қаралды 13 МЛН
Молодой боец приземлил легенду!
01:02
МИНУС БАЛЛ
Рет қаралды 2,1 МЛН
Yay😃 Let's make a Cute Handbag for me 👜 #diycrafts #shorts
00:33
LearnToon - Learn & Play
Рет қаралды 117 МЛН
Proof-of-Stake (vs proof-of-work)
7:59
Simply Explained
Рет қаралды 1,4 МЛН
Blockchain 101 - A Visual Demo
17:50
Anders Brownworth
Рет қаралды 2,5 МЛН
Zero Knowledge Proof - ZKP
10:18
Simply Explained
Рет қаралды 189 М.
5 Amazing Ways to Automate Your Life using Python
18:40
Internet Made Coder
Рет қаралды 265 М.
How does a blockchain work - Simply Explained
6:00
Simply Explained
Рет қаралды 10 МЛН
Unboxing the Raspberry Pi CM5 Development Kit
11:36
Level 2 Jeff
Рет қаралды 23 М.
Ich programmiere eine einfache Blockchain!
11:29
Kevin Chromik
Рет қаралды 23 М.
How Much Tape To Stop A Lamborghini?
00:15
MrBeast
Рет қаралды 235 МЛН