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:

Solid Principles For Javascript

SOLID principles for JavaScript

SOLID principles help us keep code flexible. In this article, we’ll examine all of those principles and their implementation using JavaScript.

Frank Joseph
Dec 5, 2024 ⋅ 10 min read
Master JavaScript Date And Time: From Moment.js To Temporal

Master JavaScript date and time: From Moment.js to Temporal

JavaScript’s Date API has many limitations. Explore alternative libraries like Moment.js, date-fns, and the new Temporal API.

Yan Sun
Dec 4, 2024 ⋅ 9 min read
Npm Vs. Npx: What’s The Difference?

npm vs. npx: What’s the difference?

Explore use cases for using npm vs. npx such as long-term dependency management or temporary tasks and running packages on the fly.

Fimber Elemuwa
Dec 3, 2024 ⋅ 5 min read
How To Audit And Validate AI-Generated Code Output

How to audit and validate AI-generated code output

Validating and auditing AI-generated code reduces code errors and ensures that code is compliant.

Boemo Mmopelwa
Dec 2, 2024 ⋅ 5 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