After mining a correct nonce on the block template (received from rpc method "getblocktemplate") you need to submit the block back to the daemon. However, the rpc method "submitblock" appears to require the entire block blob. The template does not contain the entire block, just the parts necessary for mining. And I dont see any way to derive the full block information from the template to create the block blob.

So how do I mine on the template and then submit the full block back to the daemon?

1 Answer 1


The getbklocktemplate RPC returns a blockhashing_blob and a blocktemplate_blob.

You can either try to find a nonce (4 bytes) by mining using the blockhashing_blob, or you can try to find two nonces (4 bytes in the block header, reserved_size bytes in the extra field of the mining reward transaction) using the blocktemplate_blob and computing the transaction Merkle tree yourself.

When your nonce(s) pass the difficulty test, you put it/them in the blocktemplate_blob at the right offset(s) and you send the updated blocktemplate_blob to the daemon using the submitblock RPC.

  • I checked the source code for monerod, the submit block code calls cryptonote_format_utils.parse_and_validate_block_from_blob. I dont think that method can handle parsing a template/hashing blob? It appears that it wants a block header or full block blob? Nov 6, 2017 at 13:07
  • The blocktemplate_blob is a block header.
    – glv
    Nov 6, 2017 at 18:18
  • Block headers do not contain a tree root hash (per the source code at least), and the tree root hash is part of the hashing blob. Edit: The tree hash is tacked onto the end. So when the code parses the blob, its going to attempt to parse an entire block, and then run into the tree hash, right? Nov 6, 2017 at 18:20
  • The blockhashing_blob contains the transaction tree hash root (because it's a preprocessed block header), but the blocktemplate_blob doesn't (because it is a raw block header). When you submit the blocktemplate_blob updated with your nonce, the daemon processes it, check if it is valid and sends it to the network if it is.
    – glv
    Nov 6, 2017 at 18:32
  • Ah okay, so there is some of my confusion. When you say "raw block header" you're actually talking about the entire block (in source code terms), because the block header (in source terms) is a small part of the block comprised of only major, minor, time, prev, nonce. The value of the template is actually an entire block struct, and so it parses correctly. Nov 6, 2017 at 19:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.