§ 05

§ 05 · Transactions

UTXO

Coins are outputs nobody has spent yet

Pearl doesn’t keep a list of who owns how much. It keeps a list of coins.

Each coin is an output of some earlier transaction that nobody has spent yet: an unspent transaction output, or UTXO. Spending means naming some of those coins as inputs, destroying them, and creating new ones as outputs. Your “balance” is something your wallet works out by adding up the coins your keys can unlock.

What is the UTXO set?

Every full node keeps a table of all unspent outputs. Each entry is keyed by its outpoint, the txid of the transaction that created it and the output’s index, and holds what’s needed to check a spend:

Key (outpoint) Value
d919e02a…b384c9:0 295,646,640 grains, locked by 5120 d7ab02c9…9416b2
d919e02a…b384c9:1 200,000,000 grains, locked by 5120 62e9da36…073b2b
… … one row per unspent output on the chain

Nodes also note the block height each entry came from and whether it came from a coinbase, for the maturity rule below. Checking a new transaction is mostly lookups in this table.

How does a transaction change the set?

It deletes one row per input and adds one row per output. Here is the real payment from block 130,825:

beforeafter33218153…:683495,654,555spent by d919e02a…fee 7,915d919e02a…:0295,646,640d919e02a…:1200,000,000
One payment, seen as an update to the UTXO set: one coin consumed, two created, 7,915 grains left over as the fee.
  • Removed: 33218153…553959:683, worth 495,654,555 grains.
  • Added: d919e02a…:0 (295,646,640 grains) and d919e02a…:1 (200,000,000 grains).
  • Gone for good: 7,915 grains, which no output claims. The miner collects them as the fee.

A UTXO is spent whole. To pay 2 PRL from a 4.95-PRL coin, you spend all of it and send the rest back to yourself as change.

Where is my balance, then?

In your wallet’s arithmetic. The wallet knows which locking scripts its keys can unlock (every prl1p… address it has derived), finds the UTXOs with those scripts, and adds up their amounts.

When you send, it picks coins to cover the amount plus the fee. Pearl’s wallet picks the largest coins first by default, then puts the change output at a random position. Picking coins reveals that they belong together, which is one reason wallets use a fresh address each time.

Make a guess

You receive 100 payments of 1 PRL each, then want to send 50 PRL. How many inputs does your transaction need?

Think of your answer first, then check it.

Answer 51.

Each 1-PRL payment is a separate UTXO, and each input spends exactly one. Fifty coins cover the 50 PRL exactly, leaving nothing for the fee, so a 51st is needed. Each input adds about 57.5 vbytes (41 base bytes plus a 66-byte witness at a quarter), so a fragmented wallet pays noticeably more to send. That’s why wallets sometimes consolidate small coins when fees are low.

Which outputs never become UTXOs?

Outputs that can never be spent. Pearl’s nodes skip any output whose locking script starts with 6a, OP_RETURN, when they update the set: no one could ever spend it, so there’s nothing to remember.

That covers data outputs, the witness commitment a coinbase carries, and Pearl’s genesis block, whose only output pays 0 grains to a bare 6a. Its coinbase is also explicitly unspendable in the code, so there was never a premine to spend.

Since only Taproot, P2MR and OP_RETURN outputs are valid on Pearl, every entry in the UTXO set is a 34-byte Taproot or P2MR lock.

When can a new coin be spent?

  • Normal outputs: immediately. A transaction can even spend an output of another transaction that’s still waiting in the mempool. If both land in the same block, the parent must come first; Pearl enforces that order.
  • Coinbase outputs: only after 100 blocks. If the chain reorganizes and a block disappears, its coinbase coins disappear with it; the waiting period makes sure nobody has spent them by then.

What stops a coin being spent twice?

The UTXO set itself. Once a block spends an outpoint, that row is gone, and any later transaction pointing at it is invalid: it spends a coin that doesn’t exist.

Before confirmation, two transactions can compete for the same coin. A node keeps the first it sees and rejects the other, unless the first signalled replace-by-fee and the second pays more. Whichever one a miner puts in a block wins; the other becomes invalid. That’s a double spend attempt, and the chain settles it.

The codex

Suggested

Up and down arrows move through the results, Enter opens one, Escape closes. Anywhere on the site, slash or Command K opens this search, and the square brackets [ and ] go to the previous and next page.