2022-05-12
1648
#node#web3
Frank Joseph
107833
May 12, 2022 ⋅ 5 min read

Build a cryptocurrency with Node.js

Frank Joseph I'm an innovative software engineer and technical writer passionate about the developer community. I'm interested in building applications that run on the internet.

Recent posts:

TypeScript logo over a pink and white background.

Drizzle vs. Prisma: Which ORM is best for your project?

Compare Prisma and Drizzle ORMs to learn their differences, strengths, and weaknesses for data access and migrations.

Temitope Oyedele
Nov 21, 2024 ⋅ 10 min read
Practical Implementation Of The Rule Of Least Power For Developers

Practical implementation of the Rule of Least Power for developers

It’s easy for devs to default to JavaScript to fix every problem. Let’s use the RoLP to find simpler alternatives with HTML and CSS.

Timonwa Akintokun
Nov 21, 2024 ⋅ 8 min read
Rust logo over black marble background.

Handling memory leaks in Rust

Learn how to manage memory leaks in Rust, avoid unsafe behavior, and use tools like weak references to ensure efficient programs.

Ukeje Goodness
Nov 20, 2024 ⋅ 4 min read
Robot pretending to be a person.

Using curl-impersonate in Node.js to avoid blocks

Bypass anti-bot measures in Node.js with curl-impersonate. Learn how it mimics browsers to overcome bot detection for web scraping.

Antonello Zanini
Nov 20, 2024 ⋅ 13 min read
View all posts

7 Replies to "Build a cryptocurrency with Node.js"

  1. Where is computeHash() that is used in addNewBlock method, coming from? It wasn’t a method of Block class!

    1. All instances of computeHash() have been replaced with generateHash(). Thanks for pointing out the typo!

  2. Thank you Joey for pointing this out. This skipped me. It is supposed to be generateHash() as found in the Block class. I was trying to get the best method name.

  3. There’s an error in the validity check. It will always only check the first two blocks of the chain. Move “return true” statement outside the for loop to fix it.

  4. Thank you Ahlstrand for your observation. I think everything is fine as it is. Try to add more blocks and confirm that the code still works fine with the ‘return true statement’ in the for loop.

  5. It is worth mentioning that the Blockchain class method `getTheLatestBlock` gets called in the `addNewBlock` method with the wrong name `getLatestBlock` so it won’t work.

Leave a Reply