§ 05 · Transactions
Coinbase transaction
The transaction that creates new coins
On this page 8 sections
The coinbaseCoinbase transaction: The first transaction in every block. It has no real inputs: it creates the block's new PRL and pays them, plus the fees, to the miner. is the transaction a miner writes to pay themselves. It’s always the first transaction in a block, and it’s the only one allowed to create coins out of nothing.
It looks like any other transaction, with three twists: its input points at nothing, its scriptSig carries the block height and whatever else the miner wants, and, in any block with witness data, one of its outputs commits to all the block’s witnesses. Here is a real one, from block 130,825, mined by the Kryptex pool.
Try it
What does a coinbase look like?
| Field | Bytes | Value |
|---|---|---|
| Version version | 4 @0 | 2 int32 little-endian. Pearl wallets and pearld coinbases use version 1; relay policy accepts 1-2. |
| Marker marker | 1 @4 | 0x00 Segwit marker (BIP-144): says witness data follows the outputs. |
| Flag flag | 1 @5 | 0x01 Witness flag; 0x01 is the only value Pearl accepts. |
| Input count vin.length | 1 @6 | 1 CompactSize number of inputs. |
| Previous txid vin[0].txid | 32 @7 | 0000000000000000000000000000000000000000000000000000000000000000 All zeros: this input creates new coins (coinbase). |
| Output index vin[0].vout | 4 @39 | 0xffffffff 0xffffffff together with a zero txid marks a coinbase. |
| scriptSig length vin[0].scriptSig.length | 1 @43 | 39 CompactSize length of the scriptSig. |
| Coinbase script vin[0].scriptSig | 39 @44 | 0309ff01048393d76a2f706f6f6c2e6b7279707465782e636f6d2f1550cad31e016e7bf00f2ecb Coinbase data. It starts with the block height 130825 (BIP-34, required in every Pearl block), then anything the miner likes. |
| Sequence vin[0].sequence | 4 @83 | 0xffffffff Final (0xffffffff): no RBF signal, no relative locktime, and locktime is ignored for this input. Pearl wallets use this. |
| Output count vout.length | 1 @87 | 2 CompactSize number of outputs. |
| Amount vout[0].value | 8 @88 | 223,838,373,068 grains (2238.38373068 PRL) int64 little-endian, in grains (1 PRL = 100,000,000 grains). |
| Script length vout[0].scriptPubKey.length | 1 @96 | 34 CompactSize length of the locking script. |
| Locking script vout[0].scriptPubKey | 34 @97 | prl1puv0gqv4x0wd0ylwz086y3sqrg4a6umza9r08aecehjrmdqq7mctsmqaqsh OP_1 OP_PUSHBYTES_32 <output key Q>: a Taproot output. |
| Amount vout[1].value | 8 @131 | 0 grains (0.00000000 PRL) int64 little-endian, in grains (1 PRL = 100,000,000 grains). |
| Script length vout[1].scriptPubKey.length | 1 @139 | 38 CompactSize length of the locking script. |
| Locking script vout[1].scriptPubKey | 38 @140 | witness commitment 78cc1a61dcfcee9c59ddd9f4d56a98764c071e077bcc36fe9d1cf0aad50ebac3 OP_RETURN aa21a9ed ‖ SHA256d(witness Merkle root ‖ nonce): the BIP-141 witness commitment. |
| Witness items witness[0].length | 1 @178 | 1 Number of witness stack items for input 0. |
| Witness reserved value length witness[0][0].length | 1 @179 | 32 CompactSize length of this witness item. |
| Witness reserved value witness[0][0] | 32 @180 | 0000000000000000000000000000000000000000000000000000000000000000 The coinbase witness is one 32-byte value (the witness-commitment nonce); pearld uses zeros. |
| Locktime locktime | 4 @212 | 0 0: no time lock. |
216 bytes: one input, two outputs (the reward and the witness commitment), and a one-item witness. Its version is 2; pearld’s own template writes 1, but pools may write either.
How is its input different?
| Field | Size | Description |
|---|---|---|
| txid | 32 | All zeros: there is no previous transaction. |
| vout | 4 | ffffffff. With the zero txid, this marks a coinbase. |
| scriptSig length | 1 | 27 = 39 here. Must be 2 to 100. |
| scriptSig | 2–100 | Starts with the block height (BIP-34); the rest is free. |
| sequence | 4 | ffffffff. |
Only one input like this is allowed, in only one transaction per block, and it must come first.
What’s in the scriptSig?
- Size
- 2 to 100 bytes
- Type
- Free-form, starting with a script-number push
- Format
- BIP-34 height first
Block 130,825’s 39 bytes, taken apart:
| Bytes | Meaning |
|---|---|
03 09ff01 |
Push 3 bytes: 0x01ff09 = 130,825, the block heightBIP-34 height: The block's height, written as the first push of the coinbase scriptSig. Every Pearl block must have it, which makes every coinbase transaction unique. |
04 8393d76a |
Push 4 bytes: 0x6ad79383 = 1,792,512,899, the block’s own timestamp |
2f706f6f6c2e6b7279707465782e636f6d2f |
The text “/pool.kryptex.com/” |
1550cad31e016e7bf00f2ecb |
12 bytes of extranonceExtranonce: Free bytes a miner or pool puts in the coinbase scriptSig, often a counter or a pool tag. Changing them changes the coinbase txid and so the block's Merkle root. |
Only the first push is checked. It must be the height, in the shortest possible script-number encoding (heights 1 to 16 use the one-byte opcodes OP_1 to OP_16). After that the miner can write anything. The pool tag and extranonce here aren’t even valid script pushes, which is fine: a coinbase scriptSig is never run.
Pearl’s own node writes <height> <extranonce> "/P2SH/pearld/". Block 1’s coinbase is exactly that: 51 (OP_1, height 1), 00 (an extranonce of zero) and a 13-byte push of “/P2SH/pearld/”, a tag inherited from btcd.
How much does it pay?
At most the block subsidy plus the fees of every other transaction in the block. Block 130,825 claims exactly that:
| Grains | |
|---|---|
| Subsidy at height 130,825 | 223,833,660,195 |
| Fees of the other 114 transactions | 4,712,873 |
| Coinbase output 0 | 223,838,373,068 (2,238.38373068 PRL) |
Pearl’s subsidy shrinks a little with every block on a smooth curve, with no halvings; block 1 paid 3,229.64134063 PRL. The block reward page has the formula. A miner may claim less (the rest is lost forever), never more.
The reward output must follow the same rule as any output: Taproot, P2MR or OP_RETURN. Here it pays the Taproot address prl1puv0gqv4x0wd0ylwz086y3sqrg4a6umza9r08aecehjrmdqq7mctsmqaqsh.
What is the witness commitment?
The block header’s Merkle root covers txids, which leave witnesses out. So witnesses need their own commitment, and it lives in the coinbase, in an OP_RETURN output:
| Field | Bytes | Value |
|---|---|---|
| Version version | 4 @0 | 2 int32 little-endian. Pearl wallets and pearld coinbases use version 1; relay policy accepts 1-2. |
| Marker marker | 1 @4 | 0x00 Segwit marker (BIP-144): says witness data follows the outputs. |
| Flag flag | 1 @5 | 0x01 Witness flag; 0x01 is the only value Pearl accepts. |
| Input count vin.length | 1 @6 | 1 CompactSize number of inputs. |
| Previous txid vin[0].txid | 32 @7 | 0000000000000000000000000000000000000000000000000000000000000000 All zeros: this input creates new coins (coinbase). |
| Output index vin[0].vout | 4 @39 | 0xffffffff 0xffffffff together with a zero txid marks a coinbase. |
| scriptSig length vin[0].scriptSig.length | 1 @43 | 39 CompactSize length of the scriptSig. |
| Coinbase script vin[0].scriptSig | 39 @44 | 0309ff01048393d76a2f706f6f6c2e6b7279707465782e636f6d2f1550cad31e016e7bf00f2ecb Coinbase data. It starts with the block height 130825 (BIP-34, required in every Pearl block), then anything the miner likes. |
| Sequence vin[0].sequence | 4 @83 | 0xffffffff Final (0xffffffff): no RBF signal, no relative locktime, and locktime is ignored for this input. Pearl wallets use this. |
| Output count vout.length | 1 @87 | 2 CompactSize number of outputs. |
| Amount vout[0].value | 8 @88 | 223,838,373,068 grains (2238.38373068 PRL) int64 little-endian, in grains (1 PRL = 100,000,000 grains). |
| Script length vout[0].scriptPubKey.length | 1 @96 | 34 CompactSize length of the locking script. |
| Locking script vout[0].scriptPubKey | 34 @97 | prl1puv0gqv4x0wd0ylwz086y3sqrg4a6umza9r08aecehjrmdqq7mctsmqaqsh OP_1 OP_PUSHBYTES_32 <output key Q>: a Taproot output. |
| Amount vout[1].value | 8 @131 | 0 grains (0.00000000 PRL) int64 little-endian, in grains (1 PRL = 100,000,000 grains). |
| Script length vout[1].scriptPubKey.length | 1 @139 | 38 CompactSize length of the locking script. |
| Locking script vout[1].scriptPubKey | 38 @140 | witness commitment 78cc1a61dcfcee9c59ddd9f4d56a98764c071e077bcc36fe9d1cf0aad50ebac3 OP_RETURN aa21a9ed ‖ SHA256d(witness Merkle root ‖ nonce): the BIP-141 witness commitment. |
| Witness items witness[0].length | 1 @178 | 1 Number of witness stack items for input 0. |
| Witness reserved value length witness[0][0].length | 1 @179 | 32 CompactSize length of this witness item. |
| Witness reserved value witness[0][0] | 32 @180 | 0000000000000000000000000000000000000000000000000000000000000000 The coinbase witness is one 32-byte value (the witness-commitment nonce); pearld uses zeros. |
| Locktime locktime | 4 @212 | 0 0: no time lock. |
| Field | Size | Description |
|---|---|---|
| amount | 8 | 0 grains. |
| script length | 1 | 26 = 38 bytes. |
| OP_RETURN, push 36 | 2 | 6a 24. |
| tag | 4 | aa21a9ed, which marks a witness commitment. |
| commitment | 32 | SHA256d(witness Merkle root ‖ witness reserved value). |
-
Build a Merkle tree of wtxids
Every transaction’s wtxid, in block order, except the coinbase, whose own entry counts as 32 zero bytes (it can’t include itself). -
Append the witness reserved value
The coinbase’s single 32-byte witness item. pearld uses all zeros. -
Hash twice
SHA256d of those 64 bytes is the commitment. For block 130,825:78cc1a61dcfcee9c59ddd9f4d56a98764c071e077bcc36fe9d1cf0aad50ebac3.
Block 1 shows the simplest case. With only the coinbase, the tree is a single zero entry, so the commitment is SHA256d of 64 zero bytes: e2f61c3f71d1defd3fa999dfa36953755c690689799962b48bebd836974e8cf9. That’s exactly what block 1’s coinbase contains.
| Field | Bytes | Value |
|---|---|---|
| Version version | 4 @0 | 1 int32 little-endian. Pearl wallets and pearld coinbases use version 1; relay policy accepts 1-2. |
| Marker marker | 1 @4 | 0x00 Segwit marker (BIP-144): says witness data follows the outputs. |
| Flag flag | 1 @5 | 0x01 Witness flag; 0x01 is the only value Pearl accepts. |
| Input count vin.length | 1 @6 | 1 CompactSize number of inputs. |
| Previous txid vin[0].txid | 32 @7 | 0000000000000000000000000000000000000000000000000000000000000000 All zeros: this input creates new coins (coinbase). |
| Output index vin[0].vout | 4 @39 | 0xffffffff 0xffffffff together with a zero txid marks a coinbase. |
| scriptSig length vin[0].scriptSig.length | 1 @43 | 16 CompactSize length of the scriptSig. |
| Coinbase script vin[0].scriptSig | 16 @44 | 51000d2f503253482f706561726c642f Coinbase data. It starts with the block height 1 (BIP-34, required in every Pearl block), then anything the miner likes. |
| Sequence vin[0].sequence | 4 @60 | 0xffffffff Final (0xffffffff): no RBF signal, no relative locktime, and locktime is ignored for this input. Pearl wallets use this. |
| Output count vout.length | 1 @64 | 2 CompactSize number of outputs. |
| Amount vout[0].value | 8 @65 | 322,964,134,063 grains (3229.64134063 PRL) int64 little-endian, in grains (1 PRL = 100,000,000 grains). |
| Script length vout[0].scriptPubKey.length | 1 @73 | 34 CompactSize length of the locking script. |
| Locking script vout[0].scriptPubKey | 34 @74 | prl1p2nlcavdnzq4sl9gh6q92tu7neznz2df4cux5f68umkpapkd3ha4qlknklv OP_1 OP_PUSHBYTES_32 <output key Q>: a Taproot output. |
| Amount vout[1].value | 8 @108 | 0 grains (0.00000000 PRL) int64 little-endian, in grains (1 PRL = 100,000,000 grains). |
| Script length vout[1].scriptPubKey.length | 1 @116 | 38 CompactSize length of the locking script. |
| Locking script vout[1].scriptPubKey | 38 @117 | witness commitment e2f61c3f71d1defd3fa999dfa36953755c690689799962b48bebd836974e8cf9 OP_RETURN aa21a9ed ‖ SHA256d(witness Merkle root ‖ nonce): the BIP-141 witness commitment. |
| Witness items witness[0].length | 1 @155 | 1 Number of witness stack items for input 0. |
| Witness reserved value length witness[0][0].length | 1 @156 | 32 CompactSize length of this witness item. |
| Witness reserved value witness[0][0] | 32 @157 | 0000000000000000000000000000000000000000000000000000000000000000 The coinbase witness is one 32-byte value (the witness-commitment nonce); pearld uses zeros. |
| Locktime locktime | 4 @189 | 0 0: no time lock. |
The rules: the commitment output starts 6a24aa21a9ed and the last such output counts; if present, the coinbase witness must be exactly one 32-byte item; if absent, no transaction in the block may have a witness. Every normal Pearl spend needs a witness, so in practice only coinbase-only blocks can skip it. Some miners do: 8 of 200 recent blocks had a coinbase with no witness and no commitment.
When can the miner spend it?
After 100 blocks. A coinbase output from block 130,825 can first be spent in block 130,925. If a reorganizationReorg: When a node drops the newest block or blocks of its chain because a competing branch with more work appeared. Transactions from the dropped blocks go back to waiting. replaces the block, its coinbase vanishes too; the wait makes it very unlikely anyone has spent those coins by then.
What about the genesis block?
Pearl’s first coinbase is unusual in every way. It’s serialized the old way, with no witness, and its scriptSig is 234 bytes, longer than the 100-byte rule allows (the genesis block is never validated). It starts with 04 ffff001d 01 04, a copy of the start of Bitcoin’s own genesis coinbase (Bitcoin’s difficulty bits, not Pearl’s), then a 225-byte message that ends with the hash of Bitcoin block 946,842. Its only output pays 0 grains to a bare OP_RETURN, and the code marks it unspendable: Pearl had no premine.
Show the genesis coinbase
| Field | Bytes | Value |
|---|---|---|
| Version version | 4 @0 | 1 int32 little-endian. Pearl wallets and pearld coinbases use version 1; relay policy accepts 1-2. |
| Input count vin.length | 1 @4 | 1 CompactSize number of inputs. |
| Previous txid vin[0].txid | 32 @5 | 0000000000000000000000000000000000000000000000000000000000000000 All zeros: this input creates new coins (coinbase). |
| Output index vin[0].vout | 4 @37 | 0xffffffff 0xffffffff together with a zero txid marks a coinbase. |
| scriptSig length vin[0].scriptSig.length | 1 @41 | 234 CompactSize length of the scriptSig. |
| Coinbase script vin[0].scriptSig | 234 @42 | 04ffff001d01044ce1546865206e61746976652063757272656e637920666f72206d616368696e657320616e642068756d616e732e20546f74616c20322e31653920506561726c732c2043756d756c617469766520656d697373696f6e20682f28682b363530323236292c205754454d4120336d3134732037642c20426974636f696e20626c6f636b20233934363834322077697468204d5450203137373732373035323420697320303030303030303030303030303030303030303033613932323138363165633734313134323764643234663937396662393161336238663732363565316462632e Coinbase data: starts with the block height (BIP-34), then anything the miner likes (2-100 bytes). |
| Sequence vin[0].sequence | 4 @276 | 0xffffffff Final (0xffffffff): no RBF signal, no relative locktime, and locktime is ignored for this input. Pearl wallets use this. |
| Output count vout.length | 1 @280 | 1 CompactSize number of outputs. |
| Amount vout[0].value | 8 @281 | 0 grains (0.00000000 PRL) int64 little-endian, in grains (1 PRL = 100,000,000 grains). |
| Script length vout[0].scriptPubKey.length | 1 @289 | 1 CompactSize length of the locking script. |
| Locking script vout[0].scriptPubKey | 1 @290 | OP_RETURN data (unspendable) OP_RETURN data carrier: provably unspendable, never enters the UTXO set. |
| Locktime locktime | 4 @291 | 0 0: no time lock. |