https://github.com/tkc/naivechain
implementation of a simple block chain for learning.
https://github.com/tkc/naivechain
blockchain blockchain-demo blockchain-demos blockchain-network
Last synced: about 2 months ago
JSON representation
implementation of a simple block chain for learning.
- Host: GitHub
- URL: https://github.com/tkc/naivechain
- Owner: tkc
- Created: 2018-04-23T15:35:31.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-05-01T03:30:15.000Z (about 8 years ago)
- Last Synced: 2025-12-28T11:07:03.922Z (6 months ago)
- Topics: blockchain, blockchain-demo, blockchain-demos, blockchain-network
- Language: Go
- Homepage:
- Size: 9.77 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# naivechain
a simple Blockchain inspired by https://github.com/kofj/naivechain
Implementation of a simple block chain for learning.
## Run First Node
```bash
go run main.go
```
## Run Second Node
```bash
go run main.go -api :3002 -p2p :6002 -peers ws://localhost:6001
```
## Show blocks
```bash
$ curl http://localhost:3001/blocks
```
## Mine block
```bash
$ curl -H "Content-type:application/json" --data '{"data" : "Some data to the first block"}' http://localhost:3001/mine_block
```
## Add peer
```bash
$ curl -H "Content-type:application/json" --data '{"peer" : "ws://localhost:6002"}' http://localhost:3001/add_peer
```
## Query peers
```bash
$ curl http://localhost:3001/peers
```