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 1610907346
65a150c55711c8bbb07ab00a20313f4bde518d7a0fece32b60195c4e8ff52265
Validate
2 new value
65a150c55711c8bbb07ab00a20313f4bde518d7a0fece32b60195c4e8ff52265
1ac7f8e9975c9a9de88b76a1b703299d047f77b6adb2a0b7aa090df6649a56cf
Validate
3 add something
1ac7f8e9975c9a9de88b76a1b703299d047f77b6adb2a0b7aa090df6649a56cf
a0aa7d54272a067e3f8d8a0394338cd46e4a8c2bc4245e0c0bb6e97f4ff76ac6
Validate
4 whoa
a0aa7d54272a067e3f8d8a0394338cd46e4a8c2bc4245e0c0bb6e97f4ff76ac6
5c47891b568ce33d3d5442b1053fee1854b3e8f22e65b7fa1449ad46be5a4254
Validate
5 this easy?
5c47891b568ce33d3d5442b1053fee1854b3e8f22e65b7fa1449ad46be5a4254
f9c98946c4e603464063fb557ba325c022cef20cee733f849da3197839b0f58c
Validate
6 hi?
f9c98946c4e603464063fb557ba325c022cef20cee733f849da3197839b0f58c
11f9ed14eb095d47d92e15b55ce7a9246c18273b20e88e2b3f36049718a5c978
Validate
7 NFT!!
11f9ed14eb095d47d92e15b55ce7a9246c18273b20e88e2b3f36049718a5c978
9ed4478319a3dde1d3366ff8cc2ef689f9f85355117f6ae4ba7a3a2ca0bd3929
Validate

Extend Latest Block:  9ed4478319a3dde1d3366ff8cc2ef689f9f85355117f6ae4ba7a3a2ca0bd3929


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.