I wrote a toy (but working) implementation of the Bitcoin algorithm here: <a href="https://github.com/tlrobinson/tomcoin" rel="nofollow">https://github.com/tlrobinson/tomcoin</a><p>The main logic is a few hundred lines of code: <a href="https://github.com/tlrobinson/tomcoin/blob/master/src/node.js" rel="nofollow">https://github.com/tlrobinson/tomcoin/blob/master/src/node.j...</a><p>A somewhat unique aspect is since it's written in JavaScript a node can run on the server or the browser, which makes for easy demos:<p>1. Open <a href="https://tomcoin.herokuapp.com/" rel="nofollow">https://tomcoin.herokuapp.com/</a> and <a href="https://tomcoin1.herokuapp.com/" rel="nofollow">https://tomcoin1.herokuapp.com/</a> in two browser windows (the private key is stored in localStorage so using different domains ensures each gets a different wallet)<p>2. Click "Start Mining" on one or both nodes<p>3. Once you've mined some TomCoin (should just take a few seconds unless more people start mining) copy the public key from one node to the other's "publicKey" field, enter an amount, and click "Transfer"<p>4. Wait for another block to be mined and you should see the balances transfer<p>(There's no persistence so the chain will reset when all the Heroku nodes idle out and other nodes close)<p>(It also just uses WebSockets to connect to the instances on Heroku, or in theory other server instances people are running. I meant to implement WebRTC for P2P between browser nodes but never got around to it)
> The PoW is suffice if the hash begins with a certain number of 0s<p>This is a common explanation of PoW, but is actually incorrect. If you think about it, this would mean that the PoW difficulty could only increase (or decrease) by a factor of two. In reality, the block hash is simply interpreted as a (very large) number, and this number must be less than some other very large number (the "target"). So you <i>do</i> end up with a lot of leading zeros -- but these are just a side effect, not the thing being measured.
For people that need or want to know (really understand) in depth about Bitcoin without any previous background in Computer Science (for example, in Finance, investors, journalists, historians, curious people in general) I have to recommend Ted Nelson's "How Bitcoin actually works" (2014) from his series "Computers for Cynics" [0]. I enjoyed it. (+)<p>[0] <a href="https://youtu.be/3CMucDjJQ4E" rel="nofollow">https://youtu.be/3CMucDjJQ4E</a><p>(+) For the people with background in CS: it might be that the video at some point talks about the number of zeros instead of the comparison, but really, it does not detract a 'bit' from its value.<p>edit: formatting
Here is a simple bitcoin implementation in ruby including the networking for interested, that I did some time ago:<p><a href="https://github.com/oguzbilgic/zincir" rel="nofollow">https://github.com/oguzbilgic/zincir</a>
Clear, concise and to the point. Looking forward to reading the rest. If you finish the whole series and fix/improve the posts in this sequence using the feedback from here, I think it might serve as one of the go-to pages for technically inclined people who are interested to learn about Bitcoin and blockchains.
<a href="https://github.com/lhartikk/naivechain" rel="nofollow">https://github.com/lhartikk/naivechain</a> is a rather decent introductory implementation as well.
Love this way of learning about tech. : build one yourself (the truly noble way would be to try and build without having seen the specs, just from a description of what it does, but that'd take ages).<p>However: when it comes to implementations, the real hard part of the whole Bitcoin affair is where the gnarly details hide, namely consensu, and it is missing at this point.
Mining part is confusing for me. Is POW is essentially to achieve difficulty level ? You do in this while loop until you have achieved this difficulty level ? Is this the primary factor that differentiates having various protocol in crypto ?
Please finish this series! Especially the networking and consensus models it's an interesting read, really like that it's in Rust as I'm also learning Rust so it's nice to see the concepts in that language :)
> the transaction needs to be "Signed" by the `from` public key<p>Is that so? The code actually signs with the private key. Although I might have misunderstood what that sentence refer to.
Thanks for this info Monokh. Just want to raise a minor typo, which is the first line of code in "Signed transactions". I think it's missing two of the map keys.
I really like the intention and good will behind the post but almost every part is incorrect (even on an abstract level not restricting to bitcoin).
I feel like OP is yet another someone who needed the keyword "blockchain expert" on his/her linkedin profile and trying to justify it now with misleading and incomplete information.