## A digital currency

Use cryptography.
No "central bank".
P2P network.

## WALLET

Use cryptography.
No "central bank".
P2P network.

## Transaction

When Bob is sending 42 to Alice, the bitcoin protocol is creating a transaction.
A transaction is the balance between his Inputs and his Outputs.

- First the network needs to be sure that Bob has got enough in his wallet.
  So Bob will include a list of transactions that he has received before.
  This is the inputs of the transactions.
  For example, previous transaction's amount are 10, 25 and another 10, so total inputs are 45
- As the input's sum is superior to the amount of the transaction, an ouput is added.
  This output is the change to Bob.
  In the example, this 3
- Fees are took by the network to process the transaction.
  Let say it will take 0.5.
  This is another ouput
- So Alice will get only a part of the transaction's amount.
  this the last output, 41.5

So the transaction is a made with :

- Inputs : a list of previous transactions that bob has received
- Outputs : a list of amounts to send to Alice, Bob, and fees
- A timestamp

Then the wallet will broadcast the transaction on the network.
It will be sent to the area called "mempool".
Nodes of the network will validate the transaction by verfying the Inputs and the Ouputs.
A hash of the transaction is computed.
So the transaction is sealed.

## Block

Then the bitcoin protocol is grouping validated transactions in blocks.
So a block is an array of transactions.
A block is made with :

- An array of transactions.
  That's what my script is drawing.
  Running the transactions array, it is computing the sum of each outputs of each transaction.
  Then, it draws a rectangle for each sum.
- A "proof of work".
  The miner is computing a special hash that depends on the array of transaction and that will answer to a constraint.
  This hash is very difficult to compute. In fact it is not really computed, the miner must test every value until he find the solution.
- That why the network will give him a reward.
  This is a special transaction that has no inputs.

## Blockchain

Each block has a hash and a reference to the ihash of the previous block.
So blocks are chained together.