Thanks to visit codestin.com
Credit goes to github.com

Skip to content

zsimon2016/php-blockchain

 
 

Repository files navigation

Blockchain implementation in PHP

Minimum PHP Version Build Status License

Clean code approach to blockchain technology. Learn blockchain by reading source code.

Roadmap

  • Block structure and hashing
  • Genesis block
  • Storing and validate Blockchain
  • Proof of Work with difficulty (missing consensus on the difficulty)
  • Communicating with other nodes & controlling the node (based on ReactPHP)
  • Simple persistence layer
  • Going serverless with AWS Lambda (experiment)
  • Start working on KondasCoin akondas/coin 🚀 (Transactions, Wallet, Transaction relaying, Maybe some UI)

Node

To start the node:

bin/node

Default web server port is 8080 but you can change it with --http-port param:

bin/node --http-port=9090

Default p2p server port is 3030 but you can change it with --p2p-port param:

bin/node --p2p-port=2020

API

To control node you can use simple (pseudo) REST API:

[GET] /blocks Response (list of all blocks):

[{"index":0,"hash":"8b31c9ec8c2df21968aca3edd2bda8fc77ed45b0b3bc8bc39fa27d5c795bc829","previousHash":"","createdAt":"2018-02-23 23:59:59","data":"PHP is awesome!","difficulty":0,"nonce":0}]

[POST] /mine Request (raw):

Data to mine (any string).

Response (mined block):

{"index":1,"hash":"a6eba6325a677802536337dc83268e524ffae5dc7db0950c98ff970846118f80","previousHash":"8b31c9ec8c2df21968aca3edd2bda8fc77ed45b0b3bc8bc39fa27d5c795bc829","createdAt":"2018-03-13 22:37:07","data":"Something goof","difficulty":0,"nonce":0}

[GET] /peers Response (list of all connected peers):

[{"host":"127.0.0.1","port":3131}]

[POST] /peers/add Request (json with peer):

{"host":"127.0.0.1", "port":"3131"}

Response: 204 (empty)

Tests

To run test suite:

composer tests

Coding standards

Checkers and fixers are in coding-standard.neon. To run:

composer fix-cs

License

php-blockchain is released under the MIT Licence. See the bundled LICENSE file for details.

Author

Arkadiusz Kondas (@ArkadiuszKondas)

Blockchain用PHP实现

最小PHP版本构建状态许可

区块链技术的干净代码方法。通过阅读源代码来学习区块链。 路线图

块结构和散列 创世纪块 存储和验证区块链 有困难的工作证明(在困难上缺少共识) 与其他节点通信并控制节点(基于php) 简单的持久层 用AWS Lambda去服务器(实验) 开始开发KondasCoin akondas/coin rocket(事务、钱包、事务中继,可能是一些UI)

Node

To start the node:

bin/node

Default web server port is 8080 but you can change it with --http-port param:

bin/node --http-port=9090

Default p2p server port is 3030 but you can change it with --p2p-port param:

bin/node --p2p-port=2020

API

To control node you can use simple (pseudo) REST API:

[GET] /blocks Response (list of all blocks):

[{"index":0,"hash":"8b31c9ec8c2df21968aca3edd2bda8fc77ed45b0b3bc8bc39fa27d5c795bc829","previousHash":"","createdAt":"2018-02-23 23:59:59","data":"PHP is awesome!","difficulty":0,"nonce":0}]

[POST] /mine Request (raw):

Data to mine (any string).

Response (mined block):

{"index":1,"hash":"a6eba6325a677802536337dc83268e524ffae5dc7db0950c98ff970846118f80","previousHash":"8b31c9ec8c2df21968aca3edd2bda8fc77ed45b0b3bc8bc39fa27d5c795bc829","createdAt":"2018-03-13 22:37:07","data":"Something goof","difficulty":0,"nonce":0}

[GET] /peers Response (list of all connected peers):

[{"host":"127.0.0.1","port":3131}]

[POST] /peers/add Request (json with peer):

{"host":"127.0.0.1", "port":"3131"}

Response: 204 (empty) Tests

To run test suite:

composer tests

Coding standards

Checkers and fixers are in coding-standard.neon. To run:

composer fix-cs

License

php-blockchain is released under the MIT Licence. See the bundled LICENSE file for details. Author

Arkadiusz Kondas (@ArkadiuszKondas)

About

微型区块链系统

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%