My forged block #2

Here is another block that links back to a block with a null hash, an alternative block #1. It is the hex form of the block.:

000100000000000000000000000000000000000000000000000000000000000000007359e13bfac8b85740cd1493997ae6a7b7fe40f454336e7fd04e649af8df44ac15905dd0a4ae1a77c024825aab710632c6cfff0a38d52b0dc4dd50a72bc5eeb1d24a8e1b3c02966d9333f96ba31248aad7e35f52bb3e5f0b24b10748ce03161f00000001000000015d442caf000000050001000000000000000000000000000000000000000006736d69746f7000000000

I am pretty sure it’s valid. If not, please let me know.
Here’s how to get a block object out of this:

Nimiq.Block.unserialize(Nimiq.BufferUtils.fromHex("[hex string here]"))

It’s a fairly basic block, with no transactions, and basically no mining difficulty.

Here’s how I made it:

Nimiq.GenesisConfig.main();

const nullHash = Nimiq.Hash.NULL;
const randomHashBlake = Nimiq.Hash.blake2b("smitop");
const randomSha256 = Nimiq.Hash.sha256("smitop");

const interlink = new Nimiq.BlockInterlink([], nullHash);
const interlinkHash = interlink.hash();

const body = new Nimiq.BlockBody(Nimiq.Address.NULL, [], Nimiq.BufferUtils.fromUtf8("smitop"), []);
const bodyHash = body.hash();

const header = new Nimiq.BlockHeader(nullHash, interlinkHash, bodyHash, randomHashBlake, 1, 1, Math.floor(Date.now() / 1000), 5);

const block = new Nimiq.Block(header, interlink, body);

console.log(Nimiq.BufferUtils.toHex(block.serialize()));

1 Like

What would be the use of this in any form? Super interesting that if can be done so easily as well as serialized and deserialized, I’m curious how I and others could use it in our applications. I’m thinking it would only be useful for a miner since I can’t think of anything else that requires building blocks, but maybe it’d be good for building genesis blocks for private testnets? Any other ideas?