1. Go to this page and download the library: Download danc0/dmerkle 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/ */
danc0 / dmerkle example snippets
$transactions_to_hash = [
['foo'],
['bar']
];
use DMerkle\DMerkle;
$previous_block_hash = '123456bcdef';
$DMerkle = new DMerkle($previous_block_hash);
// Data from your queue in groups equal to your max block size
$transactions = [ ... ];
// Change the default block size
$DMerkle->max_block_size = 50;
// Pass a block of no more than 50 transactions
$DMerkle->setBlockData($transactions);
// Run the hashes
$DMerkle->runBlockCalculation();
// Get block data
$block_data = $DMerkle->createBlockData();
use DMerkle\DMerkle_Block;
$block_data_from_hashing = [ ... ]; // loaded from your db somewhere
$transaction_data = [ ... ]; // loaded from your db, data used when creating blocks
$root_hash = '...'; // loaded from your db
$DMerkle_Block = new DMerkle_Block($block_data_from_hashing);
$transaction_is_valid = $block->transactionIsPartOfBlock($transaction_data, $root_hash);
use DMerkle\DMerkle_Block;
$old_block = new DMerkle_Block($old_block_data);
$old_block_hash = $old_block->getBlockHash();
$current_block = new DMerkle_Block($current_block_data);
$old_block_hash_is_valid = $current_block->previousBlockHashIsValid($old_block_hash, $current_block_stored_hash)
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.