This project is a simple implementation of a Proof of Stake (PoS) blockchain written in Go.
It demonstrates the basic concepts of block creation, chain validation, and validator selection based on stake (weight).
- Define a basic
Blockstructure with fields likeIndex,Timestamp,Data,PreviousHash,Hash, andValidator. - Define a
Blockchainthat stores blocks in a slice. - Support multiple validators, each with a configurable stake.
- Choose the validator for each new block based on their stake (weighted random selection).
- Validate each block before adding it to the chain.
- Simple hash generation using SHA-256.
- Each validator has a stake (an integer value representing their tokens).
- When a new block is to be added, a validator is selected randomly, but weighted by their stake.
- The chosen validator "proposes" the new block.
- The block is validated (index, hashes, etc.) and then appended to the blockchain.
go run main.go- Add digital signatures for validators.
- Add dynamic stake updates (validators can increase or decrease their stake).
- Implement validator slashing (penalties for malicious behavior).
- Add networking to support multiple nodes and chain synchronization.
Feel free to fork this project, open issues, or submit pull requests to improve the implementation or add new features!
This project is open source and available under the MIT License.