TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Show HN: An educational blockchain implementation in Python

412 pointsby jreover 7 years ago

12 comments

magnatover 7 years ago
&gt; It is NOT secure neither a real blockchain and you should NOT use this for anything else than educational purposes.<p>It would be nice if non-secure parts of implementation or design were clearly marked.<p>What&#x27;s the point of education article, if bad examples aren&#x27;t clearly marked as bad? If MD5 usage is the only issue, author could easily replace it with SHA and get rid of the warning at the start. If there are other issues, how can a reader know which parts to trust?<p>Even if fixing bad&#x2F;insecure parts are &quot;left as an exercise for the reader&quot;, learning value of the article would be much greater if those parts would be at least pointed at.
评论 #15946300 未加载
评论 #15945889 未加载
评论 #15947251 未加载
评论 #15946552 未加载
评论 #15946162 未加载
评论 #15946343 未加载
h4l0over 7 years ago
For the last couple of months, there have been many educational, simple implementations that explains blockchain technology, I guess thanks to crypto bubble. I wish these were around when we were doing our senior design project on blockchains in 2014. Back then, I only could find basiccoin[0], which was purely minified to just fit in 1000 loc.<p>After that, I decided to re-implement everything from scratch. My foremost constraint was to write readable code so that anyone could read the codebase and have an idea of how blockchain works.<p>My current draft of implementation can be found on <a href="https:&#x2F;&#x2F;github.com&#x2F;halilozercan&#x2F;halocoin" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;halilozercan&#x2F;halocoin</a> , which currently lacks detailed README and documentation. However, you can still experiment with it by using API or CLI. I&#x27;m running a dedicated server to have an always online peer you can connect to.<p>[0]: <a href="https:&#x2F;&#x2F;github.com&#x2F;zack-bitcoin&#x2F;basiccoin" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;zack-bitcoin&#x2F;basiccoin</a><p>Edit: a word
westurnerover 7 years ago
Thanks! Simplest explanation I&#x27;ve seen.<p>Here&#x27;s an nbviewer link (which, like base58, works on&#x2F;over a phone): <a href="https:&#x2F;&#x2F;nbviewer.jupyter.org&#x2F;github&#x2F;julienr&#x2F;ipynb_playground&#x2F;blob&#x2F;master&#x2F;bitcoin&#x2F;dumbcoin&#x2F;dumbcoin.ipynb" rel="nofollow">https:&#x2F;&#x2F;nbviewer.jupyter.org&#x2F;github&#x2F;julienr&#x2F;ipynb_playground...</a><p>Note that Bitcoin does two rounds of SHA256 rather than one round of MD5. There&#x27;s also a &quot;P2P DHT&quot; (peer-to-peer distributed hash table) for storing and retrieving blocks from the blockchain; instead of traditional database multi-master replication and secured offline backups.<p>&gt; ERROR:root:Invalid transaction signature, trying to spend someone else&#x27;s money ?<p>This could be more specific. Where would these types of error messages log to?
评论 #15946474 未加载
评论 #15947406 未加载
geraldbauerover 7 years ago
FYI: Great blockchain (from sratch) starter article. At the Awesome Blockchains page [1] I collect starter blockchains and articles (in Python, Ruby, JavaScript, etc.) the idea is the best way to learn about blockchains is to do-it-yoursef - build your own blockchains from scratch. Great example. Keep it up. Cheers. [1] <a href="https:&#x2F;&#x2F;github.com&#x2F;openblockchains&#x2F;awesome-blockchains" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;openblockchains&#x2F;awesome-blockchains</a>
评论 #15946325 未加载
heynkover 7 years ago
This is great. Just last weekend I did the same thing, coding a very basic blockchain in Python for educational purposes. You tackled wallets, which I didn&#x27;t get to yet, so that was really helpful.<p>I&#x27;m still a little unsure around exactly how miners and nodes communicate with each other. Especially things like broadcasting transactions and new blocks. Any good resources for that?
评论 #15946321 未加载
ivan_ahover 7 years ago
Very good writeup that shows all the steps.<p>Note it uses MD5 hash instead of SHA256 so not exactly bitcoin. I wonder how much more work would be to make the code fully implement bitcoin. Will it still be readable? Or Etherium? Would be great value for understanding even if Python would be inefficient to run in prod.
评论 #15946348 未加载
评论 #15945773 未加载
vinn124over 7 years ago
nice walkthrough.<p>also, not sure why folks are nitpicking about minor things like security disclaimers, number of sha256 hashes, md5, etc. while ignoring nontrivial gaps (eg no merkle dags, one of the cornerstone concepts).
评论 #15946377 未加载
jobeirneover 7 years ago
Something from a few months back that&#x27;s a bit closer to Bitcoin&#x27;s actual implementation but at a similar level of readability: <a href="https:&#x2F;&#x2F;github.com&#x2F;jamesob&#x2F;tinychain" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;jamesob&#x2F;tinychain</a>
brodoover 7 years ago
Coll project. I think having educational * implementations in Python is great in general. Better then having just an article about it...
antmanover 7 years ago
So is there a non educational implementation of blockhain that someone could use&#x2F;parametrize&#x2F;configure? Something that is not educational but more industrial strength? What must someone do to convert an educational implementation to a serious one?
satellitec4tover 7 years ago
Why is this all contained in one big json document? Am I that out of touch with modern coding??
评论 #15946150 未加载
评论 #15946137 未加载
评论 #15946161 未加载
partycoderover 7 years ago
Educational implementation, brilliant. Now some startup will give it a name and make an ICO.