GithubHelp home page GithubHelp logo

sf-chain-guides's Introduction

Build a Blockchain and Cryptocurrency from Scratch

The official code for the Build a Blockchain and Cryptocurrency from Scratch course on Udemy by David Katz.

Check out the course: https://www.udemy.com/build-blockchain

The blockchain is a revolutionary technology that allows for the secure, distributed, decentralized storage of information. Over the past few years, the blockchain has taken the engineering landscape by storm. Many people in the industry predict that the blockchain will disrupt the ways we interact with technology on the same way the Internet did in the early 2000s.

Some of the main course highlights:

  • Build a Blockchain in the object-oriented programming style.
  • Generate hashes for blocks in the chain.
  • Unit Test Components of the Blockchain.
  • Create an API around the Blockchain.
  • Create a real-time connected peer-to-peer server.
  • Implement a proof-of-work algorithm.
  • Sign Transactions with cryptography and digital signature.
  • Create a Transaction Pool for a real-time list of incoming data.
  • Include transactions in core blocks of the chain.

Ultimately, knowledge of the Blockchain will set you up for success in the future, as an engineer in a blockchain-dominated world.

sf-chain-guides's People

Contributors

15dkatz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sf-chain-guides's Issues

How to make a blockchain with peers on different ip addresses

Hello David,

I am trying to synchronize blocks on two different peers having different ip addresses on the same network. I can establish the connection between the two peers but when i try to update the chain on a peer, the console log outputs "The received chain is not valid". Please tell me how to rectify this issue.

Thanks

How to develop a frontend for the Blockchain project.

Hello David,

I have watched your blockchain tutorial on udemy.
Now, could you please help me to develop a front-end interface for the same project.
I am not a very much familiar with this so need your help

Thanks
Rajnikant

Tests fail if DIFFICULTY is set to 1

The test suits block.test.js and index.test.js fail if you set the difficulty constant in config.js to values <= 1 (works with values above 1).

Steps to reproduce:

  1. Go to config.js and set the DIFFICULTY = 1
  2. Run the tests with npm run test
  3. Observe the failed test

Output:
`FAIL blockchain\index.test.js
● Console

console.log blockchain\index.js:36
  The received chain is not valid.
console.log blockchain\index.js:33
  Received chain is not longer than the current chain.

● Blockchain › validates a valid chain

expect(received).toBe(expected)

Expected value to be (using Object.is):
  true
Received:
  false

  24 |     bc2.addBlock('foo');
  25 |
> 26 |     expect(bc.isValidChain(bc2.chain)).toBe(true);
  27 |   });
  28 |
  29 |   it('invalidates a chain with a corrupt genesis block', () => {

  at Object.<anonymous> (blockchain/index.test.js:26:40)

● Blockchain › replaces the chain with a valid chain

expect(received).toEqual(expected)

Expected value to equal:
  [{"data": [], "difficulty": 1, "hash": "f1r57-h45h", "lastHash": "-----", "nonce": 0, "timestamp": "Genesis time"}, {"data": "goo", "difficulty": 1, "hash": "6d3ac3d3fce2d53547ba8c3b7e77331e6358e323b41f03869fb35441e64533e2", "lastHash": "f1r57-h45h", "nonce": 1, "timestamp": 1634499338109}]
Received:
  [{"data": [], "difficulty": 1, "hash": "f1r57-h45h", "lastHash": "-----", "nonce": 0, "timestamp": "Genesis time"}]

Difference:

- Expected
+ Received

@@ -5,14 +5,6 @@
      "hash": "f1r57-h45h",
      "lastHash": "-----",
      "nonce": 0,
      "timestamp": "Genesis time",
    },
-   Block {
-     "data": "goo",
-     "difficulty": 1,
-     "hash": "6d3ac3d3fce2d53547ba8c3b7e77331e6358e323b41f03869fb35441e64533e2",
-     "lastHash": "f1r57-h45h",
-     "nonce": 1,
-     "timestamp": 1634499338109,
-   },
  ]

  44 |     bc.replaceChain(bc2.chain);
  45 |
> 46 |     expect(bc.chain).toEqual(bc2.chain);
  47 |   });
  48 |
  49 |   it('does not replace the chain with one of less than or equal to length', () => {

  at Object.<anonymous> (blockchain/index.test.js:46:22)

FAIL blockchain\block.test.js
● Block › generates a hash that matches the difficulty

expect(received).toEqual(expected)

Expected value to equal:
  "0"
Received:
  "7"

  20 |   it('generates a hash that matches the difficulty', () => {
  21 |     expect(block.hash.substring(0, block.difficulty))
> 22 |       .toEqual('0'.repeat(block.difficulty));
  23 |   });
  24 |
  25 |   it('lowers the difficulty for slowly mined blocks', () => {

  at Object.<anonymous> (blockchain/block.test.js:22:5)

Test Suites: 2 failed, 3 passed, 5 total
Tests: 3 failed, 28 passed, 31 total
Snapshots: 0 total
Time: 5.558s
Ran all test suites.
`

