# Bitcoin (ergo, BSV) Transactions

Bitcoin combines **data (Bit)** and **money (Coin)**. While the coin is the most visible feature, the real power lies in Bitcoin’s **data capabilities**. Think of it as a **global, immutable record of events**.

These events can be anything from:

* **Payments**
* **e-KYC checks**
* **Shipment tracking in supply chains**
* **E-commerce transactions**

All of these are recorded as **transactions** on the BSV ledger. Transactions are grouped into **blocks**, which are timestamped collections of events.

***

### Transaction Structure

A **transaction** is a data structure with fields such as:

* **Version Number**
* **nLockTime**
* **Inputs**
* **Outputs**

For our purposes, we’ll focus on **Inputs** and **Outputs**.

* **Transaction Inputs**: Refer to previous transactions and contain an **unlocking script** that allows the funds to be spent.
* **Transaction Outputs**: Define the **amount** and a **locking script** that sets the conditions for spending.

<figure><img src="/files/0fYPA773ltsORHFTh1df" alt=""><figcaption></figcaption></figure>

### Example Flow: Alice → Bob → Carol → Dave

Let’s walk through an example timeline with three transactions (T1, T2, T3):

1. **T1**: Alice has **51 BSV** and sends **50 BSV** to Bob.
2. **T2**: Bob uses those 50 BSV and sends **49 BSV** to Carol.
3. **T3**: Carol uses her 49 BSV and sends **48 BSV** to Dave.

*Note*: In BSV, **ownership** (not the coins themselves) is transferred.

Each participant—Alice, Bob, Carol, and Dave—has a **private-public key pair**.

***

### Inputs vs. Outputs

To simplify:

* A **Transaction Input** = details of the **payer** (source of funds).
* A **Transaction Output** = details of the **payee** (where funds are sent).

Example:

* In **T2**, Bob pays Carol.
* The **input** of T2 references T1 (where Bob received funds from Alice).
* The **output** of T2 defines Carol’s new ownership.

<figure><img src="/files/2kkG0VbxXhzKVwwlsaq5" alt=""><figcaption></figcaption></figure>

### Scripts: Locking & Unlocking

A powerful feature in BSV is the **Script**.

* A **Locking Script**: Sets a condition (“locks” the funds).
* An **Unlocking Script**: Provides the solution (“unlocks” the funds).

Think of it as a **puzzle and its answer**:

* Example: If the lock says *5 - 3 = ?*, the unlock must provide *2*.

Scripts are written in Bitcoin’s assembly-like language with **operands** and **opcodes**.

***

### Script Evaluation

When a transaction is broadcast:

1. Nodes combine the **unlocking script** from the new transaction with the **locking script** of the referenced previous transaction.
2. They run the script to check if the result is **True or False**.
3. If **True**, the transaction is valid and can proceed.

This mechanism ensures that only the rightful owner (with the correct **private key**) can spend funds.

***

### Transaction Templates

To simplify use, many transactions follow standard **templates**.\
The most common is **Pay-to-Public Key Hash (P2PKH)**.

* **Unlocking Script**: `<Signature> <Public Key>`
* **Locking Script**: `OP_DUP OP_HASH160 <Public Key Hash> OP_EQUALVERIFY OP_CHECKSIG`

Here:

* `<Signature>`, `<Public Key>`, `<Public Key Hash>` are **operands**.
* The rest are **opcodes**.

The key opcode here is **OP\_CHECKSIG**, which verifies **digital signatures**.

***

### Key Takeaway

* **Transactions** in BSV are not just fund transfers—they are **data events** recorded on a global ledger.
* **Inputs reference previous outputs** and require unlocking.
* **Outputs lock new funds** with conditions for future use.
* **Scripts act as puzzles** that must be solved with the correct keys.
* Standardized templates like **P2PKH** make this process practical and secure.

👉 **In short:** BSV transactions are secure, traceable, and flexible—making them useful far beyond simple payments.


---

# 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/bitcoin-primitives-digital-signatures/bsv-and-digital-signatures/bitcoin-ergo-bsv-transactions.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.
