# Spending a Coin

> Each owner transfers the coin to the next by digitally signing a hash of the previous transaction and the public key of the next owner and adding these to the end of the coin.
>
> \- Satoshi Nakamoto, Bitcoin Whitepaper

![](/files/NZznXBUtxKvmpL3T7OUU)

Each UTXO is locked with a script commonly called a scriptPubKey. This scriptPubKey is a puzzle that defines a predicate. The spending party must provide a solution which allows the predicate to be solved with a ‘True’ or non-zero outcome.

When spending a coin, the owner (or their proxy) first constructs a message that includes:

* The identity of the coin or coins on the ledger (transaction ID and output index)
* Valid solutions to each of the locking scripts written onto the ledger when the coin or coins were created
* A new locking script for each of the outputs being generated in the transaction which tests a knowledge proof provided by the receiver to the spending party
* Other details including a locktime parameter and protocol version

Depending on the spender’s preference, some or all of this message is combined, and the resulting string hashed and used to generate an ECDSA signature using a keypair controlled by the spending party and specified by scriptPubKey contained in the input being spent. Once the transaction is complete, it is ready to be sent onto the network to be processed into a block.

Learn more about Bitcoin transactions here: <http://wiki.bitcoinsv.io/index.php/Bitcoin_Transactions>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://hub.bsvblockchain.org/higher-learning/bsv-academy/bsv-theory/transactions/spending-a-coin.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
