PHP code example of jurruh / blockchain

1. Go to this page and download the library: Download jurruh/blockchain library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

jurruh / blockchain example snippets


//Create the chain
$chain = new \Blockchain\Chain();

//Add some blocks to te chain
$firstBlock = new \Blockchain\Block(0, null, time(), 'Example data 1');
$chain->addBlock($firstBlock);

$secondBlock = new \Blockchain\Block(1, $firstBlock->getHash(), time(), 'Example data 2');
$chain->addBlock($secondBlock);

//Check if valid
if($chain->isValid()){
    //The chain is valid
}