Skip to content

Instantly share code, notes, and snippets.

@gwmccubbin
Last active April 3, 2018 16:26
Show Gist options
  • Save gwmccubbin/d323bddd71d4ca9b0980e368ff7235a2 to your computer and use it in GitHub Desktop.
Save gwmccubbin/d323bddd71d4ca9b0980e368ff7235a2 to your computer and use it in GitHub Desktop.
Build a Blockchain Explorer with Quiknode.io | Ethereum dApp Tutorial
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>QuikNode Explorer</title>
<!-- Bootstrap -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<!-- Styles -->
<style>
body {
padding-top: 15px;
}
h1 {
margin: 15px 0px;
}
</style>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-lg-12 text-center" >
<!-- Link to logo file here from full project -->
<img src="img/logo.png" alt="logo">
<h1>QuikNode Explorer</h1>
<table class="table">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Hash</th>
<th scope="col">Timestamp</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
</div>
<!-- Bootstrap -->
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<!-- Web3 - Link to web3 js file from full project -->
<script src="js/web3.min.js"></script>
<script>
var provider = ''; // Add your quiknode HTTP provider link here
var web3Provider = new Web3.providers.HttpProvider(provider);
var web3 = new Web3(web3Provider);
var latestBlock = web3.eth.blockNumber;
// List blocks in table
for (var i = 0; i < 10; i++) {
var block = web3.eth.getBlock(latestBlock - i);
var number = block.number;
var hash = block.hash;
var time = block.timestamp;
$('tbody').append("<tr><td>" + number + "</td><td>" + hash + "</td><td>" + time + "</td></tr>");
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment