Skip to content

SimplyBlock is a simple Blockchain project that stores randomly generated user transactions into blocks. It only uses the built-in python modules.

License

Notifications You must be signed in to change notification settings

TheRedMudder/SimplyBlock

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SimplyBlock

A simple Blockchain project that stores randomly generated user transactions into blocks. It only uses the built-in python modules.

Getting Started

  • Download Python 3
  • Download/Clone the repo
  • Open CMD/Terminal in the project directory and run python block.py to generate the blockchain
  • The Blockchain will save to simplyblock.json

Examples

Generating a new blockchain:

simplyBlockContent={'blockIndex':0,'lasthash': None,'useract':[userAccount],"txn":[None]}
simplyBlock={'hash':getHash(simplyBlockContent),'block':simplyBlockContent}
simplyChain=[simplyBlock]

Opening existing blockchain:

with codecs.open('simplyblock.json', 'r') as outfile:
	simplyChain=json.load(outfile)

Create transaction to process(John sends Ron 57 units):

transactionToProcess = [{'reciever':'Ron','sender':'John','amount':57}]

Generate random transactions to process:

transactionToProcess = generateTransactions(userAccount,15)

Process transactions to new block:

simplyChain.append(processTransactionsToBlock(userAccount,simplyChain,transactionToProcess))
userAccount=getUpdatedUserAccount()

Print last block:

print(simplyChain[-1])

Print entire chain:

print(simplyChain)

Verify Transaction(returns True if Valid, False if Invalid)

verifyTransaction(transaction, userAccount)

Running blockServer

python blockServer.py

About

SimplyBlock is a simple Blockchain project that stores randomly generated user transactions into blocks. It only uses the built-in python modules.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published