one-chain
minimal blockchain ever.
Assist you to develop blockchain core easily.
2018 OSS Grand Developers Challenge Award
Based on the following code: lhartikk/naivechain
Abstract
As Blockchain-based service grew, so need of open source which assists developing blockchain core was drived. Although there are some open source projects like Bitcoin and Ethereum, those are difficult to learn to use.
You can gently solve the above problems by using
one-chain
, simple implementation of blockchain core.
The one-chain is modularized by function—network, core, transaction, wallet, etc.— to achieve clarity.
Also, detail comments and documents are provided for studying and easy reusing.
Most of the code is written in a pseudo-code style to provide understanding by other language developers.
Details
Use-case
Blockchain Policy Simulator
edu-chain
How to Start
Environments
- Node.js v8.11.3 (>=4.3.2)
- cURL 7.55.1 or Postman v6.4.4
install packages
npm install
start node #1
npm start
start node #2
$env:HTTP_PORT=3002
or
export HTTP_PORT=3002
$env:P2P_PORT=6002
or
export P2P_PORT=6002
optionally
$env:PEERS="ws://127.0.0.1:6001"
or
export PEERS="ws://127.0.0.1:6001"
npm start
start node #3
$env:HTTP_PORT=3003
or
export HTTP_PORT=3003
$env:P2P_PORT=6003
or
export P2P_PORT=6003
optionally
$env:PEERS="ws://127.0.0.1:6001, ws://127.0.0.1:6002"
or
export PEERS="ws://127.0.0.1:6001, ws://127.0.0.1:6002"
npm start
How to Use
Click on the image above to play the video.
Get blockchain
curl http://127.0.0.1:3001/blocks
Add new block
curl -X POST http://127.0.0.1:3001/mineBlock
curl -H "Content-type:application/json" --data "{\"data\" : \"Anything you want\"}" http://127.0.0.1:3001/mineBlock
Get connected peers
curl http://127.0.0.1:3001/peers
Add peer
curl -H "Content-type:application/json" --data "{\"peer\" : \"ws://127.0.0.1:6002\"}" http://127.0.0.1:3001/addPeer
Get Address
curl http://127.0.0.1:3001/address
Create Wallet
curl -X POST http://127.0.0.1:3001/createWallet
Delete Wallet
curl -X POST http://127.0.0.1:3001/deleteWallet
Stop
curl -X POST http://127.0.0.1:3001/stop
License
The onechain project is licensed under the Apache License, Version 2.0, also included in our repository in the LICENSE file.