https://github.com/kofj/naivechain
A naive and simple implementation of blockchains.
https://github.com/kofj/naivechain
blockchain golang naivechain
Last synced: about 1 year ago
JSON representation
A naive and simple implementation of blockchains.
- Host: GitHub
- URL: https://github.com/kofj/naivechain
- Owner: kofj
- License: mit
- Created: 2017-04-13T14:56:27.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-04-20T12:32:32.000Z (about 9 years ago)
- Last Synced: 2025-04-02T11:44:45.554Z (about 1 year ago)
- Topics: blockchain, golang, naivechain
- Language: Go
- Size: 3.91 KB
- Stars: 329
- Watchers: 16
- Forks: 90
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-block - **Go**: _NaiveChain - A naive and simple implementation of blockchains_
- awesome-blockchain - **Go**: _NaiveChain - A naive and simple implementation of blockchains_
- awesome-blockchain - **Go**: _NaiveChain - A naive and simple implementation of blockchains_
README
# naivechain
A naive and simple implementation of blockchains.
### Build And Run
- Download and compile **go get -v github.com/kofj/naivechain**
- Start First Node
```bash
naivechain -peers ""
```
- Start Second Node
```bash
naivechain -api :3002 -p2p :6002 -peers ws://localhost:6001
```
### HTTP API
- query blocks
```
curl http://localhost:3001/blocks
```
- mine block
```
curl -H "Content-type:application/json" --data '{"data" : "Some data to the first block"}' http://localhost:3001/mine_block
```
- add peer
```
curl -H "Content-type:application/json" --data '{"peer" : "ws://localhost:6002"}' http://localhost:3001/add_peer
```
- query peers
```
curl http://localhost:3001/peers
```