Check out a video demo here.
This folder includes the components of our blockchain simulation: Block, Blockchain, Test, Transaction, and User Every block holds a certain number of transactions. In our example, we set this value to 3 for simplicity in the simluation. Essentially, a Block is a portion of the data storage of transactions. Is an ordered array of Block objects. Each Transaction has a buyer, a sellar, an amount of coin sold, and a signature to show if it's valid or not. Each transaction also has a unique id which we generate using uuid. Each user is identified by its ipAddress. Each user has a secretKey which is used to generate a signature for a transaction (in each transaction, only the person who is losing money's secret key is needed to generate the signature). This is where all of the API work is located. There are routes to1. get the homepage
2. view all the users (displayed on homepage)
3. add users to the simulation
4. make new transactions between users in the simulation
5. view the current blockchain based off of the transactions added in the simulation
6. update a user's wealth
public folder - includes index.html and style.css
views folder - includes handlebars layout Though we only have one page, we decided to add this feature for flexibility in terms of scale.
Check out a video demo here.
Add a user named Shreya. Let's give her 50 coins.
Shreya has been added. Here is the response from the server, displayed on the front page.
Now let's add Grace.
Now that Grace has been added, let's start a transaction. Let's start with an example where Shreya refuses to sign the transaction. In this case, the transaction will not occur. In this simulation, the user can choose whether a transaction is signed or not to see what happens in either situation.
The response from the server is as follows:
Now let's demonstrate a signed transaction.
Let's do this transaction again to demonstrate how many transactions can be stored in the block. The block should hold 2 transactions where Shreya gives Grace 10 coin.
Currently, there is no proofOfWork because there is only 1 block in the chain. When we add a new block, that proofOfWork will display. Similarly, because this is the first block, it does not have a precedingHash (and it never will).
Let's add RandomPerson to the simulation. RandomPerson starts with 0 coin, but Shreya and Grace both give RandomPerson 5 coin each.
Here, we can see there are 2 blocks. Now the proofOfWork field has a value that corresponds to the precedingHash of the next block.