List of Blocks

This page uses a Hashtag List to show all Blocks in a Blockchain.   A Hashtag Form is shown below the Blockchain, allowing New Blocks to be added to the end.   The table is styled using Bootstrap 3 default theme classes, with a custom hash style to truncate the long values.   Hovering the cursor over any truncated value will reveal the original value.   Hovering over the Block # will reveal the Block ID used to generate the Hash.  
# Data Previous Hash Hash Action
1 Genesis 1581479097
834cc91ff6bb2ccd3216736a8efb793569e5b24024072620c71d71dc56de8fab
Validate
2 test
834cc91ff6bb2ccd3216736a8efb793569e5b24024072620c71d71dc56de8fab
d65a72824f84098d5a95584fc07344bc587ba248e947e95d51c28fd11beeb10e
Validate
3 whoa... this works
d65a72824f84098d5a95584fc07344bc587ba248e947e95d51c28fd11beeb10e
b05ecb1e30d87d48bbd4a120cccc70e099f373dfffd8d6903972eeb5a9f786aa
Validate
4 cool
b05ecb1e30d87d48bbd4a120cccc70e099f373dfffd8d6903972eeb5a9f786aa
1c67d5c59bfcf945ebd1791baa79c1cf1e8e8247cb7e3fcbb4f33f3436559131
Validate
5 really?
1c67d5c59bfcf945ebd1791baa79c1cf1e8e8247cb7e3fcbb4f33f3436559131
2db1956157efe0684e62eac5564e4d99b2395f4779cc4b0a8c4d5c5ad680bb7f
Validate
6 so cool
2db1956157efe0684e62eac5564e4d99b2395f4779cc4b0a8c4d5c5ad680bb7f
a0c557c647deaaaf320d356245056ebcd265de2abec8993eb6411246fa6a1957
Validate

Extend Latest Block:  a0c557c647deaaaf320d356245056ebcd265de2abec8993eb6411246fa6a1957


Processed this Hashtag Markup:
<# start list for blockchain;
	sort by instance_id;
#>

<# start header #>
<table class="table table-striped table-hover">
	<thead>
	<tr>
		<th>#</th>
		<th>Data</th>
		<th>Previous Hash</th>
		<th>Hash</th>
		<th>Action</th>
	</tr>
	</thead>
	<tbody>
<# end header #>

<# start row #>
	<tr id="<# hash as html #>">
		<td title="<# id as html #>"><# instance_id #></td>
		<td><# data as html #></td>
		<td><span class="hash" title="<# prev_hash as html #>"><# prev_hash as html #></span></td>
		<td><span class="hash" title="<# hash as html #>"><# hash as html #></span></td>
		<td><a href="validate?hash=<# hash as html #>" class="label label-primary">Validate</a></td>
	</tr>
<# end row #>

<# start footer #>
	</tbody>
</table>
<# set last_block.hash to "<# hash #>"; #>
<# end footer #>

<# start no results #>
<#: no blocks found... create genesis block :#>
<# create record for "blockchain" as "genesis";
	set data to "Genesis <#[system.timestamp]#>";
	set hash to "<# genesis.id #><# genesis.data #>" as hash;
#>
<h4 class="alert alert-success text-center">Genesis Block Created Successfully!</h4>
<# set last_block.hash to "<# genesis.hash #>"; #>
<# end no results #>

<# end list #>
																		
<hr>

<# start form for blockchain; 
	set form.class to "form-inline";
	when creating set prev_hash to "<#[last_block.hash]#>";
	when creating set hash to "<# form.id #><# form.prev_hash #><# form.data #>" as hash;
	when done redirect to "/blockchain/#<# form.prev_hash #>";
#>
	<h4>Extend Latest Block: 
		<span class="label label-default hash" 
			title="<#[last_block.hash as html]#>"><#[last_block.hash as html]#></span>
	</h4>
	<div class="form-group">
		<label for="data">Data</label>
		<input type="text" <# data #> required class="form-control" maxlength="20" id="data">
	</div>
	<input type="submit" <# create button #> class="btn btn-primary" value="Add Block">
<# end form #>


The Blockchain Mini-App uses the Hashtag Markup Language to demonstrate a Blockchain.

Each Block contains a hash of the previous Block, ensuring Blocks can not be altered without invalidating all linked Blocks.  

Blocks are stored in an SQL database.   Methods are provided to create and validate Blocks.