Skip to content

puru444/Blockchain_with_Python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 

Repository files navigation

BLOCKCHAIN WITH PYTHON

BACKGROUND: As a FinTech Engineer for renowned Financial Institution, I need to build a Blockchain-based Ledger System with a user-friendly Web Interface. This ledger should allow partner banks to conduct financial transactions (that is, to transfer money between senders and receivers) and to verify the integrity of the data in the ledger.


CONTENT

  • Project Description
  • Technologies
  • Blockchain Web-Application
  • Contributor
  • License

PROJECT DESCRIPTION

Decentralized Blockchain Ledger for tracking Sending & Receiving Transactions:

A. DATA CLASSES: There are 3 data classes are defined:

- Record: This data class contains: Sender, Receiver & Amount for each transaction.

- Block: This data class contains: Record (Defined first data class in previous step), Creator ID, Previous Hash (Previous Block's Hash), Timestamp, Nonce (No. of attempts to satisfy the difficulty of Mined Hash).

- PyChain: This data class contains: List of Blocks & the difficulty level by defining prefixes like: "0000" before hash for the miners to Guess & Add Block in Chain, eventually.

B. FUNCTIONS: There are various functions are defined for following purposes:

- hash_block: This function's purpose: to hash the data attributes inside the Block Data-class.

- proof_of_work: This function's purpose: to set the difficulty level for guessing the prev_hash of block.

- add_block: This function's purpose: to add the block in chain after succesfully performed the Proof of Work.

- is_valid: This function's purpose: to validate the block in chain.

- setup(): This function's purpose: to increase the size of chain on addition of each block successfully.


TECHNOLOGIES

  • Python
  • Pandas
  • Streamlit
  • Jupyter Notebook

BLOCKCHAIN WEB APPLICATION

TRANSACTIONS

There are 10 different transactions occured in test instance (streamlit) with following details:

1. TRX_1:

  • Sender: 'Psharma'
  • Receiver: 'Dsmith'
  • Amount: '$500'

TRX_1

  • Block_Difficulty_Level: '2'
  • Nonce_Count: '356'
  • Block_Details: Block(record=Record(sender='Psharma', receiver='Dsmith', amount='$500'), creator_id=42, prev_hash='c91caad3d3438d5b2646eb389c1cd51f0ca6ebaa7b38570ff097c1b7ac4eca70', timestamp='22:11:43', nonce=356)

Block 1


2. TRX_2:

  • Sender: 'Psharma'
  • Receiver: 'Skumar'
  • Amount: '$1000'

TRX_2

  • Block_Difficulty_Level: '2'
  • Nonce_Count: '93'
  • Block_Details: Block(record=Record(sender='Psharma', receiver='Skumar', amount='$1000'), creator_id=42, prev_hash='009c615c5dba7cbee9ebdec32d5742b1d7a7f9b94602060cb7e2a7ad64c3e14a', timestamp='22:12:35', nonce=93)

Block 2


3. TRX_3:

  • Sender: 'Psharma'
  • Receiver: 'Skumar'
  • Amount: '$250'

TRX_3

  • Block_Difficulty_Level: '2'
  • Nonce_Count: '249'
  • Block_Details: Block(record=Record(sender='Psharma', receiver='Skumar', amount='$250'), creator_id=42, prev_hash='00407b66d184a3a69a3224afac120225d4570a9a8aa7c7d2f85f47fce7970936', timestamp='22:13:04', nonce=249)

Block 3


4. TRX_4:

  • Sender: 'Psharma'
  • Receiver: 'Tmiller'
  • Amount: '$700'

TRX_4

  • Block_Difficulty_Level: '2'
  • Nonce_Count: '59'
  • Block_Details: Block(record=Record(sender='Psharma', receiver='Tmiller', amount='$700'), creator_id=42, prev_hash='00b29fecd0c868f72b3605791eb38fd086b2a57a61c1e9e99480fb02fcb5a25a', timestamp='22:14:29', nonce=59)

Block 4


5. TRX_5:

  • Sender: 'Psharma'
  • Receiver: 'Tmiller'
  • Amount: '$300'

TRX_5

  • Block_Difficulty_Level: '2'
  • Nonce_Count: '16'
  • Block_Details: Block(record=Record(sender='Psharma', receiver='Tmiller', amount='$300'), creator_id=42, prev_hash='00706f49736a2ac6cd356a452e06e5a6e407671aba82150ca497592584e36760', timestamp='22:15:16', nonce=16)

Block 5


6. TRX_6:

  • Sender: 'Psharma'
  • Receiver: 'PWilliam'
  • Amount: '$600'

TRX_6

  • Block_Difficulty_Level: '5'
  • Nonce_Count: '992235'
  • Block_Details: Block(record=Record(sender='Psharma', receiver='PWilliam', amount='$600'), creator_id=42, prev_hash='00641e67dd01722db6a941705c9f9fca9501131bc81cdf6383a293ce8398e811', timestamp='22:15:43', nonce=992235)

Block 6


7. TRX_7:

  • Sender: 'Psharma'
  • Receiver: 'Dsmith'
  • Amount: '$800'

TRX_7

  • Block_Difficulty_Level: '5'
  • Nonce_Count: '1011496'
  • Block_Details: Block(record=Record(sender='Psharma', receiver='Dsmith', amount='$800'), creator_id=42, prev_hash='0000099cb96435759f0f300db7df107091b252f61c364601e783fb64c31bb742', timestamp='22:16:22', nonce=1011496)

Block 7


8. TRX_8:

  • Sender: 'Psharma'
  • Receiver: 'Pwarren'
  • Amount: '$200'

TRX_8

  • Block_Difficulty_Level: '5'
  • Nonce_Count: '1903338'
  • Block_Details: Block(record=Record(sender='Psharma', receiver='Pwarren', amount='$200'), creator_id=42, prev_hash='00000e0112f7a0c6f4dd0e4da002d9de91678b5ba4f850181f7dd231e7d322a6', timestamp='22:17:29', nonce=1903338)

Block 8


9. TRX_9:

  • Sender: 'Psharma'
  • Receiver: 'Susan'
  • Amount: '$700'

TRX_9

  • Block_Difficulty_Level: '3'
  • Nonce_Count: '3870'
  • Block_Details: Block(record=Record(sender='Psharma', receiver='Susan', amount='$700'), creator_id=42, prev_hash='000000737a70a3e396b3f30a245f1ad848d60b16ca6ac95cae62fb0ac24685ee', timestamp='22:18:15', nonce=3870)

Block 9


10. TRX_10:

  • Sender: 'Psharma'
  • Receiver: 'Skumar'
  • Amount: '$900'

TRX_10

  • Block_Difficulty_Level: '3'
  • Nonce_Count: '9248'
  • Block_Details: Block(record=Record(sender='Psharma', receiver='Skumar', amount='$900'), creator_id=42, prev_hash='00010afd5d4d36a0a8e0a2fad6372ce6d6b3bd6c2503cffdd116ad3749165355', timestamp='22:18:44', nonce=9248)

Block 10


CHAIN VALIDATION

Chain of 10 blocks are validated with Result: True:

Chain Validation


LEDGER WITH 10 TRANSACTIONS

Blockchain Ledger with 10 Transactions:

Ledger


CONTRIBUTOR

  • PRATEEK SHARMA

www.linkedin.com/in/prateek-sharma-21a081180


LICENSE

GNU General Public License v3.0

About

CASE STUDY: Decentralized Blockchain-based Ledger System for Financial Institution with a user-friendly Web Interface (Streamlit) to transfer money between Sender & Receiver.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages