https://github.com/tamimehsan/poysha
A basic implementation of FinTech Blockchain
https://github.com/tamimehsan/poysha
Last synced: 3 months ago
JSON representation
A basic implementation of FinTech Blockchain
- Host: GitHub
- URL: https://github.com/tamimehsan/poysha
- Owner: TamimEhsan
- Created: 2021-01-17T19:07:07.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2021-02-04T20:23:43.000Z (over 4 years ago)
- Last Synced: 2025-04-13T19:52:40.730Z (6 months ago)
- Language: JavaScript
- Size: 105 KB
- Stars: 4
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Poysha
### Blocks
Blocks hold the information of the transaction .
Any kind of necessary data and most importantly the hashes.
It holds the hash of this block and also the hash of the previous block.
This one uses SHA256 for hashing the fields of the block
This has function
- generateHash() => generates a SHA256 hash from its fields
- mineBlock() => calcualtes hash with given difficuly ie mining
### Blockchain
Some continuous chain of block is a block chain
The first block is created manually and is called **genesis block**.
The chain has some functions
- getLatestBlock()
- addNewBlock()
- isChainValid() => checks the hash and compares if the information provided in the blocks are consistent
### Mining
So, we used isChainValid() to alternate any mid blocks.
But one might add new blocks and spam the hell out of blockchain.
To remove this the chain needs a proof of work.
To ensure this some chain has some rules.
Like the hash should have n leading zeros.
And as one can't predict a hash, So the hash should be done by mere brute force.
A hash with 4 leading zeros takes quite time to generate.
But how one can generate different hash?
Well, add a dummy data which is to be changed to make that happen.
So, when one computer successfully finds a hash with that difficulty then it is called mining.
Then the hash is the proof of work.
Here we see that the hash contains 5 leading zeros and took about 20 seconds for the second block to mine it. The reason why first block took different time than second one is cause the contents of the block on which the hash works are different.
### Transactions
A new block is created at about 10 minutes. Any new transactions are kept in a queue for that time being. Then after that all of the pending transactions are put in a new block and send to mine.
### Rewards
Many computers try to mine a block. But the one who does it quickly will get the reward. As computational power gets increasing so does the difficulty. Current dificulty is 17 leading zeros in SHA256 hash. So when one mines a block a small portion is awarded to him. That will be pending for the next block.

Here we see the address Tamim mined the block successfully and in the next transaction was awarded 100 poysha asa thin air. So, yeah "Pacchish din may paysha double".
### Signing Transactions
Each transaction must be signed from the sender. The signature contains a public key. And that public key identifies the user. But the signature is created by the private key. So no one can replicate others signature.

exception is the reward transaction. As it is not from anyone, so it doesn't have any signature. And it is added automatically to the pending transactions and is rewarded to the miner address.