This resource states that "data": "hex",(string, required) A key-value pair. The key must be "data", the value is hex-encoded data.


  1. It says that the field is "required" but what exactly should that data be ??
  2. If the data isn't provided does that invalidate the coinbase transaction (even when block height is encoded into scriptSig)?

I asked the question here but an answer wasn't provided. So I decided to make it a stand-alone question.


  1. To confirm what data should be inserted within this data field

1 Answer 1


The data field is only for when you want to create data-carrying transactions (ones with an OP_RETURN). This is generally not needed in normal transactions (and its usage there is somewhat controversial even). For coinbase transactions, you do need an OP_RETURN output with the witness commitment as specified in BIP141, if you want to include segwit transactions in your block.

However, you shouldn't use createrawtransaction and related RPCs for constructing coinbase transactions, as they will miss the necessary scriptSig contents. Even if you could, it would most likely be so slow as to be useless (a modern miner like an AntMiner S17 needs 13000 coinbases per second). Thus, the miner firmware constructs them using hardcoded logic.

The field is marked as required in the RPC documentation for such outputs. If you don't want a data-carrying output, the object simply wouldn't exist.

  • So the "data" needed is the string "OP_RETURN"? Dec 12, 2021 at 3:32
  • 1
    No, the data is whatever you want it to be, and in your case, you don't want it at all. If used, createrawtransaction uses an OP_RETURN-based scriptPubKey to encode it in the transaction. But again, this is completely unrelated to anything you're trying to do. Dec 12, 2021 at 3:41
  • Thanks Pieter....... I wish you'd always be online to help me out.....Cheers Dec 12, 2021 at 14:35

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.