A simple implementation of a blockchain using the PHP programming language. It still has far to go and contributions are welcomed.
composer require davidngugi/php-blockchain
php vendor/phpunit/phpunit/phpunit
The PHPBlockchain\TestBlockchain::class has a basic working implementation of this blockchain. It shows how you can add transactions to the blockchain.
Run it from the terminal:
php src/TestBlockchain.php
Example,
$blockchain = new TestBlockchain;
$blockchain->addNewTransaction('David', 'Dan', 200);
$blockchain->addNewTransaction('Dan', 'David', 100);
$blockchain->display();
$transactions = [
['David', 'Dan', 200],
['Dan', 'David', 100],
['Cynthia', 'David', 50],
['Martin', 'David', 100]
];
$blockchain->addManyTransactions($transactions);
$blockchain->display();
- Add more Tests for the Blockchain
- Improve the Proof-of-Work (PoW) algorithm or evaluate whether to switch to a Proof-of-Stake (PoS) is worth it
- Add Address class
- Design changes
- Clean up for publishing to packagist
All contributions (big or small) are highly welcomed.
- Fork the project
- Open an issue on this repo
- Work out a solution on your fork and ensure all tests run successfully
- Send a PR associated with the issue you opened
- PR will be evaluated and if approved, merged into the project and the issue closed
It's as simple as that! :)
- David Ngugi [email protected]
If you would love to support the continuous development and maintenance of this package, please consider buying me a coffee.
This package is open-sourced software licensed under the MIT Licence