Transaction › transacting with an amount that exceeds the balance › does not create the transaction

when testing the transaction system i get this error in my console:

 FAIL  Wallet/transaction.test.js
  ● Transaction › transacting with an amount that exceeds the balance › does not create the transaction

    expect(received).toEqual(expected) // deep equality

    Expected: undefined
    Received: {"id": "3552af40-3b4b-11ec-b380-118a0d2a95d5", "input": {"address": "0468c30443e37d55c4083dbe0617d540f1fecd2bf9d383789eb922f3e417a346ce996bb38b1945de5fe94e165737733aacf7f0af2ea9beda8a82bccdafe9bc24be", "amount": 500, "signature": {"r": "2d5f77cdc00f45cfbd5572a43b5952219ea3acffa8de47967af9f23d6db0a8c2", "recoveryParam": 1, "s": "1520a0058ac99d3f10ad81c767e53d018792a8a7793ede4ad6a2b1186300441d"}, "timestamp": 1635795474484}, "outputs": [{"address": "0468c30443e37d55c4083dbe0617d540f1fecd2bf9d383789eb922f3e417a346ce996bb38b1945de5fe94e165737733aacf7f0af2ea9beda8a82bccdafe9bc24be", "amount": 450}, {"address": "RECEIVER", "amount": 50}]}

      41 |
      42 |     it('does not create the transaction', () => {
    > 43 |       expect(transaction).toEqual(undefined);
         |                           ^
      44 |     });
      45 |
      46 |     describe('and updating a transaction', () => {

      at Object.<anonymous> (Wallet/transaction.test.js:43:27)

how can i fix this error

P2P Websocket Error

I am using windows 10 as the host machine

PS D:\blockchain\source_code\in-block> npm run dev HTTP_PORT=3002 P2P_PORT=5002 PEERS=ws://localhost:5001

[email protected] dev D:\blockchain\source_code\in-block
nodemon ./app "HTTP_PORT=3002" "P2P_PORT=5002" "PEERS=ws://localhost:5001"

[nodemon] 1.18.9
[nodemon] to restart at any time, enter rs
[nodemon] watching: .
[nodemon] starting node ./app HTTP_PORT=3002 P2P_PORT=5002 PEERS=ws://localhost:5001
Listening for peer-to-peer connections on: 5001
events.js:183
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE :::3001
at Object._errnoException (util.js:1022:11)
at _exceptionWithHostPort (util.js:1044:20)
at Server.setupListenHandle [as _listen2] (net.js:1351:14)
at listenInCluster (net.js:1392:12)
at Server.listen (net.js:1476:7)
at Function.listen (D:\blockchain\source_code\in-block\node_modules\express\lib\application.js:618:24)
at Object. (D:\blockchain\source_code\in-block\app\index.js:26:5)
at Module._compile (module.js:643:30)
at Object.Module._extensions..js (module.js:654:10)
at Module.load (module.js:556:32)
[nodemon] app crashed - waiting for file changes before starting.

Node beginner

The course instructions said
With Node installed, you should get responses similar to this on the command line:

$ node -v

v8.8.1 (or something similar)

Im getting

$ node -v
$ node -v
^^^^

SyntaxError: Unexpected identifier

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.