Ethereum Wallets Explained Simply (Smart Contracts, Gas, Transactions) - YouTube

Channel: 99Bitcoins

[0]
What are the best Ethereum wallets out there?
[2]
How do Ethereum wallets work
[4]
and what’s their purpose?
[6]
What is Gas and how is it calculated?
[9]
Well stick around,
[10]
in this episode of Ethereum whiteboard Tuesday
[12]
we’ll answer these questions and more.
[21]
Hi, I’m Nate Martin from 99Bitcoins
[23]
and today we’re going to talk about Ethereum wallets -
[26]
those pieces of software, or hardware,
[28]
that allow us to interact with the Ethereum network.
[32]
At its core,
[33]
an Ethereum wallet, also known as a client,
[35]
holds your private key -
[37]
the “secret password” that gives you control
[39]
over your coins.
[40]
It also supplies you with a public Ethereum address
[43]
which people can use to send you Ethereum’s currency
[45]
known as Ether.
[47]
This is almost as far as Bitcoin and Ethereum go
[50]
in terms of similarities.
[52]
Many non technical users think of Ether as a currency
[56]
in the same sense they view Bitcoin.
[58]
They buy Ether in hopes its price will rise,
[60]
they pay for stuff with Ether and more.
[63]
However,
[63]
Ether wasn’t designed for the same purpose as Bitcoin.
[67]
If you’ve watched our previous video
[68]
“What is Ethereum?”
[69]
and if you didn’t you should,
[71]
you know that Ethereum is a network of independent computers
[74]
working together as one supercomputer.
[77]
This super computer executes pieces of code
[79]
known as contracts or smart contracts.
[82]
Interacting with contracts requires more complex communication
[86]
than to just send X amount of money
[88]
from Y to Z like Bitcoin does.
[90]
Ethereum wallets are the tool we use
[92]
for this communication .
[93]
So in order to truly understand Ethereum wallets
[96]
we need to first understand how Ethereum is built.
[100]
In Ethereum there are two types of accounts:
[102]
The most basic type of account in Ethereum is called
[105]
an EOA or Externally Owned Account.
[109]
Similar to how a Bitcoin wallet operates,
[111]
EOAs have an Ethereum address that is controlled by a private key.
[115]
A person can open as many EOAs as he likes.
[118]
In addition to sending and receiving Ether,
[120]
EOAs have the ability to create contracts and trigger them.
[125]
The second type of account is the Contract account.
[128]
These are accounts that have code associated with them.
[132]
Every contract deployed to the Ethereum network
[134]
has its own account which includes a unique Ethereum address.
[138]
However, unlike an external account
[140]
a contract account doesn’t have a private key that controls it.
[144]
So how is a contract account controlled?
[147]
Well, the code that defines the contract
[149]
includes a set of predefined triggers
[152]
which control the account.
[153]
In other words,
[154]
the conditions to control how the contract operates
[157]
are hard coded from the get-go.
[159]
Similar to EOAs,
[161]
contract accounts can receive Ether,
[163]
and if triggered,
[164]
send Ether or even create additional contract accounts.
[168]
It’s important to note that
[169]
contracts can’t be changed once they’ve been launched,
[172]
so the author must be very thorough
[175]
in drafting the conditions for each trigger.
[178]
EOAs can interact with other EOAs
[181]
and with contracts through messages.
[183]
These messages are “wrapped” inside transactions
[187]
which are paid for in Ether.
[188]
So while in Bitcoin
[190]
transactions are used only to transfer value,
[193]
Ethereum transactions are used for a variety of reasons:
[196]
First, transactions are used for the transfer of value.
[199]
This is the simplest form of transaction,
[201]
meaning sending Ether between accounts.
[204]
You can also use transactions to create a new Smart contract.
[208]
Creating a new contract
[210]
is done by sending a transaction that includes the contract’s code.
[214]
And finally,
[215]
transactions can be used to trigger a contract.
[218]
For example -
[218]
when you send money to an ICO’s contract account address,
[222]
you’re actually activating a contract
[224]
that sends you tokens in return.
[226]
Now that you understand how Ethereum is built
[229]
and that transactions are in fact used to help accounts
[232]
talk to each other
[233]
we can move on to Ethereum wallets.
[235]
Some Ethereum wallets will only allow you to transfer value,
[238]
or send Ether between accounts.
[241]
Other wallets will allow you to also deploy or trigger a contract.
[245]
These wallets are known as “Smart contract wallets”.
[248]
Similar to Bitcoin,
[250]
wallets are sometimes referred to as clients or nodes.
[253]
There are two types of clients -
[255]
full clients and light clients
[258]
A full node is a computer that holds
[261]
the entire Ethereum blockchain history,
[263]
since its inception until this day.
[266]
Running a full node has disadvantages like
[268]
increased memory and computer usage,
[270]
however it allows you to
[272]
verify transactions on the Ethereum blockchain
[275]
without needing to trust anyone’s word for it.
[278]
Full nodes are an integral part of the Ethereum network
[281]
as they are the “muscles” of the network,
[283]
that help execute contracts in a decentralized manner.
[287]
Each node that receives a new block of transactions
[289]
also executes the code inside these transactions.
[293]
There are different programs
[294]
to help you run an Ethereum full node.
[297]
We won't discuss all of 'em,
[298]
however we will talk about the most common clients:
[301]
The first on is Geth -
[303]
Short for Go Ethereum.
[305]
Developed by the Ethereum Foundation,
[307]
a non-profit organization established to develop
[310]
the code and community for Ethereum.
[312]
Geth is the most popular and widely used program.
[315]
The second is Mist -
[317]
Since Geth is a tool made for developers
[320]
Mist was created in order to allow
[322]
non technical users to interact with it.
[324]
So while technically you’re using Geth,
[327]
Mist provides you with an easy user interface to talk to it.
[330]
And finally, Parity –
[332]
which is a private company based in London
[334]
whose mission is to enable businesses and organizations
[337]
to capitalize on blockchain technology.
[340]
They developed software to run full nodes for Ethereum
[343]
and are considered the second most popular full client.
[347]
Just for reference,
[348]
at the time of releasing this video
[349]
there are 9713 nodes running Geth
[352]
and 4069 nodes running Parity.
[355]
All full nodes are smart contract wallets -
[358]
meaning they can deploy smart contracts
[360]
to the Ethereum network.
[362]
If you don’t want to run a full node
[364]
you can use a light node.
[366]
Light nodes, similar to Bitcoin’s SPV wallets,
[369]
are programs that rely on 3rd party full nodes
[371]
in order to get information when needed
[373]
rather than holding a full copy of the blockchain.
[376]
This means they require less space
[378]
and can operate on devices with limited space,
[381]
such as mobile phones.
[384]
Being the second largest currency
[385]
by market cap on the crypto market,
[387]
Ether has caught the eye of day to day users.
[390]
These users will usually use light nodes as their wallet
[393]
since it’s easier to install and operate.
[395]
If you don’t intend to write smart contracts any time soon
[398]
you can use any of the light nodes
[400]
listed on our website
[401]
for the most user friendly experience.
[404]
Let’s talk a bit about Ethereum hardware wallets
[408]
If you're serious about security
[409]
I suggest storing your Ether on a hardware wallet.
[412]
While being the most secure way to store your coins,
[415]
hardware wallets cost money.
[417]
Also, hardware wallets are not smart contract wallets by design,
[421]
they can only send and receive Ether
[423]
and ERC-20 tokens.
[425]
Now let’s move on to transaction fees and Gas;
[428]
trust me, you’ll understand in a few minutes.
[431]
While Bitcoin can be divided into 100,000,000 units
[434]
with the smallest unit called a Satoshi,
[437]
Ether can be divided into one quintillion units,
[440]
that’s a 1 with 18 zeroes after it

[443]
with the smallest one called Wei.
[446]
Wei is named after Wei Dai,
[448]
a cryptography activist
[450]
who is known for supporting widespread use of strong cryptography
[453]
and privacy-oriented technologies.
[456]
Fees for transactions, are usually calculated in Giga Wei.
[459]
So 1 quintillion Wei equals 1 Ether
[463]
and 1 billion Wei equals one Giga Wei.
[466]
There are also other names for different amounts of Wei,
[469]
all named after famous cryptographers,
[471]
as shown in this table.
[473]
In Bitcoin,
[474]
to send a transaction we need to add a miner's fee to it.
[477]
This way, we incentivize the miners to include it in a block.
[480]
In Ethereum,
[481]
we must keep miners incentivized as well,
[483]
for their contribution of computing power to the Ethereum supercomputer.
[487]
Just like a car,
[488]
the Ethereum network runs on Gas.
[491]
Each line of code that needs to be executed by the network
[494]
will take up a certain amount of gas.
[495]
Run out of Gas and the code stops running.
[498]
You specify how much Gas you’re going to use upfront,
[502]
and you can’t refuel on the way.
[504]
If your contract runs out of Gas because it’s written inefficiently
[507]
or you miscalculated,
[508]
it will just stop in the middle of the road.
[511]
This system motivates Smart contract programmers
[514]
to keep their code lean and optimized,
[516]
since Gas costs money as we will soon learn.
[519]
The Gas you pay goes to the miners,
[521]
as they are the ones investing computing power
[524]
in order to update the ledger of Ethereum transactions,
[527]
similar to what goes on in Bitcoin.
[529]
Keep in mind that Gas isn’t something you can own,
[532]
it’s just a unit of account
[533]
to measure how much work is needed to run a line of code.
[536]
Think of it as the equivalent of hours of labour.
[539]
Gas is paid in Ether,
[541]
Now I know what you’re thinking -
[543]
why not just price execution of smart contracts in Ether,
[546]
why do we need another virtual currency?
[548]
Well, Ether’s price is constantly changing,
[551]
and if we priced contracts in Ether
[553]
the price would be different each time we calculated it
[555]
due to the fluctuating exchange rate.
[558]
Imagine we’d price painting our house at 2 Ether,
[561]
sometimes it would cost us $1000 and other times $2000.
[565]
With Gas,
[566]
running the same contract several times
[568]
will always bring back a fixed amount of Gas to be paid
[571]
just like painting the same house
[573]
takes the same amount of hours every time.
[576]
So how much gas do you need to run a line of code?
[579]
Easy... there are predefined amounts
[581]
for each action you want to run in your code.
[584]
For example,
[584]
sending Ether from one address to the other
[586]
requires 21,000 gas units.
[589]
Now comes the tricky part.
[591]
How much do you actually pay for a unit of gas?
[594]
The price of 1 gas unit changes all the time
[597]
depending on how crowded the network is.
[600]
The same way an hour of labor would cost more
[602]
if many people are looking for employees
[604]
the Gas price rises when the network is crowded.
[607]
The “standard” gas price is around 20 GiGa wei.
[611]
You can consider this the average salary on the market
[614]
for an hour of labor.
[615]
If the Ethereum network is very busy
[618]
and you want your contract to get priority in execution
[621]
over other contracts
[622]
you may over bid the gas price
[624]
so that miners will have an incentive to include your contract
[627]
in the next block.
[629]
You’re basically saying
[630]
I’m willing to increase your pay per unit of labor
[633]
so you’ll give my work priority.
[635]
This is similar to how Bitcoin transaction fees rise
[638]
when the network is crowded.
[640]
When you send a transactions in Ether
[642]
you also need to specify a gas limit -
[645]
meaning how much gas are you willing to use at maximum
[647]
for running your lines of code.
[649]
This is done in order to protect you from depleting your funds
[652]
in case your code has an error and runs endlessly or inefficiently.
[657]
You pay the full amount for your gas limit upfront
[659]
and there’s no option for “refueling”.
[662]
This can cause certain things to go wrong, for example:
[665]
If you overpaid and your contract ended up using less gas -
[668]
you’ll get refunded for the gas not used.
[670]
However, if an operation ran out of gas mid way
[674]
it will halt, just like your car,
[676]
and no Ether will be returned to you
[678]
just like a gas station doesn’t refund you
[680]
even if you didn’t have enough gas to get where you want to go.
[683]
This can happen if, for example,
[685]
your contract needs to do some recurring function
[688]
that keeps on consuming gas and finally runs out.
[691]
If you don’t include enough gas units for running your code
[694]
no miner will pick up your transaction
[696]
since it doesn't have enough gas from the get go.
[698]
And finally -
[699]
If you choose enough units of gas
[701]
but pay very little for each unit
[703]
it may take a lot of time for your transaction to go through
[706]
since miners will prioritize higher paying transactions.
[710]
To conclude,
[710]
in Ethereum fees are a general term that refers to
[713]
the gas used multiplied by the gas price
[716]
you were willing to pay.
[717]
In other words -
[718]
the hours of labor worked times the wage per hour.
[721]
The higher you’re willing to pay per gas unit
[723]
the more miners will compete for running your code,
[726]
and the faster your transaction will be included in the blockchain.
[730]
That’s it for today’s video.
[731]
Hopefully by now
[732]
you have a better understanding of Ethereum's wallets,
[735]
Ethereum accounts, gas, transaction fees
[738]
and also the various wallets you can choose from.
[740]
As you probably noticed
[742]
Ethereum is a lot more complicated than Bitcoin
[744]
mainly because it’s intended on
[746]
executing much more complex functions
[748]
than just sending money from A to B.
[750]
Don’t worry, it gets worse,
[752]
but we’ll walk you through it as always
[754]
in our upcoming videos.
[755]
You may still have some questions.
[757]
If so, just leave them in the comment section below.
[759]
And if you’re watching this video on YouTube,
[761]
and enjoy what you’ve seen,
[762]
don’t forget to hit the like button.
[764]
Then make sure to subscribe to the channel
[766]
and click that bell
[767]
so that you’ll be notified as soon as we post new episodes.
[770]
Thanks for joining me here at the Whiteboard.
[771]
For 99Bitcoins.com, I’m Nate Martin,
[774]
and I’ll see you
 in a bit.