<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Blocks | Gradecoin </title>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<style>
:root {
/* Primary theme color */
--primary-color: #F8D12F;
/* Primary theme text color */
--primary-text-color: #1E2329;
/* Primary theme link color */
--primary-link-color: #2F57F7;
/* Secondary color: the background body color */
--secondary-color: #FAFAFA;
--secondary-text-color: #303030;
/* Highlight text color of table of content */
--toc-highlight-text-color: #d46e13;
}
</style>
<link href="https://fonts.googleapis.com/css?family=Alfa+Slab+One&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Fira+Sans:400,500,600&display=swap" rel="stylesheet">
<link rel="stylesheet" href="/normalize.css">
<link rel="stylesheet" href="https://gradecoin.xyz/juice.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css" />
<link rel="stylesheet" href="/site.css" />
</head>
<body>
<header class="box-shadow">
<a href="https://gradecoin.xyz/">
<div class="logo">
<img src="https://gradecoin.xyz/gradecoin.png" alt="logo">
Gradecoin
</div>
</a>
<nav>
<a class="nav-item subtitle-text" href="https://gradecoin.xyz/register-docs/">Register</a>
<a class="nav-item subtitle-text" href="https://gradecoin.xyz/jwt/">JWT</a>
<a class="nav-item subtitle-text" href="https://gradecoin.xyz/transaction-docs/">Transactions</a>
<a class="nav-item subtitle-text" href="https://gradecoin.xyz/block-docs/">Blocks</a>
<a class="nav-item subtitle-text" href="https://github.com/zhuowei/nft_ptr#why">why?</a>
</nav>
</header>
<main>
<div class="toc">
<div class="toc-sticky">
<div class="toc-item">
<a class="subtext" href="https://gradecoin.xyz/block-docs/#requests">Requests</a>
</div>
<div class="toc-item-child">
<a class="subtext" href="https://gradecoin.xyz/block-docs/#get"><small>- GET</small></a>
</div>
<div class="toc-item-child">
<a class="subtext" href="https://gradecoin.xyz/block-docs/#post"><small>- POST</small></a>
</div>
<div class="toc-item">
<a class="subtext" href="https://gradecoin.xyz/block-docs/#fields">Fields</a>
</div>
<div class="toc-item">
<a class="subtext" href="https://gradecoin.xyz/block-docs/#hash">Hash</a>
</div>
</div>
</div>
<div class="content text">
<div class="heading-text">Block Documentation</div>
<p>A block that was proposed to commit Transactions in <code>transaction_list</code> to the
ledger with a nonce that made <code>hash</code> valid; 6 zeroes at the left hand side of the
hash (24 bytes).</p>
<p>We are <em>mining</em> using <a href="https://www.blake2.net/">blake2s</a> algorithm, which produces 256 bit hashes. Hash/second is roughly 20x10^3 on my machine, a new block can be mined in around 4-6 minutes.</p>
<h1 id="requests">Requests</h1>
<h2 id="get">GET</h2>
<p>A HTTP <code>GET</code> request to <a href="/block">/block</a> endpoint will return the latest mined block.</p>
<h2 id="post">POST</h2>
<p>A HTTP <code>POST</code> request with Authorization using JWT will allow you to propose your own blocks.</p>
<h1 id="fields">Fields</h1>
<pre style="background-color:#ffffff;">
<code><span style="color:#545052;">transaction_list: [array of Fingerprints]
nonce: unsigned 32-bit integer
timestamp: ISO 8601 <date>T<time>
hash: String
</span></code></pre><h1 id="hash">Hash</h1>
<p><code>tha</code> field in <a href="/jwt">jwt documentation</a> in fact stands for "The Hash", in the case of a post request for a block, you need to use hash field of the block. </p>
<p><a href="https://en.wikipedia.org/wiki/ISO_8601#Combined_date_and_time_representations">ISO 8601 Reference</a></p>
</div>
</main>
<footer>
Built For ⁂ CENG489 ⁂ Introduction to Computer Security
</footer>
</body>
<script>
function highlightNav(heading) {
let pathname = location.pathname;
document.querySelectorAll(".toc a").forEach((item) => {
item.classList.remove("active");
});
document.querySelector(".toc a[href$='" + pathname + "#" + heading + "']").classList.add("active");
}
let currentHeading = "";
window.onscroll = function () {
let h = document.querySelectorAll("h1,h2,h3,h4,h5,h6");
let elementArr = [];
h.forEach(item => {
if (item.id !== "") {
elementArr[item.id] = item.getBoundingClientRect().top;
}
});
elementArr.sort();
for (let key in elementArr) {
if (!elementArr.hasOwnProperty(key)) {
continue;
}
if (elementArr[key] > 0 && elementArr[key] < 300) {
if (currentHeading !== key) {
highlightNav(key);
currentHeading = key;
}
break;
}
}
}
</script>
</html>