Chapter 03 · Beginner guide
Transactions
Spend old outputs, make new ones
On this page 6 sections
A transactionTransaction: A signed instruction that spends some existing outputs and creates new ones. It is how PRL moves from one owner to another. is a short message with a big job: it moves PRL from one owner to another.
It says which coins are being spent, who gets them, and it carries a signature proving the owner agreed. That’s all. There are no account numbers and no names.
What’s inside a transaction?
Two lists.
InputsInput: The part of a transaction that names an earlier output and spends it, all of it at once. point to coins you already have. OutputsOutput: The part of a transaction that creates a new chunk of PRL: an amount in grains and a lock saying who can spend it. Pearl allows only three kinds: Taproot, P2MR and OP_RETURN. create new coins for whoever is being paid.
Every coin in the ledger is an output of some earlier transaction. Until someone spends it, it’s an unspent transaction output, or UTXOUTXO: 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.. Your wallet balance is simply the total of all the UTXOs your keys can unlock.
So a transaction is a little act of recycling: it uses up some old outputs and creates fresh ones.
Why do you get change?
Outputs work like banknotes. You can’t tear one in half, so when you spend an output, you spend all of it.
Say you hold one output worth 10 PRL and want to pay a friend 3 PRL. Your transaction spends the whole 10 PRL output and creates two new ones: 3 PRL for your friend, and the rest back to you. That second output is your 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..
Here is a real payment from block 130,825, drawn as boxes.
Add up the outputs and you get 4.95646640 PRL. The input held 4.95654555 PRL. Keep that small gap in mind; it comes back in a moment.
Make a guess
You hold exactly one output, worth 10 PRL, and want to pay a friend 3 PRL. How many outputs will your transaction create?
Think of your answer first, then check it.
Answer Two.
One output of 3 PRL for your friend, and one change output back to you for a little under 7 PRL. The “little under” is the fee. Your old 10 PRL output is now spent and can never be spent again.
How do you prove the coins are yours?
Every output is locked to a key. To unlock it, the spender attaches a signatureSignature: Proof, made with a private key, that the key's owner approved one exact transaction. Anyone can check it with the public key, and it is useless for any other transaction. made with the matching private key. Pearl uses Schnorr signatures, 64 bytes each.
Any node can check the signature using the public key. And a signature only fits the exact transaction it was made for. Change a single grain of any amount, or swap the recipient’s address, and the signature no longer checks out.
That’s why nobody can intercept your payment and redirect it. They’d need to sign a new one, and only your private key can do that.
The signatures travel in a separate section of the transaction called the witnessWitness: The part of a transaction that carries the signatures and other unlocking data, kept apart from the part that makes the transaction ID. Every Pearl spend has one.. Every spend on Pearl has one.
Where does a transaction wait?
A signed transaction hops from node to node, and each node keeps a copy in its mempoolMempool: Each node's waiting room for valid transactions that aren't in a block yet. Miners pick from it, usually the best-paying ones first., a waiting room for valid transactions that aren’t in a block yet.
When a miner builds its next block, it picks transactions from its mempool. Once yours is in a block, it’s recorded in the ledger.
Why pay a fee?
Remember the gap in the real example? The outputs add up to 7,915 grains less than the input. That difference is the feeFee: What a transaction leaves for the miner: the total of its inputs minus the total of its outputs. The miner who puts it in a block keeps it..
Nobody writes the fee down. It’s simply left over, and the miner who includes the transaction claims it as part of the block’s reward.
Space in a block is limited: at most 1,000,000 vbytesVirtual byte (vbyte): Pearl's unit of transaction size: ordinary bytes count in full and witness bytes count a quarter each. A block can hold at most 1,000,000 vbytes.. A vbyte is Pearl’s unit of size, where signature bytes count a quarter. Miners fill that space with the best-paying transactions first, so what matters is the fee per vbyte, called the fee rateFee rate: A transaction's fee divided by its size, in grains per vbyte. Miners prefer higher rates; nodes won't pass on anything below 1 grain per vbyte..
The example transaction was 154 vbytes, so its fee rate was about 51 grains per vbyte, which was typical for payments that day. Nodes won’t even pass on a transaction paying less than 1 grain per vbyte.
What kinds of lock can an output have?
Pearl is strict here. Only three kinds of output are valid at all:
- Taproot, with addresses starting
prl1p. Locked to one key, which can also hide extra spending rules. Almost every payment uses this. - P2MR, with addresses starting
prl1z. Locked to a tree of spending rules with no key in it. Rare today; the quantum safety page explains why it exists. - OP_RETURN. Carries a piece of data and can never be spent.
Taproot and P2MR outputs smaller than 333 grains are called dustDust: An output so small that spending it would eat a large share of its value in fees. Pearl nodes won't pass on transactions that create Taproot or P2MR outputs below 333 grains., because they’re worth so little that spending them would eat a large share of their value in fees. Nodes won’t pass on transactions that create them.
So a payment is now signed, checked and waiting. The next page shows how it gets locked into the ledger for good.