This is a workshop to learn the basics of blockchain technology and how to create a simple blockchain using Java and Spring Boot.
.
│
├───assets
├───src
│ ├───main
│ │ ├───java
│ │ │ └───com
│ │ │ └───mustaphaslimani
│ │ │ └───workshop
│ │ │ │ WorkshopApplication.java
│ │ │ │
│ │ │ ├───configuration
│ │ │ │ BlockchainConfig.java
│ │ │ │
│ │ │ ├───controller
│ │ │ │ BlockchainController.java
│ │ │ │
│ │ │ ├───entity
│ │ │ │ Block.java
│ │ │ │ Blockchain.java
│ │ │ │ Transaction.java
│ │ │ │ TransactionPool.java
│ │ │ │
│ │ │ └───helper
│ │ │ HashUtils.java
│ │ │
│ │ └───resources
│ │ │ application.properties
To test the blockchain, you can use Postman or any other API testing tool.
Mine new block by requesting the endpoint http://localhost:1337/blockchain/mine
with a POST request.
Get the blockchain by requesting the endpoint http://localhost:1337/blockchain
with a GET request.
Get a block by index by requesting the endpoint http://localhost:1337/blockchain/{index}
with a GET request.
Add a new transaction by requesting the endpoint http://localhost:1337/blockchain/transaction
with a POST request.
You may need to specify the 'content-type' header as 'application/json' and the body as 'raw' with the following JSON format:
{
"sender": "sender-address",
"recipient": "recipient-address",
"amount": 10
}
Get the transaction pool by requesting the endpoint http://localhost:1337/blockchain/transaction-pool
with a GET request.
Validate the blockchain by requesting the endpoint http://localhost:1337/blockchain/validate
with a GET request.