<p>A coinbase transaction is not one that is signed or broadcast to the network. Rather it should be the first transaction in the block that you are mining. Also, the first 4 bytes of the scriptSig must be the block's height (1 byte for pushdata 3 bytes for the height).</p>

CC BY-SA 3.0
2017-08-27T16:22:28.127Z
The result for the command createrawtransaction above is a hex string. FOr create the block I want broadcast, I think I need a transaction id (txid)? Or am I mistaken? If I am not, how I get the txid for the coinbase transaction?
Kleber Mota
CC BY-SA 3.0
2017-08-27T16:39:29.477Z
The txid is the hash of the bytes of the transaction, so you first need to make the hexstring an array of bytes and then hash that with sha256d. The block also contains that transaction, not the txid (the txid is only part of the merkle root), so your block, when you broadcast it, must also contain the transaction itself.
Ava Chow
CC BY-SA 3.0
2017-08-27T23:47:03.180Z
Do you know how to pack the transaction to append to the block? Just create a array with each field and then hash it with sha256d?
Kleber Mota
CC BY-SA 3.0
2017-08-28T01:13:04.177Z
The hash is not included in the block. It is only used for creating the merkle root. The transaction is the hex string that createrawtransaction gives you. You will need to slightly modify it. That hex string is a string representation of the bytes, so you will need to convert it into an array of bytes. Every two characters is one byte.
Ava Chow
CC BY-SA 3.0
2017-08-28T02:17:57.673Z
Not the coinbase transaction, I mean. How pack the transactionS into the block: the ones returned by the `getblocktemplate` command. I already know how to retrieve the data from the json-rpc interface. For calculate the merkle root, I create an array with all txid's.  What other data available I need to use to build de list of transactions for the new block?
Kleber Mota
CC BY-SA 3.0
2017-08-28T03:24:56.990Z
You just need the hex of the transaction which you can get by using getrawtransaction.
Ava Chow
CC BY-SA 3.0
2017-08-27T16:17:08.897Z
2017-08-27T16:17:08.897Z
Ava Chow
<p>I have create a coinbase transaction successfully with the command:</p>

<pre><code>createrawtransaction '[{"txid":"0000000000000000000000000000000000000000000000000000000000000000","vout":0}]' '{"12Evb28oMpkP76HRS2CZ7VjNMD25B84VMv":12.5}'
</code></pre>

<p>what give a hex string for the transaction. But when I try <code>signrawtransaction</code> I got this error:</p>

<pre><code>{
  "hex": "...",
  "complete": false,
  "errors": [
    {
      "txid": "0000000000000000000000000000000000000000000000000000000000000000",
      "vout": 0,
      "scriptSig": "",
      "sequence": ...,
      "error": "Input not found or already spent"
    }
  ]
}
</code></pre>

<p>with <code>sendrawtransactions</code> i got:</p>

<pre><code>Missing inputs (code -25)
</code></pre>

<p>what I have to do with this transaction after create it?</p>

<transactions><json-rpc><coinbase-transaction><transaction-id>
After creation, what I have to do with a coinbase transaction?
Kleber Mota
# After creation, what I have to do with a coinbase transaction?

(Asked by: username_0 on 2017-08-27)

I have create a coinbase transaction successfully with the command:

```
createrawtransaction '[{"txid":"0000000000000000000000000000000000000000000000000000000000000000","vout":0}]' '{"12Evb28oMpkP76HRS2CZ7VjNMD25B84VMv":12.5}'

```

what give a hex string for the transaction. But when I try `signrawtransaction` I got this error:

```
{
  "hex": "...",
  "complete": false,
  "errors": [
    {
      "txid": "0000000000000000000000000000000000000000000000000000000000000000",
      "vout": 0,
      "scriptSig": "",
      "sequence": ...,
      "error": "Input not found or already spent"
    }
  ]
}

```

with `sendrawtransactions` i got:

```
Missing inputs (code -25)

```

what I have to do with this transaction after create it?

**Tags:** transactions, json-rpc, coinbase-transaction, transaction-id


---

## 1 answers

### Answer by username_1 on 2017-08-27. Score: 1 | Accepted answer

A coinbase transaction is not one that is signed or broadcast to the network. Rather it should be the first transaction in the block that you are mining. Also, the first 4 bytes of the scriptSig must be the block's height (1 byte for pushdata 3 bytes for the height).

> **Comments:**
> **username_0**: The result for the command createrawtransaction above is a hex string. FOr create the block I want broadcast, I think I need a transaction id (txid)? Or am I mistaken? If I am not, how I get the txid for the coinbase transaction?  
> **username_1**: The txid is the hash of the bytes of the transaction, so you first need to make the hexstring an array of bytes and then hash that with sha256d. The block also contains that transaction, not the txid (the txid is only part of the merkle root), so your block, when you broadcast it, must also contain the transaction itself.  
> **username_0**: Do you know how to pack the transaction to append to the block? Just create a array with each field and then hash it with sha256d?  
> **username_1**: The hash is not included in the block. It is only used for creating the merkle root. The transaction is the hex string that createrawtransaction gives you. You will need to slightly modify it. That hex string is a string representation of the bytes, so you will need to convert it into an array of bytes. Every two characters is one byte.  
> **username_0**: Not the coinbase transaction, I mean. How pack the transactionS into the block: the ones returned by the `getblocktemplate` command. I already know how to retrieve the data from the json-rpc interface. For calculate the merkle root, I create an array with all txid's.  What other data available I need to use to build de list of transactions for the new block?  
> **username_1**: You just need the hex of the transaction which you can get by using getrawtransaction.  

---

