Skip to content

zhtswang/simple-blockchain-lite

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple Blockchain Lite

This is a simple blockchain implementation in Java. It is a lite version of a blockchain, which is a distributed database that maintains a continuously growing list of ordered records called blocks. Each block contains a timestamp and a link to a previous block.

prerequisites

  • Java 17
  • Maven
  • Git
  • IDE (IntelliJ IDEA, Eclipse, etc.)
  • LevelDB
  • Postman

Installation

  1. Clone the repository
git clone https://github.com/zhtswang/simple-blockchain-lite.git
  1. Open the project in your IDE
  2. Maven Compile the project and generate related GRPC files
mvn compile
  1. Run the project
mvn package
  1. Run the server, you can configure the server at the application.yml file and run the following command by the configuration
echo "Starting Node 1"
java -Dnode.id=1 -jar simple-blockchain-0.1.1.jar --server.port=8080
eho "Starting Node 2"
java -Dnode.id=2 -jar simple-blockchain-0.1.1.jar --server.port=8081
echo "Starting Node 3"
java -Dnode.id=3 -jar simple-blockchain-0.1.1.jar --server.port=8082
  1. Test the server by Postman
  • Send Transactions to Node.
curl --location 'localhost:8081/transactions/broadcast' \
--header 'Content-Type: application/json' \
--data '[
    {
        "header": {},
        "payload": {
            "smartContract": "test/v1",
            "args": [
                "write",
                "testkey",
                "testvalue"
            ]
        }
    }
]'
  1. Query the blockchain
curl --location 'localhost:8082/api/v1/blockchain/node/1/block?from=0&to=5'

System Architecture

  • High level architecture
  • High level architecture Notice: The project is in progress, it has many issues and can be only used to study the block chain knowledge.

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

About

Simple Blockchain sample, one lite version for studying

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages