a

How Blockchain Transactions Work (Adding Data to Blockchains)

in this video I'll explain conceptually

how data is added on to block chains and

how transactions work in blockchain

spilt for crypto currencies like Bitcoin

in what is blockchain we talked about

how secure and immutable data is on a

blockchain if you haven't watched that

yet I highly recommend you to do so so

how do we add new information after all

a place to store information without

being able to add to it isn't too useful

also how do you make sure that the data

added is legitimate for example in the

application of the cryptocurrency it is

extremely vital that the new information

we add is legitimate we know that blocks

are used to store information and

information in previous blocks are

immutable so then we need to create new

blocks if we need to add new information

in the last video I mentioned that it's

very difficult to create a block let me

go into a little bit more detail recall

that blocks with different data must

have different hash codes theoretically

maybe not but for all practical purposes

we can assume so

there are restrictions hard-coded into

the blockchain system every blocks hash

must start with for example five zeros

how's that possible if I already have

data I want to add on to the new block

how am I supposed to control the hash

the hash comes from a preset algorithm

so how do I control what the algorithm

spits out let's look at what information

we have in a block we have data the hash

of the previous block and time stamp

this is the data we want to store in the

new block once I've decided that I want

to add this specifically data to the

block I cannot change this plus we have

something called nonce each block has a

special piece of data called the nonce

its sole purpose is for us to have the

ability to manipulate the hash code to

for example start with five zeros we

give the nonce a random value at first

we see the hash code does not start with

five zeros so we change its value and

try again

let's see what the hash code is still it

doesn't start with five zeros we try

again nope and we guess again

there we go essentially this is all just

using raw computing power to guess the

correct value of the knots so we can

have hash code that starts with five

zeros we call the people who try to

create blocks and finances miners many

miners could be simultaneously trying to

create a block whoever computes the

correct nonce first will broadcast it to

the network so the other miners hash the

blocks data and nonce to see if it

returns the right hash with five leading

zeros for example once verified at over

50% agree everyone on the network adds

this new block onto their blockchain

this is a general way of adding data to

a blockchain and so far we cannot

control what miners decide to add to the

blockchain so here's a problem if miners

can just add whatever they want how do

we apply this blockchain to crypto

currency like Bitcoin it would be

disastrous if any miner can unilaterally

decide to record something like BLTs

sent 5,000 bitcoins to me whenever they

find the correct knots for this piece of

data so each application of blockchain

has some additional rules that dictate

how data is added onto the blockchain

[Music]

when miners want to update the

blockchain with important data like

transactions they must take extra steps

to make sure what they're adding is

legit for example you need to make sure

that blt actually has 5000 bitcoins in

its balance and also that blt actually

wants to send those 5000 bitcoins to say

crazy miner 1 2 3 this is where keys and

signatures come in each cryptocurrency

account has its own unique private key

and public key public keys are basically

this accounts address on the blockchain

they can be thought of as the user name

of the account transactions relating to

this account explicitly mention this key

private keys are only known to the owner

of its corresponding public key it's

like a password to the public key say

blt wants to send crazy modern 1 2 3

bitcoins first blt will need to know

crazy modern 1 2 3 is public key ELT

writes down this transaction so as you

can see here the red text on the top is

the LTS public key and it says that it

wants you sent the bottom rep red text

which is the public key of crazy miner 1

2 3 so basically this just means that

ELT you want to send crazy miner one two

three five thousand bitcoins now BLT

takes this message and it's private key

which is actually another string of

numbers add letters but will use this

key to represent it here so we add them

together add hash it to get the

signature

the signature is essentially the

hashcode of message and the private key

[Music]

now VLT would need to announce that it

would like to make this transaction so

it takes the message and the signature

which was hash from the message and the

BLT prime key and the BLT public key and

packages it together remember miners are

the ones with the computing power to

create blocks so BLT we need to announce

two miners that would like to add this

transaction to the blockchain now this

transaction is added to the pool of

other transactions that other people

want to make none of these transactions

are on the blockchain yet this is just

the pool of transactions that want to go

onto the blockchain it is up to the

miners to actually add these

transactions onto the blockchain now a

minor fix of transaction he likes

usually whichever transaction gives the

miner a larger tip but we'll go into

that in a later video let's say BLT is

lucky and a miner decides to add the BLT

transaction to his new block before this

miner puts this transaction on his new

block he must first verify that this

transaction is legitimate how first he

simply looks at the message and makes

sure that BLT has sufficient funds to

make the proposed transaction then he

runs it through his blockchain software

that has this amazing algorithm to

determine if the signature message and

public key in the path package is

legitimate this algorithm is one of

blockchains most ingenious things it is

able to verify two crucial pieces of

information what the signature was

created using the corresponding private

key of the provided public key in the

package and who the signature was

created using the same message as the

provided message in the package notice

how in this entire init process the

miner is able to verify that the

transaction is indeed the will of BLT

without ever seeing BLTs private key

so a miner can add multiple transactions

on to his new clock the miner must

validate each transaction in the way I

just described the miner finds the

correct nonce

that announces this block with

information about all the transactions

that he added to it to the network other

miners first verify that the nonce is

correct then verify that each

transaction described in the proposed

new block is legitimate if all its

correct other miners for okay and add

this new block to their own blockchains

a new block that contains BLTs

transaction has now been added to the

blockchain

you