Giter Site home page Giter Site logo

blockchain-demo's People

Contributors

abitrolly avatar ajeet-yadav avatar anders94 avatar chiukapoor avatar dawe35 avatar dependabot[bot] avatar dindinw avatar ds-kang avatar empeje avatar gabrielecker avatar janioxavier avatar jidma avatar matsxm avatar mrozigor avatar ppkrauss avatar scottcanoni avatar taha-abbasi avatar tonyh2021 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  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

blockchain-demo's Issues

Docker Container not running

Hi,

When running the container the following error occurs: ': No such file or directory. But you can fix that by replacing CMD ["bin/www"] with CMD ["node","./bin/www"] inside the Dockerfile.

Blockchain and Distributed Tab Chains Behave Differently

I noticed, when experimenting with your excellent demo, that the chains on the blockchain and distributed tabs behave differently.

For example, on the blockchain tab when you modify the data field on the second block, which breaks the hash signature as expected, the next block in the chain reflects the proper (broken) hash in the Prev field. Also, when you mine the current block again, generating a good signature for the block, the next block in the chain (and all following) reflect the newly generated hashes in the Prev field as well. This works as expected.

However, on the Distributed tab, which to my thinking should behave identically, just with three parallel blockchains, the next and all following blocks do NOT update the Prev value to reflect reality. This means you would need to carry those values forward manually, where I should just be able to kepp clicking mine on successive blocks to get one of the chains to be divergent from all of the others (while still being internally consistent).

After cloning and testing it out I believe changing line 55 in the distributed code with the following diff would fix it:

https://github.com/anders94/blockchain-demo/blob/master/views/distributed.jade#L55

$ git diff
diff --git a/views/distributed.jade b/views/distributed.jade
index 8793610..49cb601 100644
--- a/views/distributed.jade
+++ b/views/distributed.jade
@@ -52,7 +52,7 @@ block content
           var l = Ladda.create(this);
           l.start();
           setTimeout(function() {
-              mine(block, chain);
+              mine(block, chain, true);
               l.stop();
             }, 250); // give UI time to update
         });

I think this also fixes the token page which does not currently break signatures if you modify a value in the data block.

How to realize the two account transfer?

Transfer money between two accounts, the rest of the block is how can anyone know?Program is how to reflect on the process of running.Thanks for everyone's help

Unconfirmed Transaction / Mempool demo

It would be nice to demonstrate How

  • Transactions are added to the Mempool
  • How miners pull from the pool
  • How do miners broadcast to the network and update other nodes once they win the race to mine a block.

I found a simple demo and explanation here:
https://99bitcoins.com/what-is-bitcoin-mempool/

NOTE: The above link is just a reference to an attempt to tackle these questions, I think your solution can implement it in a much better manner.

These are some of the common requests I am seeing from folks that I am sharing the demo with.

What are your thoughts? If you like this direction, I can contribute to the effort as well.

Highlight coinbase repartition problem

Hi !

What about display a color when a verified blockchain as a coin repartition problem ?
For instance, if Anders initially receive only 10 coin, the second block (and therefore the next ones) should be marked as suspect (with a yellow/orange color ?), because Anders gives money he doesn't have.

Even if this is out of scope of the blockchain implementation, it could be an easy way to teach about exchange verification using blockchains.

Maybe another tab, in order to keep things simple ?

Add bitcoin as a topic to this repository

Hello,

This repository is listed on the Awesome Bitcoin list, which is a collection of useful Bitcoin projects. However, it seems that the 'bitcoin' topic is missing from this repository's topics.

Adding the 'bitcoin' topic will help users discover your project more easily and recognize its relevance to the Bitcoin ecosystem. To add the topic, please follow these steps:

  1. Navigate to the main page of the repository.
  2. Click on the gear icon next to "About" on the right side of the page.
  3. In the "Topics" section, type 'bitcoin' and press Enter.
  4. Click "Save changes."

Thank you for your attention and for contributing to the Bitcoin community!

Error running in container

I'm getting the following error wher trying to run the demo in a container using docker-compose up -d command
': No such file or directory
Is it working for you?
Thanks.

Issue at NPM start

Very very very good demo for newbies !!!!!

Having the following issue at startup .... Any ideas ?

Thanks !!

/home/*******/blockchain-demo/node_modules/fast-printf/dist/src/tokenize.js:4
const TokenRule = /(?:%(?([+0-]|-+))?(?\d+)?(?\d+$)?(?.\d+)?(?[%BCESb-iosux]))|(\%)/g;
^

