curl -s /api/checkpoints?limit=3
curl -s "/api/verify?from=23231001&to=23232000"
const RPC = 'http://127.0.0.1:18545'; // your node
const R = [[10, 7], [7, 5], [8, 6]]; // [BASE, SPREAD] for energy, materials, water
async function block(n) {
const r = await fetch(RPC, { method: 'POST', headers: { 'content-type': 'application/json' },
body: JSON.stringify({ jsonrpc: '2.0', id: 1, method: 'eth_getBlockByNumber', params: ['0x' + n.toString(16), false] }) });
return (await r.json()).result.hash;
}
const from = 23231001, to = 23232000, sum = [0, 0, 0]; // between two checkpoints
for (let n = from; n <= to; n++) {
const h = await block(n);
R.forEach(([b, s], i) => { sum[i] += b + parseInt(h.slice(2 + 2 * i, 4 + 2 * i), 16) % s; });
}
console.log(sum); // = checkpoint(to) − checkpoint(from − 1)