Skip to content

hackerbuddy/CapstoneBlockchain

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Capstone Blockchain

Windows Setup Info

I strongly reccommend running python version 3.6.2.

  1. Install ngrok here at https://ngrok.com/download
  2. Add ngrok to the Windows path...or navigate to "ngrok.exe" in CMD then type "ngrok http 6000". You will see this:

Session Status online
Session Expires 7 hours, 27 minutes
Version 2.2.8
Region United States (us)
Web Interface http://127.0.0.1:4040
Forwarding http://af5b7b9c.ngrok.io -> localhost:6000
Forwarding https://af5b7b9c.ngrok.io -> localhost:6000

  1. Install IPFS here at https://docs.ipfs.io/introduction/install/
  2. Initialize IPFS by running "ipfs init"
  3. Run the IPFS daemon "ipfs daemon"
  4. Install python version 3.6.2 here at https://www.python.org/downloads/, or try your own version at your own risk!
  5. In a new command prompt run "pip install -r requirements.txt" (downloads dependencies)
  6. Run "flask run" (if this doesn't work, try "python -m flask run")
  7. Copy and paste the garbled ngrok link from earlier into your favorite browser. For example http://af5b7b9c.ngrok.io.
  8. Congrats! You are now running a decentralized node!

After the initial setup you'll run these in separate command windows:

  1. "ngrok http 6000"
  2. "ipfs daemon"
  3. "flask run"

Mac/Linux Untested Setup Info

Hi guys, if you are running a Linux/Mac, these commands should work. There are some wonky Python version compatability with commands, so it is highly reccommended you use python 3.6.2 or lower (but not below 3).

  1. Install ngrok with "brew install ngrok" or your package manager of choice
  2. Run "ngrok http 6000" or "ngrok 6000". You will see this:

Session Status online
Session Expires 7 hours, 27 minutes
Version 2.2.8
Region United States (us)
Web Interface http://127.0.0.1:4040
Forwarding http://af5b7b9c.ngrok.io -> localhost:6000
Forwarding https://af5b7b9c.ngrok.io -> localhost:6000

  1. Install IPFS here at https://docs.ipfs.io/introduction/install/
  2. Initialize IPFS by running "ipfs init"
  3. Run the IPFS daemon "ipfs daemon"
  4. In a new terminal run "pip install -r requirements.txt" (downloads dependencies)
  5. Run "flask run" (if this doesn't work, try "python -m flask run")
  6. Copy and paste the garbled ngrok link from earlier into your favorite browser. For example http://af5b7b9c.ngrok.io.
  7. Congrats! You are now running a decentralized node!

DATA FORMAT INFO:

get("url/print")

returns a json object structured as below...there are only 3 keys to the returned json (chain, last_hash, and peers)

{
     'chain': #a list of dictionaries where each dictionary represents one check transaction
                 [
                 {"nonce": 0,
                 "prev_hash": \"00000000\",
                 "check_number": null,
                 "item": null,
                 "desc": null,
                 "amount": null,
                 "picture": null,
                 "expires": null,
                 "timestamp": "10-18-2018 00:01 Central Standard Time",
                 "hash": "db5d1b22c1448e9880af063c594ebdf0d33004430ca62e9f72c1170026166e9b"}"
                   }
                   ,
                  {
                  "nonce": 124124,
                 "prev_hash": "db5d1b22c1448e9880af063c594ebdf0d33004430ca62e9f72c1170026166e9b",
                 "check_number": null,
                 "item": "Couch",
                 "desc": A pea green love seat with floral print, from the '70s. Good quality",
                 "amount": null,
                 "picture": "https://ipfs.io/ipfs/QmZKK4EM82Pphav7Z5GbDn6dPhdezEYrPZX3KkHimD6SSm",
                 "expires": "10-31-2018 23:59",
                 "timestamp": "10-18-2018 00:01 Central Standard Time",
                 "hash": "f2h83hb22c1443io2f82ht083c594ebdf038hf283h823hfieh20838hgg280j2920b"}"
                  }
                  ,
                  ...
                  ]
                  ,

    'last_hash': f2h83hb22c1443io2f82ht083c594ebdf038hf283h823hfieh20838hgg280j2920b
     ,

     'peers': [url, url2, url3, url4,...]
}

/add adds a new block to one node, which is then shared to all connected peers using gossip protocol requires a data json to be passed in representing the new block and what nodes it has been shared to.

new_block = Block(node.last_hash,
                      new_block_data['block']['check_number'],
                      new_block_data['block']['item'],
                      new_block_data['block']['desc'],
                      new_block_data['block']['amount'],
                      new_block_data['block']['picture'],
                      new_block_data['block']['expires'])

post("url/add",json=data)

making this call automatically distributes the new block to all other connected nodes, and begins validating it on all receiving nodes. the first node to complete validation will then alert the other nodes that the block has been validated and they will add it to their chain

I believe that these are the only two methods that need to be made through the front end, all other methods and routes are handled by the backend.

About

Marketplace using Blockchain

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •