Skip to content

shreyaj1212/COM70-Blockchain-Project

Repository files navigation

COM70-Blockchain-Project

Check out a video demo here.

components

This folder includes the components of our blockchain simulation: Block, Blockchain, Test, Transaction, and User

Block

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.

Blockchain

Is an ordered array of Block objects.

Transaction

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.

User

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).

index.js

This is where all of the API work is located. There are routes to
1. 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.

Demo

Check out a video demo here.

the page a user arrives at Screen Shot 2021-10-24 at 2 15 27 PM

Add a user named Shreya. Let's give her 50 coins.

add shreya

Shreya has been added. Here is the response from the server, displayed on the front page.

shreya has been added

Now let's add Grace.

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.

grace added, start transaction

The response from the server is as follows:

Screen Shot 2021-10-24 at 2 18 30 PM

Now let's demonstrate a signed transaction.

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.

Screen Shot 2021-10-24 at 2 18 55 PM

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.

Screen Shot 2021-10-24 at 2 19 38 PM

Here, we can see there are 2 blocks. Now the proofOfWork field has a value that corresponds to the precedingHash of the next block.

Screen Shot 2021-10-24 at 2 19 38 PM

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published