§ 05 · Transactions
UTXO
Coins are outputs nobody has spent yet
On this page 6 sections
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 outputUTXO: An output that has not been spent yet: a chunk of PRL waiting to be used. Your balance is the total of the UTXOs your keys can unlock., 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 outpointOutpoint: A pointer to one specific output: the ID of the transaction that made it, plus the number of the output within that transaction., 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:
- Removed:
33218153…553959:683, worth 495,654,555 grains. - Added:
d919e02a…:0(295,646,640 grains) andd919e02a…: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 changeChange: The leftover a transaction sends back to its sender. Outputs are spent whole, so if they hold more than you're paying, the rest comes back to you as a new output..
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_RETURNOP_RETURN: An output that starts with OP_RETURN. It can carry data but can never be spent, so it never joins the set of unspent outputs., 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 spendDouble spend: Trying to spend the same coins twice, for example paying two people with one coin. Stopping this without a bank is the main job of a blockchain. attempt, and the chain settles it.