An educational project for learning Golang
and blockchain
technology. This project uses Golang
, net/http
for networking, and Badger
as persistent storage.
Before running the project, make sure you have the following installed:
- Clone the repository:
git clone https://github.com/okr-go-club/blockchain.git cd blockchain
- Install dependencies for the backend:
go mod tidy
- Install dependencies for the frontend:
cd frontend npm install
- Run the project (as described in the "Run" section below).
An example of running multiple nodes on a single machine:
go run cmd/blockchain/main.go -address localhost:8080 -http localhost:8090 -storage chain_storage
go run cmd/blockchain/main.go -address localhost:8081 -peers localhost:8080 -http localhost:8091 -storage chain_storage_2
go run cmd/blockchain/main.go -address localhost:8082 -peers localhost:8080,localhost:8081 -http localhost:8092 -storage chain_storage_3
You can generate a private and public key for testing purposes:
go run cmd/private_key_generator/main.go
The blockchain implements a Bitcoin-like model. The blockchain and wallet entities are implemented in the chain
package. Each node stores its own copy of the blockchain (in the storage
package) and synchronizes it with others via peer-to-peer connections (using the p2p
package).
The UI is built with TypeScript, React, and Chakra UI. To run a local instance:
cd frontend
npm start
The default port is 8090
, but you can change it in frontend/src/axiosConfig.ts
.
Contributions are welcome! If you would like to contribute, please follow these steps:
- Fork the repository.
- Create a new branch (
git checkout -b feature-branch
). - Commit your changes (
git commit -m 'Add new feature'
). - Push to the branch (
git push origin feature-branch
). - Open a pull request.
Please make sure your code follows the existing style and passes all linting checks before submitting a PR.