Skip to content

📚✨Quick look the Blockchain algorithm

License

Notifications You must be signed in to change notification settings

mayoz/blockchain-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Blockchain

Let's start by creating a new simple example for understanding the cycle:

use Mayoz\Blockchain\Blockchain;
use Mayoz\Blockchain\Transaction;

// create main blockchain instance
$blockchain = new Blockchain;

// add new transactions to pending chain
$blockchain->transaction(new Transaction('foo', 'bar', 10));
$blockchain->transaction(new Transaction('foo', 'baz', 20));

// mine the pending chain
$block = $blockchain->mine('miner-address');

var_dump($block->hash);

// add new transactions to new pending chain
$blockchain->transaction(new Transaction('baz', 'bar', 15));

// and mine it
$block = $blockchain->mine('miner-address');

var_dump($block->hash);

For more information about Blockchain, please watch this video.

Testing

You will need an install of Composer before continuing.

First, install the dependencies:

$ composer install

Then run PHPUnit:

$ vendor/bin/phpunit

License

The MIT License (MIT). Please see License File for more information.

About

📚✨Quick look the Blockchain algorithm

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages