Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Unspent Transaction Output | Blocks and Transactions
Introduction to Blockchain

Unspent Transaction OutputUnspent Transaction Output

UTXO and Balance

The Unspent Transaction Output (UTXO) model is a fundamental concept in the way Bitcoin and several other cryptocurrencies track ownership of digital currency representing the amount of digital currency someone has available to spend.

A UTXO is essentially a piece of digital currency that has been received in a Bitcoin wallet but not yet spent.

Each UTXO represents a chunk of Bitcoin that can be used as an input in a new transaction. The Bitcoin network tracks all UTXOs in the blockchain, and the collection of all UTXOs is known as the UTXO set. This set is used to determine a wallet's balance and to verify new transactions.

Let's take a look at an example:

Bob's wallet

As you can see, Bob has a total of 4 UTXOs, and they all comprise his wallet. Summing up their amounts, we get the balance of Bob's wallet, which is equal to 4 BTC.

Spending UTXOs

Now, let's illustrate the spending of UTXOs with an example to make things clear. Suppose Bob wants to send 1.9 BTC to his friend Alice with the transaction fee equal to 0.01 BTC. Here is her wallet before the transaction:

Alice's wallet

As for now, Alice has 3 UTXOs making the total balance of 8.45 BTC.

We can now proceed to our transaction, however there is one detail to keep in my mind.

A single UTXO cannot be split into smaller chunks, so the whole UTXO must be used as an input in a new transaction. However, a transaction can use any combination of UTXOs (not necessarily an entire set). The combination to use, though is determined by your wallet and cannot be controlled.

Since Bob doesn't have a single UTXO or a combination of UTXOs equal exactly to 1.91 BTC (1.9 BTC for Alice + 0.01 BTC as transaction fee), he'll have to use a UTXO or a combination of UTXOs with the total amount greater than this one. Let's say, the wallet chooses a UTXO with 2 BTC (however, using 1.5 BTC, 0.3 BTC and 0.2 BTC UTXOs is also possible).

To spend his 2 BTC UTXO, Bob's wallet creates an unlocking script, also known as the scriptSig (script signature). This script typically contains a digital signature produced by Bob's private key and, depending on the type of locking script used to lock the UTXO, may also contain the public key. The digital signature proves that Bob is the owner of the funds and has the right to spend the UTXO. You can read more about public and private keys in this article.

Let's now take a look at our transaction:

After the transaction is confirmed, Alice's wallet balance increases by 1.9 BTC. Bob's wallet balance will now consist of the remaining UTXOs he did not spend (1.5 BTC, 0.3 BTC, and 0.2 BTC) plus the new change UTXO of 0.09 BTC (after the fee of 0.01 BTC is taken out). Bob's new total balance will be the sum of these UTXOs, which is 2.09 BTC.

As you can see, when Bob's wallet creates the transaction, it also creates locking scripts for the outputs. The output that sends 1.9 BTC to Alice will have a locking script that specifies the conditions under which those funds can be spent in the future. This script is known as the scriptPubKey (script public key).

The scriptPubKey will typically contain a cryptographic hash of Alice's public key or Bitcoin address, setting a condition that only someone with the corresponding private key (Alice) can unlock and spend these funds.

Finally, when Bob broadcasts the transaction to the network, miners will validate it by checking that the unlocking script (scriptSig) for each input satisfies the locking script (scriptPubKey) from the output where the UTXOs were previously sent to Bob. If the scripts are valid and the transaction is confirmed, it becomes part of a block in the blockchain.

When creating a Bitcoin transaction, what must occur for the transaction to be considered valid regarding UTXOs?

Selecione a resposta correta

Tudo estava claro?

Seção 2. Capítulo 7
course content

Conteúdo do Curso

Introduction to Blockchain

Unspent Transaction OutputUnspent Transaction Output

UTXO and Balance

The Unspent Transaction Output (UTXO) model is a fundamental concept in the way Bitcoin and several other cryptocurrencies track ownership of digital currency representing the amount of digital currency someone has available to spend.

A UTXO is essentially a piece of digital currency that has been received in a Bitcoin wallet but not yet spent.

Each UTXO represents a chunk of Bitcoin that can be used as an input in a new transaction. The Bitcoin network tracks all UTXOs in the blockchain, and the collection of all UTXOs is known as the UTXO set. This set is used to determine a wallet's balance and to verify new transactions.

Let's take a look at an example:

Bob's wallet

As you can see, Bob has a total of 4 UTXOs, and they all comprise his wallet. Summing up their amounts, we get the balance of Bob's wallet, which is equal to 4 BTC.

Spending UTXOs

Now, let's illustrate the spending of UTXOs with an example to make things clear. Suppose Bob wants to send 1.9 BTC to his friend Alice with the transaction fee equal to 0.01 BTC. Here is her wallet before the transaction:

Alice's wallet

As for now, Alice has 3 UTXOs making the total balance of 8.45 BTC.

We can now proceed to our transaction, however there is one detail to keep in my mind.

A single UTXO cannot be split into smaller chunks, so the whole UTXO must be used as an input in a new transaction. However, a transaction can use any combination of UTXOs (not necessarily an entire set). The combination to use, though is determined by your wallet and cannot be controlled.

Since Bob doesn't have a single UTXO or a combination of UTXOs equal exactly to 1.91 BTC (1.9 BTC for Alice + 0.01 BTC as transaction fee), he'll have to use a UTXO or a combination of UTXOs with the total amount greater than this one. Let's say, the wallet chooses a UTXO with 2 BTC (however, using 1.5 BTC, 0.3 BTC and 0.2 BTC UTXOs is also possible).

To spend his 2 BTC UTXO, Bob's wallet creates an unlocking script, also known as the scriptSig (script signature). This script typically contains a digital signature produced by Bob's private key and, depending on the type of locking script used to lock the UTXO, may also contain the public key. The digital signature proves that Bob is the owner of the funds and has the right to spend the UTXO. You can read more about public and private keys in this article.

Let's now take a look at our transaction:

After the transaction is confirmed, Alice's wallet balance increases by 1.9 BTC. Bob's wallet balance will now consist of the remaining UTXOs he did not spend (1.5 BTC, 0.3 BTC, and 0.2 BTC) plus the new change UTXO of 0.09 BTC (after the fee of 0.01 BTC is taken out). Bob's new total balance will be the sum of these UTXOs, which is 2.09 BTC.

As you can see, when Bob's wallet creates the transaction, it also creates locking scripts for the outputs. The output that sends 1.9 BTC to Alice will have a locking script that specifies the conditions under which those funds can be spent in the future. This script is known as the scriptPubKey (script public key).

The scriptPubKey will typically contain a cryptographic hash of Alice's public key or Bitcoin address, setting a condition that only someone with the corresponding private key (Alice) can unlock and spend these funds.

Finally, when Bob broadcasts the transaction to the network, miners will validate it by checking that the unlocking script (scriptSig) for each input satisfies the locking script (scriptPubKey) from the output where the UTXOs were previously sent to Bob. If the scripts are valid and the transaction is confirmed, it becomes part of a block in the blockchain.

When creating a Bitcoin transaction, what must occur for the transaction to be considered valid regarding UTXOs?

Selecione a resposta correta

Tudo estava claro?

Seção 2. Capítulo 7
some-alt