SyntaxError: Invalid regular expression: /(?:%(?([+0-]|-+))?(?\d+)?(?\d+$)?(?.\d+)?(?[%BCESb-iosux]))|(\%)/: Invalid group
at Object. (/home/*/blockchain-demo/node_modules/fast-printf/dist/src/tokenize.js:4:19)
at Module._compile (module.js:653:30)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
at Module.require (module.js:597:17)
at require (internal/module.js:11:18)
at Object. (/home/
/blockchain-demo/node_modules/fast-printf/dist/src/createPrintf.js:5:20)
at Module._compile (module.js:653:30)

Merkle Tree Demo

Hey, I think it would be really useful to add a visual representation of Merkle Trees to demonstrate those concepts as well

Error i18n and RUN app.js

** RUN app.js **
myuserpc@myuserpc-pc:~/Documentos/blockchain-demo$ node app.js
module.js:549
throw err;
^

Error: Cannot find module 'i18n'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object. (/home/myuserpc/Documentos/blockchain-demo/app.js:2:12)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)

** INSTALL i18n **
myuserpc@myuserpc-pc:~/Documentos/blockchain-demo$ npm install i18n --save
npm ERR! Linux 4.15.0-20-generic
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install" "i18n" "--save"
npm ERR! node v8.10.0
npm ERR! npm v3.5.2
npm ERR! code EMISSINGARG

npm ERR! typeerror Error: Missing required argument #1
npm ERR! typeerror at andLogAndFinish (/usr/share/npm/lib/fetch-package-metadata.js:31:3)
npm ERR! typeerror at fetchPackageMetadata (/usr/share/npm/lib/fetch-package-metadata.js:51:22)
npm ERR! typeerror at resolveWithNewModule (/usr/share/npm/lib/install/deps.js:456:12)
npm ERR! typeerror at /usr/share/npm/lib/install/deps.js:457:7
npm ERR! typeerror at /usr/share/npm/node_modules/iferr/index.js:13:50
npm ERR! typeerror at /usr/share/npm/lib/fetch-package-metadata.js:37:12
npm ERR! typeerror at addRequestedAndFinish (/usr/share/npm/lib/fetch-package-metadata.js:82:5)
npm ERR! typeerror at returnAndAddMetadata (/usr/share/npm/lib/fetch-package-metadata.js:117:7)
npm ERR! typeerror at pickVersionFromRegistryDocument (/usr/share/npm/lib/fetch-package-metadata.js:134:20)
npm ERR! typeerror at /usr/share/npm/node_modules/iferr/index.js:13:50
npm ERR! typeerror This is an error with npm itself. Please report this error at:
npm ERR! typeerror http://github.com/npm/npm/issues

npm ERR! Please include the following file with any support request:
npm ERR! /home/myuserpc/Documentos/blockchain-demo/npm-debug.log

potential double-spending?

Thanks for making this wonderful demo.

I have a question about how to prevent double-spending.

In coinbase block #5, if I change the first transaction to "$2000.00 from Jackson to Alexander", it will pass at nonce=10042. Since Jackson does not have 2000, do we have a double-spending issue here?

Not working

The file is not working at localhost:3000.

Pasting Values Does Not Immediately Change the Other Blocks

As the title states, there is a problem when pasting values in the Block, Blockchain, and Distributed tabs (the tabs I've been working with). This problem seems to be the case only for when a paste is used through right-click. This problem was tested on both the latest versions of Chrome and Firefox. This seems to be a simple fix as you can type something on the keyboard and backspace giving the correct result, but this is nonetheless something that could be fixed.

Difficulty Target

Hi Anders,
are the 4 zeros at the beginning of the hash the so-called difficultiy target, which must be found by the mining?

Thanks for the great work.
I wait eagerly for the continuation of your demo.

Best regards,
Arne

npm start stuck and not doing anything

STUDENTS+CH590@DESKTOP-N MINGW64 ~
$ cd blockchain-demo

STUDENTS+CH590@DESKTOP-N MINGW64 ~/blockchain-demo (master)
$ npm install

[email protected] preinstall C:\Users\CH590\blockchain-demo\node_modules\extendr\node_modules\typechecker
node ./cyclic.js

[email protected] preinstall C:\Users\CH590\blockchain-demo\node_modules\extract-opts\node_modules\typechecker
node ./cyclic.js

[email protected] postinstall C:\Users\CH590\blockchain-demo\node_modules\core-js
node scripts/postinstall || echo "ignore"

Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!

The project needs your help! Please consider supporting of core-js on Open Collective or Patreon:

https://opencollective.com/core-js
https://www.patreon.com/zloirock

Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)

added 169 packages from 209 contributors and audited 350 packages in 57.359s
found 0 vulnerabilities

STUDENTS+CH590@DESKTOP-N MINGW64 ~/blockchain-demo (master)
$ npm start

[email protected] start C:\Users\CH590\blockchain-demo
node ./bin/www

Enhancement in Blockchain section

HI Ander,

your project is awesome. While playing around, the Blockchain section, I found some issue.

If I mine all the blocks, like block 1, Block 2, Block 3 and Block 4.

If I change something in Block 1, my complete chain gets invalidated, that's correct. Now, I directly goes to Block 3, and mine it. It's getting mined. This should not happen.

This breaks the functionality of Blockchain.

app.js is not running

As i18n does not work, I have commented on it in the app.js file, but when executing the program with the node app.js. Nothing happens, just app.js seems not to be running on the server.

var express = require('express');
//var i18n = require('i18n');
var path = require('path');
var favicon = require('serve-favicon');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');

** next section **
/i18n.configure({
locales:['en', 'de', 'es', 'fr-CA', 'hi', 'ja', 'ko', 'nl', 'pl', 'pt', 'zh-CN', 'hu'],
directory: __dirname + '/locales'
});
/

Changes not detected properly

In your demo under the "Tokens" section, I can change the first row of each Tx: segment without invalidating the hash. I don't think this is how it is intended, right?

Spanish

I don't have bitcoins, but here is the Spanish json.

{
"Hash": "Hash",
"Data": "Datos",
"Block": "Bloque",
"Nonce": "Nonce",
"Mine": "Minar",
"Blockchain Demo": "Demo de Blockchain",
"Blockchain": "Blockchain",
"Distributed": "Distribuído",
"Tokens": "Tokens",
"Coinbase": "Coinbase",
"Prev": "Anterior",
"Distributed Blockchain": "Blockchain distribuída",
"Peer": "Peer",
"Tx": "Tx",
"$": "$",
"From": "De",
"Coinbase Transactions": "Transacciones Coinbase"
}

Change to a different block hashing algorithm?

Just emailed you only to find this here... This demo is superb and just wondering please (sadly not being savvy enough) whether it would take much to modify this to work with/appear to work with a different hashing algorithm: more specifically with CryptoNight for ed purposes?

Blockhash on tokens.html unaffected by changes to first transaction.

Observed behavior:
The blockhash of any block on the tokens.html page is unaffected by changes to the first transaction (the top most transaction) in any block.

To reproduce:
Load https://anders.com/blockchain/tokens.html
Modify the tx value or sender or receiver, for the first transaction (the top most transaction) in the block.

Expected result:
Any modification to any data in the block should cause the Blockhash to change.
Block color with a modified tx, and the dependent blocks, should turn red until mined again.

P.S.
Thanks so much for this wonderful demonstration.

Unable to run the project on Windows 10 home 64 bit

I am trying to run this project on Windows 10 home 64 bit version with node js version v8.11.3 and npm version 5.6.0. I can install the packages using npm install and when run using npm start, it shows one message

[email protected] start C:\test\blockchain-demo-master
node ./bin/www
it hangs here and nothing works.
I tried with npm start --inspect option but the same behaviour is observed.

I tried on windows 7 32 bit OS with node version 8.x.x, it doesn't work.
I remember that it was working with older version of node on windows 7 32 bit.

Please suggest.

find a bug

In the coinbase option,Account transfers can be larger than UTXO.
QQ截图20190527155400

Add how to switch to a different "locale" in the README ?

Dear Anders,

Thank you for this very nice demo of blockchains!

However, I am new to Javascript and having difficulty in switching the demo to a different language, though it seems to be part of the applications.

Could you add the instructions in the manual?

Thanks in advance,

Thomas

How to use exports in blockchain.js?

I'm trying to modify the program for an optional project in the university, and I'm trying to put an option to choose how many boxes you want to have in the blockchain.

I put a couple for's in the jade file, in index.js I change:
`var mb = require('../public/javascripts/blockchain.js');
console.info(mb.getMaxBlocks());

router.get('/:page', function(req, res, next) {
res.render(req.params.page, {page: req.params.page, pageData: {maxBlocks : mb.getMaxBlocks()}});
});`

But in blockchain.js I tried to put a global variable and use it from index.js but I'm not sure how, right now I have:
exports.getMaxBlocks = function() { return maxBlocks; };

But it gives an error when running of "TypeError: exports is undefined" and I don't know how to fix it, I tried to download some nodejs modules, search in SO, but I couldn't find a solution, and I was so close...

Because Im seeing index.js and another file has at the bottom "module.exports...", so I suppose they can use it because they are in the root? I cant use this, how can I send the value of a variable to another js file?

If you like it I can do a pull request when it works.

Account balance checking

In the video (final Coinbase section), you mention that only Anders can transact to others in Block 2, because only Anders has a historical balance to transact from.

It would be a great enhancement if this final Coinbase implementation also made blocks Red/invalid if there are any attempts to transact from a source with insufficient balance (or maybe a different color-code, like purple? to indicate a different kind of invalidity than the Red for incorrect hash chaining)

(Another thought: maybe the "Mine" button is deactivated until the transactions are valid according to historical balances)

Valid Balance and more...

First of all : Great project !

Question #1: Please details how transactions are validated (there are sufficient funds)
In video you mentioned if user A received in previous block $10 than in the next one can transfer $2.
What if user A besides receiving $10 also transfer those $10 in previous block?

Question #2: Please explain how peers synchronize their chains?

Question #3: Do you plan to add the functionality to add "Blocks"?

Thanks

Blockchain

I'm new to the blockchain and technology world. Looking forward to learning and developing myself with help from here

npm WARN deprecated [email protected]: Package renamed as '@messageformat/core'

Getting the below error on install npm:
npm WARN deprecated [email protected]: Package renamed as '@messageformat/core', see messageformat.github.io for more details. 'messageformat' will eventually provide a polyfill for Intl.MessageFormat, once it's been defined by Unicode & ECMA.
npm ERR! Linux 5.4.0-104-generic
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install"
npm ERR! node v8.10.0
npm ERR! npm v3.5.2
npm ERR! code EMISSINGARG

npm ERR! typeerror Error: Missing required argument #1
npm ERR! typeerror at andLogAndFinish (/usr/share/npm/lib/fetch-package-metadata.js:31:3)
npm ERR! typeerror at fetchPackageMetadata (/usr/share/npm/lib/fetch-package-metadata.js:51:22)
npm ERR! typeerror at resolveWithNewModule (/usr/share/npm/lib/install/deps.js:456:12)
npm ERR! typeerror at /usr/share/npm/lib/install/deps.js:457:7
npm ERR! typeerror at /usr/share/npm/node_modules/iferr/index.js:13:50
npm ERR! typeerror at /usr/share/npm/lib/fetch-package-metadata.js:37:12
npm ERR! typeerror at addRequestedAndFinish (/usr/share/npm/lib/fetch-package-metadata.js:82:5)
npm ERR! typeerror at returnAndAddMetadata (/usr/share/npm/lib/fetch-package-metadata.js:117:7)
npm ERR! typeerror at pickVersionFromRegistryDocument (/usr/share/npm/lib/fetch-package-metadata.js:134:20)
npm ERR! typeerror at /usr/share/npm/node_modules/iferr/index.js:13:50
npm ERR! typeerror This is an error with npm itself. Please report this error at:
npm ERR! typeerror http://github.com/npm/npm/issues

npm ERR! Please include the following file with any support request:
npm ERR! /home/dibs/Desktop/Blockchain_WebDemo/blockchain-demo/npm-debug.log

Looking for a possible fix for this issue. Is this an issue with the NPM itself to some specific version?

Run the Blockchain-Demo on Wordpress

Hello everyone,

I want to run this blockchain demo on my Wordpress page. There is no better way to explain how to start a blockchain.

Is it possible to get a small manual here? I have a complete web hosting with mysql and ftp access. Thank you for your help!

Is it possible to donate ETH instead of BTC?

greeting
xr3rebel

[Question] How does one calculate the max nonces limit?

I am trying to make an Proof-of-work script myself, and i want the nonce limit to change dynamically with the difficulty.
The example table shows that the difficulty 4 has a max of 500,000. How would i calculate the max, for a different difficulty?

Thanks in advance

Broken url

At the bottom of the index page, the 'by Anders Brownworth' --> andersbrownworth.com URL has broken. Later I can create a pl if you want.

Off: if you see fantasy in it, I can re-design a bit the page to make it more modern and handy. Would you like me to deal with it?

How to run behind a reverse proxy

What would it take to run this behind a nginx reverse proxy?
I tried this at first, but I guess there is a problem with translating the address between the layers, so all i get is the base html-template.

location /btc {
    proxy_pass http://localhost:3000;
}

Do i have to edit something in the code, or do you know of some other parametres i can use in the nginx-config?
I'm running the app in a docker container, built from the dockerfile in the source code.

How do you run this demo on Windows?

Hi Anders,

Great demo software on blockchain! Thank you for creating and sharing it!

This is not an issue but a question on the installation instructions. How could one run this application on Windows machine using Internet Information Service (IIS) or using XAMPP? I am not very technical, so apologies for what might be a simple question.

Also, would it be possible for other users on their separate machines to connect to the demo application and simultaneously update the blockchain? That is if one is able to run the application on a local host and having users connect and update their blockchains.

Thanks again and all the best,
Rumen

Coinbase mining changes data instead of nonce

Hi !

This work is a amazing idea :)

I'm struggling with the coinbase tab. I change, for instance, the initial amount of coin received by Anders. As the block chain is broken, i click Mine, and, instead of modifying the nonce value, the initial amount of coin is reset to 100.

IMHO, it should be much more interesting to only tweak nonce value (as shown in the video),
allowing one to break the blockchain to understand its interest in case of coinbase implementation.

Tested on Firefox 51.0.1, 64bits, fedora 24.

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.