Skip to content

Commit 8c77b89

Browse files
docs: clean up and rewrite README with clear instructions
1 parent eb8e75d commit 8c77b89

1 file changed

Lines changed: 69 additions & 28 deletions

File tree

README.md

Lines changed: 69 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -77,29 +77,68 @@ MiniChain is a minimal fully functional blockchain implemented in Python.
7777
implementing MiniChain in Python aligns with MiniChain's educational goal.
7878

7979

80-
### Overview of Tasks
80+
### Resources
8181

82-
* Develop a fully functional minimal blockchain in Python, with all the expected components:
83-
peer-to-peer networking, consensus, mempool, ledger, ...
82+
* Read this book: https://www.marabu.dev/blockchain-foundations.pdf
8483

85-
* Bonus task: add smart contracts to the blockchain.
84+
---
8685

87-
Candidates are expected to refine these tasks in their GSoC proposals.
88-
It is encouraged that you develop an initial prototype during the application phase.
86+
## Getting Started
8987

90-
### Requirements
88+
### Prerequisites
9189

92-
* Use [PyNaCl](https://pynacl.readthedocs.io/en/latest/) library for hashing, signing transactions and verifying signatures.
93-
* Use [Py-libp2p](https://github.com/libp2p/py-libp2p/tree/main) for p2p networking.
94-
* Implement Proof-of-Work as the consensus protocol.
95-
* Use accounts (instead of UTxO) as the accounting model for the ledger.
96-
* Use as few lines of code as possible without compromising readability and understandability.
97-
* For the bonus task, make Python itself be the language used for smart contracts, but watch out for security concerns related to executing arbitrary code from untrusted sources.
90+
- Python 3.10+
91+
- Install dependencies:
92+
```bash
93+
pip install -r requirements.txt
94+
```
95+
96+
### 1. Creating a New MiniChain
97+
To bootstrap a brand new blockchain network from scratch, simply start a node. By default, this creates a new Genesis block.
98+
```bash
99+
python main.py --port 9000 --datadir ./node1_data
100+
```
101+
*Note: Keep this terminal open to interact with the node via the CLI.*
102+
103+
### 2. Connecting to an Existing Chain
104+
To connect a secondary node to the network, start a new instance on a different port and point it to the seed node using the `--connect` flag.
105+
```bash
106+
python main.py --port 9001 --connect 127.0.0.1:9000 --datadir ./node2_data
107+
```
108+
The node will automatically sync the blockchain state via the P2P network using the Fork-Choice rule.
109+
110+
### 3. Mining Blocks
111+
To confirm pending transactions, you need to mine blocks. In the interactive CLI of your node, simply type:
112+
```text
113+
minichain> mine
114+
```
115+
This runs the Proof-of-Work algorithm, validates transactions, computes the new state root, updates your wallet with the block reward + fees, and broadcasts the block to all connected peers.
98116

99-
### Resources
117+
---
100118

101-
* Read this book: https://www.marabu.dev/blockchain-foundations.pdf
119+
## Basic Operations (Interactive CLI)
120+
121+
Once your node is running, you can perform basic blockchain operations directly in your terminal.
102122

123+
**Making a Transfer**
124+
Send coins to another public key:
125+
```text
126+
minichain> send <receiver_address> <amount> <fee>
127+
```
128+
*Example: `send 8b3401abedb875aff7279b5ab58cb9a0c... 100 1`*
129+
130+
**Checking Balances**
131+
View the state of all active accounts and contracts on the chain:
132+
```text
133+
minichain> balance
134+
```
135+
136+
**Viewing Network State**
137+
```text
138+
minichain> chain # View all blocks
139+
minichain> peers # View connected P2P nodes
140+
minichain> address # View your own public key
141+
```
103142

104143
---
105144

@@ -118,26 +157,28 @@ Check out the `/examples` directory for tutorials:
118157

119158
### Interacting via CLI
120159
Start the interactive node using `python main.py` and use the following commands:
121-
1. **Deploy:** `deploy <filepath> [amount] [gas_limit]`
122-
2. **Call:** `call <contract_address> <payload> [amount] [gas_limit]`
123-
124-
---
160+
1. **Deploy:** `deploy <filepath> [amount] [fee]`
161+
2. **Call:** `call <contract_address> <payload> [amount] [fee]`
125162

126-
## Tech Stack
127-
128-
TODO:
163+
Example deployment:
164+
```text
165+
minichain> deploy examples/counter.py 0 100
166+
```
129167

130168
---
131169

132-
## Getting Started
133-
134-
### Prerequisites
170+
## JSON-RPC 2.0 Server
135171

136-
TODO
172+
MiniChain automatically spins up a JSON-RPC 2.0 server alongside the P2P node. By default, it binds to `port 8545` (the standard EVM RPC port). External wallets and dApps can use this to interact with the chain asynchronously.
137173

138-
### Installation
174+
**Example Request (Get Block Number):**
175+
```bash
176+
curl -X POST http://127.0.0.1:8545/ \
177+
-H "Content-Type: application/json" \
178+
-d '{"jsonrpc": "2.0", "method": "mc_blockNumber", "id": 1}'
179+
```
139180

140-
TODO
181+
Available endpoints include: `mc_blockNumber`, `mc_getBlockByNumber`, `mc_getBalance`, and `mc_sendTransaction`.
141182

142183
---
143184

0 commit comments

Comments
 (0)