Giter VIP home page Giter VIP logo

blockchain's Introduction

Backend Functionalities::

Blockchain() :
1. has a array of blocks
2. has a dictionary of all the unspent transactions
3. creates a genisis block

Wallet() : Creates a wallet
1. has a private key
2. has a public key
3. has a dictionary of unspent transaction outputs

Block(previousBlock.hash) : creates a block of blockchain
1. keeps previous block's hash
2. has a timestamp
3. keeps a array of all the transactions

WalletA.sendFund(WalletB.publicKey,value) : tries to send coins from walletA to walletB, returns a transaction
1. calls WalletA.getBalance() : gets balance of walletA
1. for all UTXOs(unspent transaction outputs) in blockchain, checks if it blongs to the same wallet, if yes, add it to the dictionary of the wallet and counts total balance.
2. for all UTXOs in wallet, takes some UTXOs such that their sum is greater than the value and adds them to the inputs array
3. calls Transaction(self.publicKey,recipient,value,inputs) : makes a transaction
1. has a unique id/hash
2. stores all variables and make a empty outputs array
4. signs the transaction by walletA's private key
5. deletes all the spent TXOs from self.UTXOs
6. returns newTransaction

block.addTransaction(WalletA.sendF...) : adds transaction to the block
1. calls transaction.processTransaction() : processes transaction
1. verifies transaction's signature
2. for all input transactons for this transactoin, update input UTXOs's value from Blockchain.UTXOs
3. calls getInputsValue() : get total value of input TXs
4. makes transaction to recipirnt of input value and another transaction to self of leftover value
5. adds these tranactions to the output array
6. also adds them to the Blockchain.UTXOs
7. delets all the input TXs from Blockchain.UTXOs
2. adds the transaction to the transactions array

Blockchain.addBlock(block) : adds block to the blockchain array
1. calls block.mineBlock(difficulty)
1. calls getMerkleRoot(self.transactions) : gets merkle's root
2. find a hash string which starts with specific zeros(equals to the difficulty)
3. updates the hash/id and the nonce
2. adds it to the blockchain

isChainValid() : checks if the blockchain is valid

Frontend Functionalities
Routes:
1) / : home
2) /blockchain : displays complete blockchain
3) /blockchain/: displays all tranactions for block number
4) /wallet : shows balance and form to make any tranactions
5) /mine : to mine new block to add current tranactions to blockchain
6) /isValid : to check if current chain is valid or not
7) /connect : to connect with peers
8) /mykeys : to generate publicKey and privateKey and save them in file
9) /about : shows info about team

blockchain's People

Contributors

rajneesh04 avatar mandeepvirang avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.