kokonut

Kokonut πŸ₯₯

High-Performance Modular Blockchain Framework Powered by Kotlin with Proof of Stake

Docker FullNode Docker FuelNode

Kokonut is a lightweight and scalable blockchain framework written in Kotlin. Designed for educational and research purposes, it implements Proof of Stake (PoS) consensus with core blockchain principles (Staking, Validation, Wallets) using an intuitive multi-module architecture.

🌟 Key Features

πŸ“š Project Structure

This project is organized as a Gradle multi-module project, where each module plays a distinct role in the blockchain network.

1. :library (Core)

Contains the core logic and data structures of the blockchain.

2. :fuelnode (Bootstrap Node)

Acts as the network entry point and provides Node Discovery services.

3. :fullnode (Main Node)

The core node that maintains and operates the actual blockchain network.

4. :lightnode (Wallet Client)

A desktop wallet application for users (built with Compose Desktop).


πŸš€ Getting Started

Prerequisites

Build

Run the following command in the project root to build the entire project.

# Windows
./gradlew.bat build

# Mac/Linux
./gradlew build

How to Run

Each node can be run individually. The recommended order is Fuel Node β†’ Full Node (Multiple) β†’ Light Node.

1. Run Fuel Node

./gradlew.bat :fuelnode:run

2. Run Full Node

./gradlew.bat :fullnode:run

3. Run Light Node (Wallet)

./gradlew.bat :lightnode:run

πŸ“‘ API Reference

Full Nodes and the Fuel Node interact via HTTP APIs.

Full Node API

| Method | Endpoint | Description | |:β€”:|:β€”|:β€”| | GET | / | Node status and information dashboard (HTML) | | GET | /getLastBlock | Get the last block of the current chain | | GET | /getChain | Get the entire blockchain data | | GET | /isValid | Check the integrity of the local blockchain | | GET | /getTotalCurrencyVolume | Get the total supply of KNT | | POST | /startMining | Start mining (Miner key required) | | POST | /addBlock | Submit a mined block (Network propagation) |

Fuel Node API

| Method | Endpoint | Description | |:β€”:|:β€”|:β€”| | POST | /submit | Register to participate in the Full Node network | | GET | /getGenesisBlock | Download the Genesis Block data | | GET | /getFullNodes | Get the list of active Full Nodes |


πŸ›  Tech Stack

🀝 Contributing

  1. Fork this repository.
  2. Create a new branch (git checkout -b feature/amazing-feature).
  3. Commit your changes (git commit -m 'Add some amazing feature').
  4. Push to the branch (git push origin feature/amazing-feature).
  5. Open a Pull Request.

License This project is licensed under the MIT License. See the LICENSE file for details.

🐳 Docker Hub & Usage

Official Docker images are available on Docker Hub.

Running with Docker

To ensure data persistence (blockchain data, keys), you must mount a volume to /data.

1. Run Fuel Node

The Fuel Node acts as the network bootstrapper.

# -p 80:80 : Bind container port 80 to host port 80
# -v ./data:/data : Persist blockchain data to host's ./data directory
docker run -d \
  --name knt_fuelnode \
  -p 80:80 \
  -v $(pwd)/data_fuel:/data \
  volta2030/knt_fuelnode

2. Run Full Node

Full Nodes connect to the network. You can specify a peer to connect to using KOKONUT_PEER.

# -e KOKONUT_PEER : Address of a known node (e.g., Fuel Node or another Full Node)
# -v ./data_full:/data : Use a separate data directory for the Full Node
docker run -d \
  --name knt_fullnode \
  -p 8080:80 \
  -e KOKONUT_PEER="http://<FUEL_NODE_IP>:80" \
  -v $(pwd)/data_full:/data \
  volta2030/knt_fullnode

Critical Note: Full Nodes MUST configure KOKONUT_PEER to join an existing network. If KOKONUT_PEER is omitted or the target peer is unreachable, the Full Node will fail to start (throw an exception). This mechanism prevents accidental network splitting (Split Brain). Only the Fuel Node is allowed to start without a peer to generate the Genesis Block.

Note: Replace <FUEL_NODE_IP> with the actual IP address or domain of your Fuel Node. If running on the same machine, use the host’s local network IP.