►
From YouTube: Smart Contract Vulnerabilities: Ethernuats
Description
In this video, our technical evangelist - Andy Tudhope - talks you through the first 6 Ethernaut smart contract exercises. He discusses some of the basics around Solidity, how to write defensive smart contracts, what sorts of patterns to avoid when you're developing and how best to understand everything from gas to inter-contract calls and provenance. This is an intermediate tutorial and assumes some knowledge of smart contracts and Solidity.
00:30 - Getting started
04:15 - Hello Ethernaut
17:53 - Fallback
31:15 - Mored details about Gas
33:50 - Fallout
39:50 - Token
49:03 - Delegation
57:30 - Remix IDE
A
Other
stuff
works,
so
I
thought
as
a
nice
way
to
sort
of
get
started
with
how
to
use
status
itself
and
how
to
build
the
apps
that
this
would
be
a
good
dry
run
to
see
how
we
can
put
together
useful
and
entertaining
educational
content
by
going
over
some
of
the
amazing
resources
for
free
in
this
open
source
ecosystem.
So
there's
a
really
great
bunch
of
people,
mostly
based
in
South
America,
called
Zeppelin
solutions,
and
they
builds
auditive
libraries
of
smart
contracts
that
sort
of
cover
all
of
the
basic
patterns
that
you
need
in
solidity.
A
A
And
brave
comes
pre-loaded
with
meta
mask,
which
is
what
we're
going
to
be
using
for
this
particular
tutorial.
If
you
want
to
chat
about
some
of
the
downsides
of
meta
mask,
then
ricardo
and
richard
are
really
really
great
to
talk
to,
because
there
are
some
downsides,
but
we'll
get
to
those
as
we
go
through.
A
I'll
send
up
to
open
Zeppelin
link
in
the
meeting
notes
for
this
sorry
I'm,
just
not
logged
into
my
github,
for
this
presentation,
so
they've
put
together
a
series
of
eight
different
situations
with
smart
contracts
that
you
can
go
through
in
order
to
learn
more
about
the
vulnerabilities
inherent
in
some
of
the
things
that
have
been
written.
So
all
of
these
contracts
come
from
different
ways
that
smart
contracts
on
ethereum
have
been
hacked
over
the
last
two
and
a
half
years.
A
So
it's
a
really
instructive
sort
of
set
of
tasks
to
get
you
into
thinking
about
how
to
write
properly
secure,
smart
contracts.
All
of
these
are
written
in
a
language
called
solidity,
which
is
currently
the
most
popular
language
to
write
smart
contracts
in
in
in
ethereum,
as
you
would
have
seen
from
sharks
presentation
in
bangkok.
There
are
other
alternatives
to
this
he's
working
on
Viper,
which
is
a
Python
like
language
and
then
there's
something
called
lll,
which
was
the
low-level
language
or
the
lovely
little
language,
depending
on
your
interpretation
of
it.
A
But
solidity
is
the
most
popular
and
it
looks
fairly
similar
to
Java
scripts.
I.
Think
the
easiest
way
to
imagine
it
is
sort
of
strongly
typed
Java
scripts
with
object
orientation
sort
of
baked
into
it.
So
you
can
apply
the
notion
of
inheritance
to
your
contracts,
which
is
something
that
we'll
get
into
in
the
course
of
our
tutorials.
A
If
you
want
to
and
take
a
look
at
the
sort
of
latest
salinity,
Ducks
they're,
really
really
good
they're,
going
to
much
more
detail
than
I
will
over
the
next
sort
of
45
minutes
and
are
a
really
really
great
place
to
start.
If
you
want
to
dive
deep
into
understanding
both
the
strengths
and
some
of
the
limitations
that
come
with
solidity,
a
lot
of
which,
in
terms
of
the
limitations
are
sort
of
highlighted
in
these
tutorials,
is
just
sort
of
the
points.
A
But
if
you
hits
command
ult's
I
on
your
Mac
or
if
you're
on
Windows
I,
think
it's
command
shift,
C
or
I
control
shift,
C
and
I
to
get
your
developer
tools
up
and
go
into
your
console.
You'll
see
a
whole
bunch
of
information
printed
in
pretty
psychedelic
colors,
which
is
you
know,
quite
a
neat
way
to
sort
of
play
the
game
and
we're
going
to
go
through
each
of
these
ones.
Perhaps
not
re-entrance
t
in
elevator,
but
just
the
first
six.
A
To
give
you
guys,
a
sense
of
both
hostility
works,
how
smart
contracts
work
in
general
and
how
they
can
be
manipulated,
just
so
that
you're
aware
of
sort
of
how
best
to
write
defensive
patterns
when
you're
thinking
about
this
stuff.
The
first
thing
that
you'll
need
before
we
really
begin
is
meta
mask.
If
you
haven't
got
it
already,
essentially
you
can
imagine
like
imagine
it
like
a
wallet
for
your
browser,
but
it's
probably
better
to
describe
it
as
a
keyring.
It's
where
you
store
all
of
your
different
accounts.
A
There
are
several
limitations
to
doing
this
and
we
sort
of
don't
recommend
keeping
any
ether
in
in
meta
masks,
because
it's
not
necessarily
the
most
secure
way
of
storing
your
ether
and
also
the
injects
a
whole
bunch
of
information
into
every
webpage
that
you
visits,
which
can
be
something
used
against
you
for
advertising
purposes,
which
is
not
so
cool.
But
it's
useful
for
this
particular
tutorial.
A
A
You've
got
a
sort
of
drop-down
that
you
can
choose
which
network
you
want
to
join,
we're
going
to
be
working
on
Rob
stone,
which
is
the
closest
sort
of
mimic
of
the
main
ethereum
network,
in
the
sense
that
it
runs
the
same
consensus
algorithms
as
ethereum
itself
does
ie
proof-of-work,
whereas
the
other
ones,
rinkeby
and
Kovan
runs
something
called
proof
of
authority
just
because
Rob
Stan
has
been
attacked
so
many
times,
because
the
ethernet
is
worth
nothing.
So
it's
very,
very
easy
to
sort
of
spam.
A
You
know
the
fact
that
Rob,
Stern
and
Morden
before
it
have
been
killed
by
people
sort
of
spanning
the
network
with
useless
transactions
is
indicative
of
what
happens
if
you
don't
have
any
value
behind
your
native
token
anyway.
The
other
place
that
I
wanted
to
show
you
just
before
we
actually
dive
into
the
code
is
like.
A
If
you
really
want
to
go
and
like,
if
you
know
nothing
about
solidity,
then
ether
noughts
is
quite
a
quite
an
advanced
like
place
to
start,
and
so,
if
you
really
want
to
learn
from
like
the
very
bottom
crypto
zombies,
not
IO
is
really
the
place
to
go.
They
have
some
really
really
awesome.
Tutorials,
it's
very,
very
interactive!
You
get
to
build
your
own
ssam
B's,
they
eat
crypto
kiddies,
it's
huge
amounts
of
fun
and
it
certainly
starts
at
a
lower
level.
A
If
you've,
you
know
if
you've
never
really
like
seen
much
code
before
in
general,
then
Apps
Script
zombies
is
the
place
for
you,
but
most
of
the
guys
on
this
call
I
think
are
developers
so
we're
gonna
dive
into
ether
noughts,
which
is
quite
a
bit
more
fun.
If
you
ask
me
from
just
the
technical
challenge
perspective,
so
what
even
Ott's
does,
if
you
sort
of
read
through
the
sort
of
short
abstract
here,
is
that
it
has
a
contract
called
ether
nodes
running
on
the
rough
stand
network.
A
And
then
you
can
call
that
directly
through
your
developer
console
and
when
you
know
guys
like
Gavin
woods
say
you
know
if
there
iam
is
this
global
computer,
that
all
you
need
is
the
JavaScript
way
of
socket
to
interact
with
and
program
on,
and
that
this
brings
like
a
completely
new
paradigm
shift
and
so
how
we
think
about
consensus
and
you
know,
sort
of
connection
with
each
other.
This
is
exactly
what
he's
talking
about
right.
A
A
It
should
pick
that
up
in
the
console
here,
you
can
see
that
it's
a
transaction
and-
and
this
is
also
really
useful,
because
you
know
I-
think
that
a
lot
of
the
other
ways
of
learning
solidity
don't
actually
interact
directly
with
live
network.
So
you
can
actually
like
see
the
delay
as
the
content
rights
get
deployed
and
get
a
better
sense
of
what
it's
actually
like
to
develop
for
real
on
ethereum
and
so
we've
we've
deployed
our
contracts.
A
We've
got
the
instance
address
spec
and
now
it's
sort
of
time
to
start
interacting
with
it
to
see
what
we
can
do
to
get
out
of
it,
and
they
give
us
the
first
thing
that
we
should
should
call
on
the
contracts
in
order
to
get
started,
trying
to
understand
what's
in
this
contract
and
what
we
need
to
do
with
its
in
order
to
complete
the
level.
So
if
we
wait
the
contracts
info
and
essentially
what
we're
calling
you
like
in
that
info
rights
is
just
a
public
variable.
A
That's
been
declared
and
clearly,
in
this
case,
a
string
and
what
it
returns
to
us
is
you'll
find
what
you
need
in
info,
one
right,
which
is
clearly
another
function,
that
we
need
to
call
that's
made
available
by
the
smart
contract.
So
when
you
declare
public
variables
in
solidity
and
it's
pretty
neat,
it
goes
and
sort
of
makes
automatic,
getter
methods
for
you,
which
is
why
we
can
just
directly
call
the
info
or
info
one
in
this
case.
A
A
See
that's
the
next
sort
of
so
we're
just
going
to
go
through
these
instructions
and
practice.
Essentially,
what
we're
doing
here
is
just
getting
used
to
the
idea
that
you
can
call
methods
on
a
smart
contract
directly
from
your
JavaScript
console
right
and
then
this
translates
obviously
very
easy
into
writing.
You
know
the
sort
of
basic
JavaScript
based
distributed
applications
that
will
live
with
the
in
status.
So
when
you
know
developers
are
working
with
our
API
and
status,
they
apply,
which
is
sort
of
the
SDK.
A
A
You
can
see
that
this
is
an
array
and
essentially
there's
the
number
42
being
stored
in
it.
So
there's
something
there's
something
about
42:
that
we
need
to
try
and
understand,
and
if
you,
if
you
take
a
look,
obviously
we've
got
sort
of
really
neat
autocomplete.
You
know
in
our
terminal
and
there's
a
method
on
this
contract
or
add
method
being
returned
by
the
ABI
and
that's
allowing
us
to
interact
with
that's
that
is
info
42.
So
why
don't
we
give
that
a
call
and
you'll
see?
A
A
So
we
haven't
yet
found
out
what
the
password
is.
So
it's
clear
that
we
can't
sort
of
call
or
fancy
Kate's
just
right
yet.
So
if
we
look
on
the
contract
objects
again,
it
turns
out
that
there
is
in
fact
a
password
a
password
object
as
well,
so
we
can
get
that
there's
the
password
and
now
the
last
thing
that
we
need
to
do
in
order
to
authenticate
with
our
smart
contract
submitted
and
move
on
to
the
actual
sort
of
trying
to
hack
the
contracts.
Part
of
this
tutorial.
A
Because,
in
this
case,
so
this
is,
you
know
quite
an
important
points
in
notes
as
to
like
why
I've
never
asked
us
for
to
sign
any
transactions
and
we're
calling
this
information.
But
as
soon
as
we
call
those
fancy
codes,
we
needed
to
sign
a
transaction
from
meta
mask,
and
this
is
because
any
read
when
you
call
data
from
from
ethereum.
That
is
for
free
right.
A
So
it's
only
writing
to
the
network
that
actually
costs
gas
and
therefore,
as
a
has
a
cost
associated
with
it
in
ether,
and
is
the
reason
that
you
sort
of
need
to
sign
off
on
that
from
your
accounts.
So
authenticate
is
clearly
changing
the
states
of
ethereum
and
therefore
we
need
to
pay
gas
in
order
to
cover
those
sort
of
state
changing
computational
steps,
whereas
when
we
recording
this
informational
stuff
that
was
leading
us
through
the
contracts
in
a
very
heavy-handed
way,
all
we
were
doing
was
reading
data
from
the
state.
We're
not
manipulating
it.
A
A
There's,
obviously,
some
really
really
fun
and
exciting
scaling
stuff,
that's
happening
at
the
moments
and
I
recommend
that's
you're,
going
to
check
out
the
ECC
videos
from
last
week
which
which
were
happening
while
we
were
in
Bangkok
and
there's
some
really
really
interesting,
scaling
talks
there
and
you
can
see
while
I've
sort
of
been
waffling
on
about
that.
That's
we've
submitted
the
instance
to
be
even
on
contractors
check
that
agrees
that
we've
gone
through
the
whole
thing
and
authenticated
ourselves
with
the
correct
password.
A
A
No
go
cool,
so
fall
back
has
to
do
with
with
sort
of
what's
going
on
in
act
in
the
actual
solidity
contracts,
and
this
is
the
first
time
that
we
get
to
look
at
sort
of
what
solidity.
What
sort
of
the
actually
looks
like,
and
it's
not
the
greatest
contracts
are
supposed
to
introduce
it
to,
but
if
you've
seen
JavaScript
before
then
a
lot
of
this
should
sort
of
make
sense.
What's
going
on
in
this
file
is
at
the
very
top.
A
What
we
need
to
do
is
sort
of
declare
our
compiler
version
of
solidity,
and
we
do
that
with
some
syntactic
sugar
called
pragna,
and
then
we
just
specify
the
version
at
the
moment.
I
think
the
latest
version
is
0
for
20.
That's
we're
still
working
with
0
for
18
yeah,
which
is
very
cold,
like
the
versions
come
out
fairly
regularly,
especially
minor
versions,
and
then
you
sort
of
have
access
to
import
other
contracts
into
your
own
contracts,
which
is
what
I
was
talking
about
in
terms
of
imagining
solidity.
A
Is
it's
sort
of
like
type
scripts
right,
strongly
type
Java
scripts,
but
it
has
this
notion
of
inheritance
with
its
rights.
So
if
you
imagine
a
contract
as
an
object,
then
it
can
inherit
properties
from
another
object.
In
this
case,
we've
written
a
contract
called
fallback,
and
this
fallback
contract
is
ownable,
which
is
one
of
the
contracts
that
comes
from
these
Zeppelin
solidity.
Libraries
that
provides
like
a
safe
pattern
for
ownership
of
contracts,
and
this
means
that
whoever
sort
of
deploys
this
fallback
contracts
will
be
the
owner
right.
A
A
So,
in
the
case
of
this
contract
that
we
were
just
looking
at
the
message,
sender
is
the
person
who
deploys
who
sends
the
message
that
deploys
the
contracts
and
you
always
like
I,
say
no
I,
don't
know
of
any
other
computing
environments
where
you
always
would
add
a
shadow.
The
dark
know
where
a
message
comes
from
and
it
allows
for
some
really
interesting
sort
of
features
around
computing.
There's
a
there's,
a
wonderful
video
from
gaved
from
very
early
on
I
think
DEFCON
1,
but
they
have
can't
sue
in
London.
A
The
that
goes
into
detail
about
why
provenance
was
such
an
interesting
feature
to
have
in
a
theorem
and
again,
like
I'll,
share
that
video
after
this
talk
is
done,
and
so
like
I
say
if
you
want
to
learn
more
about
solidity
like
cryptos
on
this
is
the
place
to
go,
but
here
what
we
want
to
try
and
do
is
claim
ownership
of
the
contracts
and
reduce
its
balance
to
zero
right.
So
this
is
where,
like
the
fun,
really
begins,
we
get
to
like
actually
think
about
like
how
do
we
hack
this
contract
right?
A
A
A
A
All
of
the
changes
consumes
all
of
the
gas
for
that
transaction,
and
it
puts
a
0
onto
the
stack,
so
it's
very,
very
difficult
to
debug,
whereas
using
a
require
sort
of
what
what
it
will
do
is
it
will
revert
the
transaction
rather
than
throwing
its
reverting
means
that
you
return
all
of
the
gas
that
hasn't
been
used
to
that
point
to
the
user.
So
it's
a
better
user
experience
and
it
puts
a
1
onto
the
stack.
So
it's
much
easier
to
debug
and
so
like
using
require
is
now
sort
of
standard
practice.
A
Again,
if
you're
going
to
read
this
to
the
docs,
there's
lots
of
stuff
in
there
about
it.
Essentially,
we
just
need
to
make
sure
that
the
value
of
the
message,
which
is
another
global
variable
available
and
solidity,
is
greater
than
0.01
eath
and
then
a
bunch
of
stuff
will
happen.
So
the
contributions
mapping
for
the
address
of
the
person
who
sent
that
gets
increased
by
the
value
that
they
sense
and
if
that
contribution
is
greater
than
the
contribution
of
the
owner,
then
the
owner
becomes
the
person
who
sent
the
message.
A
Remember
that
the
contribution
of
the
owner
here
is
set
to
a
thousand
ether
which
we
clearly
don't
have.
So
that's
there's
nothing
really
there
that
we
can
do
to
get
into
the
contracts.
What's
most
interesting.
I
suppose
is
this
fallback
function
right
so
clearly
like
the
name
of
the
tutorial
is
pointing
us
to
it's.
The
fallback
function
gets
called
when
you
send
a
transaction
to
the
contract
without
specifying
what
function
you
want
to
call,
or
that
has
yeah
and
generally
it's
made
payable,
because
this
is
how
you
send
ether
to
contracts.
A
So,
if
I
send
ether
to
this
contracts
without
specifying
a
method
on
it,
it
will
automatically
call
this
fallback
function,
and
this
fallback
function
requires
that
the
message
value
is
greater
than
zero
and
that
the
contributions
of
the
message
sender,
like
is
greater
than
zero.
So
we'll
need
to
update
that
mapping
first
and
then,
if
we
send
another
message
that
has
a
value
greater
than
zero,
we
will
become
the
owner
right.
So
this
is
clearly
like
the
the
vulnerability
in
this
contract.
A
It's
pretty
easy
to
see,
and
all
you
need
to
know
is
that,
in
order
to
call
the
fallback
function,
you
just
use
send
transaction,
which
is
a
method,
that's
sort
of
globally
available.
So
we've
got
our
instance
address
there
like
it's
pretty
simple
here.
All
we
need
to
do
is
like
awaits
the
contracts.
The
first
thing
that
we
want
to
do
like
I
said,
is
I
update
this
contributions,
mapping
right
so
that
we
can
pass
that
second
part
of
the
conditional
here.
A
So
if
we
contributes
and
the
way
that
we
send
like
value
and
when
we
call
so
generally
you'd
sort
of
make
a
call
like
that
and
maybe
pass
through
some
parameters,
if
there
were
but
with
ethereum,
you
can
pass
in
an
extra,
an
extra
little
JSON
blob
and
that
you
can
add
a
whole
lot
of
information
in
about
like
the
gas
price,
the
value
and
the
data
associated
with
each
call.
So
in
this
case
we're
already
interested
in
the
value,
and
we
want
to
make
sure
that
it's
greater
than
0.01
e
right.
A
So
this
is
like
a
little
bit
of
a
subtlety.
Everything
in
aetherium,
like
all
amounts,
are
passed
in
in
way,
not
eath.
So
we
need
to
sort
of
understand
hum
like
how
much
value
we
actually
need
to
put
into
this,
because
it's
being
passed
in
a
way,
not
each.
So
we
need
to
make
sure
that's
greater
than
0.01,
let's
just
say
open,
so
there's
the
way
amounts.
So
we
can
grab
that
I'll
also
drop
that
link.
A
A
B
A
Good,
look
instead
of
succeeded,
so
we
should.
We
should
be
okay,
the
way
that
we
can
check,
that
is
by
looking
at
the
the
mapping
contributions,
but
it's
just
let's
just
carry
on
week,
because
time
is
short
here.
So
if
we
we've
now
sort
of
updated
that
contributions
mapping.
The
next
thing
that
we
want
to
be
able
to
do
is
call
this
payable
routes
over
here.
The
fallback
function.
A
A
Excuse
me,
but
let's
just
do
it
again,
yeah.
Why
don't
take
away
a
zero
there?
We
go
that
should
not
throw
an
error
this
time.
That
looks
much
better.
Excuse
me,
but
once
that
contributions
mapping
has
been
updated,
we
should
be
able
to
call
the
full
back
function
need
to
wait
for
it
to
be
mined,
which
is
always
a
bit
of
a
bit
of
a
bug
swine's
away
for,
but
this
is
the
nature
of
the
the
beast
when
developing
on
ethereum.
A
You
can
set
up
the
next
transaction
while
we
wait
for
that.
There
we
go
mind
so
now
we
can
send
a
transaction
for
the
full-back
function
and
this
one's
value
just
needs
to
be
greater
than
zero
right.
So
we
don't
need
to
give
it
a
lot
just
a
little
bit
to
register.
It
really
doesn't
matter
you
can
put
in
a
hundred
or
ten
there.
A
It's
fine,
a
transaction
in
meta,
mask
wait
for
it
to
get
mind,
so
the
reason
that
they're
sort
of
going
through
this
whole
fullback
thing
is
that's
like
I
said,
a
lot
of
people
include
this
payable
fullback
function
in
their
contract,
so
that
the
contract
can
receive
ether.
But
it's
really
really
really
important
that
you
pay
close
attention
to
what
you
actually
allow
people
to
do
in
their
fallback
function
and
especially
like
the
order
in
which
you
go
about
writing
things
in
that
fallback
function.
A
The
other
thing
is
always
do
like
optimistic
accounting,
which
is
something
that
we'll
come
to
in
sort
of
re-entrance
II,
which
is
like
rather
sort
of
behave
as
if
the
transaction
has
already
gone
through
by
updating
balances.
In
a
specific
way,
so
that
you
don't
open
yourself
up
to
this,
this
notion
of
re-entrance
II,
which
is
how
the
dow
got
hacked
and
something
that
we'll
come
to
in
a
while
and
see
that
our
transaction
has
gone
through.
A
So
now,
if
we
look
at
the
owner
of
the
contracts,
it
should
be
us
that's
Derek's,
FD
which,
which
it
is
right,
there's
our
address,
so
we
can
be
pretty
sure.
That's
we've.
We've
managed
to
take
ownership
of
this
contracts,
and
now
sort
of
all
we
need
to
do
right
is
withdraw.
So
you
can
see
this
one.
It's
gonna
transfer
literally
the
balance
of
this
contracts
to
the
owner,
seen
as
with
the
owner,
we're
sort
of
more
than
happy
to
call
it.
So,
let's
awaits
for
contracts
brawl.
We
don't
need
to
pass
anything
to
that.
A
We
will
need
to
sign
a
transaction
because
obviously
the
the
transfer
over
here
as
a
state
changing
transaction
again.
So
there
is
a
gas
cost
associated
with
this,
and,
while
this
one
mines
in
before
we
submit
it's
like
it's
worth
just
going
into
like
a
little
bit
more
detail
about
gas
and
what
it
actually
is
so
that's
actually
be
in
mind.
Very
fast,
like
gas
is
guess,
is
the
way,
I
suppose
in
which
ethereum
overcomes
some
security
concerns
around
allowing
it's
your
incomplete
language
to
to
run
on
the
blockchain.
A
A
So
currently
that
gas
limit
is
sitting
like
somewhere
just
above
7
million,
and
that's
like
gas
is
literally
just
an
arbitrary
measure
that
you
pay
per
computational
cycle
of
the
EVM,
the
etherium
virtual
machine
so
like
each
computational
step
costs
a
certain
amount
of
gas
and
then
gas
costs
a
certain
amounts
of
ether
right,
which
is
how
we
sort
of
tie
this
mechanism
for
achieving
deterministic
computation
ie.
You
can't
have
more
computation
than
per
block
than
is
defined
by
the
gas
minutes
to
the
notion
of
my
crypto
economics
right.
A
So
there's
this
cost,
if
you
want
to,
you,
know,
submit
a
whole
bunch
of
spam
transactions
and
try
and
like
DDoS
or
civil,
the
network
there's
this
actual
economic
cost.
In
addition
to
you
know,
making
sure
that
we
can
still
have
deterministic
computation
with
with
a
Turing
complete
language,
which
is
pretty
neat
when
you
really
think
about
it
and
I'm
more
than
willing
to
explain
like
a
little
bit
more
because
I
know
that's
some
people,
especially
the
developers
that
get
a
little
bit
lost
when
we
talk
about
gas.
A
But
as
long
as
you
remember,
it's
like
there's
a
gas
limit
per
block
which
limits
how
much
computation
can
get
done
and
that's
like
gas
is
just
an
arbitrary
units
used
to
measure
like
each
computational
step.
That
is
then
linked
by
the
yellow
paper
to
a
price
in
ether.
Then
you'll
be
fine
mm-hmm,
so
this
transaction,
oh
I,
haven't
signed
its
weights
off
about
gas
about
signing
us.
Excuse
me:
there
you
go,
we
should
we
should
get
that
in
mind
and
get
through
in
the
next
time.
A
I'm
I'm,
not
sure
that
we'll
have
enough
time
to
go
through
all
of
these,
but
I
will
do
as
many
as
we
can.
You
can
see.
We've
passed
a
level,
that's
super,
exciting,
I,
really
love
this
console
art
done
by
the
Zeppelin
guys
as
well.
If
you
ever
watch
this,
you
guys
really
Rock.
This
is
awesome,
so
we
can
move
on
to
the
next
level,
which
is
which
is
called
fallout,
is
like
a
pretty
city
contracts,
but
that's
let's
go
through
it.
If
we
just
get
in
the
instance.
A
Cool,
so
you
can
see
a
importing
ownable
this
time.
What
we're
trying
to
do
is
claim
ownership
of
the
contract
again
right.
So
it's
like
in
this
clearly
something
else.
That's
wrong.
With
this
contract.
You
can
see
that
we
don't
have
nearly
the
same
set
up
as
last
time
right,
there's,
no
there's
no
sort
of
obvious
fallback
function
to
attack.
A
There's
no
obvious
in
in
fact
to
this
to
this
contract
right.
If
you
take
a
look
through
it
and
you
can
kind
of
satisfy
yourself
there
we
go
deployed,
you
can
satisfy
yourself.
In
fact,
it's
very,
very
difficult,
in
fact,
impossible
at
first
glance
to
manipulate
any
part
of
this
contract
in
order
to
claim
ownership.
But
if
you
look
at
the
constructor
as
its
labeled,
it
sets
the
owner
to
whoever
sends
the
messenger.
A
A
Our
code
is
open
source
and
you
can
take
and
look
at
it,
but
they
can
be
kind
of
misleading
because
you
know
you
really
have
to
sometimes
read
very
carefully
smart
contracts
in
order
to
understand
exactly
what
they're
doing
and
if
you
look
here
like
this
contract
is
called
fall
out.
But
if
you
actually
take
a
look
like
closely
at
what's
been,
labeled
is
the
constructor.
It's
actually
FAL
one.
Oh
you
see,
which,
like
I,
says
it's
annoying,
but
like
it's
really
really
important
to
realize.
A
That's
something
as
simple
as
that
can
change
entirely
the
behavior
of
a
smart
contract
right.
So
this
because
it's
a
different
name
is
not
actually
the
constructor
and
will
not
be
called
when
the
contract
is
deployed
right,
it
can
be
called
by
anyone.
You
can
see,
that's
like
in
solidity
and
I
suppose
this
is
the
other
important
thing
that
I
should
have
mentioned
earlier.
Is
you
have
all
of
these
like
scope,
declarations
that
you
need
to
make
one
of
the
things
to
be
super
aware
of
when
you're
writing,
smart
contracts
and
working
in
solidity?
A
Is
that
functions
and
variables
default
to
public,
which
is
obviously
like
a
hotly
debated
pattern,
and
there's
lots
of
there's
been
ongoing
debate
for
like
years
about
exactly
why?
That
is
the
case
and
whether
it
would
be
better
to
default.
The
privates,
which
a
lot
of
people
do
feel
is
the
case,
but
it
stayed
this
way
for
now.
A
So
this
function
is
public
right,
which
means
that
anybody
can
call
it,
and
if
you
sort
of
refer
to
that
cheat
sheets
on
somebody
that
I'll
send
out
the
the
sort
of
scope,
declarations
that
you
can
call
are
public,
which
means
every
anybody
can
call
its
external,
which
means
only
people
outside
any
like
contracts
and
people
external
to
that
contract
can
call
it.
Then
you
get
privates,
which
is
only
people
within
the
inheritance
graph
of
of
this
contracts
right.
A
So,
if
you
have
like
fallout
is
ownable,
then
fallout
can
still
called
private
methods
in
ownable,
whereas
internal,
which
is
the
next
went
down.
That
means
that
only
con,
like
only
functions
in
this
contract
can
call
it
so
yeah
like
sort
of
external
public,
privates
internal
and
then
there's
a
few
others
like
pure
and
constants
and
view
and
payable,
but
they
all
sort
of
relates
to
specific
instances.
A
A
Like
a
bit
of
an
annoying
one
like
I
say,
but
it's
really
really
important
to
sort
of
like
really
drum
it
into
people
that,
even
though
the
code
is
open
source,
you
have
to
be
careful
when
you
read
this
stuff-
and
you
know
it's
obviously
like
it's
the
sort
of
thing,
that's
that
auditors
would
go
looking
for
in
dodgy
I,
SEOs
and
and
that
sort
of
stuff.
So
let's
just
take
a
look
at
stoner.
We
expect
it
to
be
ourselves
which
it
is
fantastic,
so
we
can
submit
this
instance.
A
B
A
A
B
Maybe
also
there
is
another
security
vulnerability
that
it's
not
maybe
it's
not
mentioning
there,
but
our
race
conditions
when
you
send
transactions.
Do
you
don't
actually
can
be
assured
that
your
transaction
is
going
to
get
mean
it
or
when
it's
going
to
be,
and
also
there
is
another
card
to
it
that
turns
out
when
you
send
it
to
the
network
everything
you
send
its
public
then.
So
there
is
some
cases
on
where
in
some
transactions
like,
for
example,
which
are
revealing
a
secret
for
don't
know
where
a
deed,
don't
know,
many
contacts
can
use
secrets.
A
Yeah
yeah
this
is
this
is
a
very
good
points
to
make,
particularly
as
we
wait
an
unusually
long
time
for
for
one
of
our
transactions
to
be
mined,
which
it
finally
has
been.
But
Ricardo
is
exactly
right.
One
of
the
key
like
problems,
for
instance,
like
the
best
way
of
describing
this,
is
like
one
of
the
key
problems
for
the
centralized
exchanges
operating
on
ethereum.
Is
that
there's
sort
of
two
opportunities
to
front
run
trades
right,
like
he's
like
like
Ricardo,
says
when
you
submit
a
trade
even
in
a
supposedly
secret
formats.
A
So
what
we
want
to
do
here
right,
it's
a
very,
very
basic
token
contract,
and
we
can
see
that
essentially
like
there's
a
constructor
that
gets
called
and
sets
the
balances
mapping
for
whoever
sent
that
message
to
the
total
supply,
which
is
just
the
initial
supply.
So
whoever
deploys
this
contract
gets.
Whatever
they
passed
in
is
the
initial
supply
when
deploying
and
then
there's
just
two
other
roots
right,
balance
of
which
simply
returns
that
mapping.
So
there's
nothing
really
interesting
for
us
to
look
at
yeah
and
then
this
transfer
function.
A
A
A
That's
what
they're
essentially
saying
there,
but
the
problem
with
this
right
is
that
we've
declared
value
as
an
unsigned
integer
and
we've
declared
balances
and
unsigned
integer,
and
so
like
that.
Statements
is
always
true,
and
what
we
can
do
is
we
can
actually
cause
an
integer
and
the
flow
by
sort
of
calling
this
transfer
function
with
any
address
and
a
value
that
is
greater
than
20
right,
because
that
will
that
will
cause
an
integer
and
the
flow
in
this
require
which
will
assign
to
us
an
absolutely
massive
value
in
tokens.
A
What
we're
looking
at
here
is
tokens
are
just
these
mappings
of
addresses
to
unsigned
integers
that
represent
the
balances
associated
with
those
addressing
in
a
smart
contracts
and
obviously
like
the
smart
contracts
exists
everywhere.
But
it's
pretty
just
it's
just
like
any
interesting
philosophical
point
to
consider.
A
This
is
actually
what
tokens
are
and
if
you
write
smart
contract
in
this
way,
which
seems
secure
at
first,
you
can
cause
like
an
institute
and
the
flow
which
will
assign
me
like
an
absolutely
massive
number
of
tokens,
where
I
can
sort
of
get
like
to
256
minus
one
kind
of
thing
yeah.
So
if
I,
if
I
awaits
this
contract,
I
want
to
call
the
transfer
function.
A
A
And
that
will
be
mine,
hopefully
soon.
So
the
reason
that
this
is
included
is
like
integer
under
flows
are
very,
very
bad
in
solidity.
Right
they
happen
all
the
time
in
JavaScript,
obviously,
but
like
there's
no
sort
of
money
associated
with
them,
whereas
there
is
here
potentially,
so
you
really
need
to
watch
out
for
them.
A
The
way
that
you
generally
watch
out
for
them
is,
and
the
reason
I
suppose
that
the
Zeppelin
guys
have
included
this
in
their
tutorial
is
that
they've
written
a
contract
called
safe
math
which
allows
you,
instead
of
doing
this
kind
of.
Like
addition
in
smart
contracts,
you've
got
like
safe,
add
or
subtract
or
multiply
functions
that
you
can
call,
and
that
will
do
it
in
a
safe
manner
for
you
and
make
sure
that
this
sort
of
feature
doesn't
happen
right.
A
So
the
transactions
gone
through
if
I,
try
and
look
at
the
contract,
I
mean
the
balance
of
my
account.
Now,
right,
you
can
see
that's
if
I
go
into
that,
there's
absolutely
huge
beast
of
the
number
rights
to
the
77
as
opposed
to
20
before
so
so,
I've
gone
and
paused
an
integer
under
flow
and
thus
balances
mapping
and
and
got
myself
a
massive
amount
of
tokens.
So
I
can
submit
the
instance
and
off
we
go
hopefully
see
some
more
awesome.
A
A
As
it's
been
adopted
in
the
IETF,
it's
just
like
it's
a
really
really
great
way
of
thinking
about
governance.
It's
not
directly
related
to
what
we're
talking
about
here,
but
it's
really
really
important
for
the
ecosystem
and
the
more
the
more
people
that
we
have
they're
actively
debating
this
stuff
in
a
constructive
manner,
which
I
know
everybody
has
status,
is
capable
of
doing
then
the
better
for
everybody
in
general,
and
that's
obviously
like
our
goal
at
state
Australia's
to
be
this
crystal
clear
window
and
say
etherium
and
to
improve
the
ecosystems
first,
always
so.
A
You're
gonna
take
a
look
through
there
and
how
can
be
used
to
delegate
operations?
These
unchained
libraries
right,
which
is
what
resulted
in
that
famous,
gets
up
comments
like
oops
I
accidentally
killed
it,
which
referred
to
the
parody
multi-sig,
which
had
millions
and
millions
locked
up
in
its
and
is
like
I
say
stole
a
bone
of
contention
about
how
exactly
or
if
they're,
going
to
recover
those
funds.
And
so
here
is
like
the
very
basic
contracts.
You've
got
delegates
right,
it
has
an
owner
which
gets
sets
in
its
constructor
and
then
it's
got.
A
This
function
called
pawn
which
sends
the
like
sets
the
owner
to
ever
manages
to
call
that
and
then
here's
the
delegation
contracts,
it
declares
its
delegate
objects
and
then
it
has
this
fallback
function
and
it's
not
necessarily
payable.
That's
the
fallback
function
calls
delegate,
call
passes
of
the
message,
data
and
that
will
sort
of
like
delegate
the
call
on
to
delegates,
which
is
this
contract
here,
and
if
you
call,
if
you
pass
in
the
right
message
data
you
can
call
this
right.
B
These
bug
it's
actually
about
the
first
parity
but
I
guess
because
they're
there
there
was
two
pirate
bugs
for
the
this.
This
delegation,
woman,
was
about
you
taking
our
ownership
of
any.
Would
you
see
wallet
because
the
the
the
initialization
function
cool
was
like
open
to
anyone
and
the
other
was
about
this
killing?
Yes,.
A
Sorry
you're
absolutely
right,
and
this
was
the
first
one,
so
this
was
when
anybody
could
take
control
of
the
parity,
multi
SIG's,
which
is
kind
of
worse
but
but
yeah.
Clearly,
those
multi-sig
wallets
were
not
well
written
and
we
highly
recommend
like
the
nicest
ones
they
much
much
better
and
have
been
audited.
So
this
is
how
we
can
sort
of
take
control
of
it.
We
need
to
figure
out
what
the
actual
function
signature
for
porn
is
and
I
suppose.
A
This
is
why
this
is
part
of
the
tutorial,
because
it's
just
something
I
suppose
that
you
need
to
know
about
how
we
actually
compose
function,
calls
on
a
Feria
mat
like
in
the
bytecode
itself,
in
order
to
pass
through
the
right
message,
data
to
make
this
call
here.
What
we
need
is
the
first
four
bytes
of
the
kick
act:
256
signature
of
the
256
hash
of
the
function
signature.
A
So
let
me
say
that
again,
the
first
four
bytes
of
the
kick
act,
256
hash
of
the
function,
signature
right
and
then
we
add
0x
in
front
of
that.
So
if
you
put
in
your
function,
signature
whatever
it
is
in
this,
it
happens
to
be
porn
but
like
if
you
had,
if
you
had
parameters,
you
would
pass
in
their
types
rights.
A
So
that's
what
we
need,
plus
a
0
X,
and
what
we
want
to
do
is
we
want
to
sort
of
awaits
this
contract
call
again,
as
we've
been
doing
and
we're
just
gonna,
send
it
a
transaction
here
right,
because
we
want
to
call
this
pullback
function.
So
there's
no
need
to
call
like
any
of
the
routes
on
its
right.
See.
If
I
can
spell
that
right,
then
transaction,
we
don't
want
value
this
time.
What
we
want
is
data
and
there's
lots
to
be
said
about
like
this
notion
of
data
right.
A
Okay,
so
you
need
to
actually
add
a
zero
X
in
front
of
it
in
order
to
call
the
function.
Signature
again
like
there's
this
wonderful
video
from
gab
from
very
early
on
in
ethereum,
which,
like
explains
this
notion
of
like
everywhere,
there's
data,
there's
network
and
everywhere,
there's
Network
this
data,
and
this
is
again
one
of
the
most
interesting
things
about
these
kind
of
networks.
A
So
you
can
see
here
that,
like
making
it
called
surf,
action
is
as
easy
as
putting
in
like
the
data
and
that,
like
literally
in
the
byte
code,
this
is
how
it
gets
composed
with
a
zero
X
in
front
and
then
the
sort
of
first
four
bytes
of
the
cake
acts
in
five
six
hash,
and
then
you
append
onto
that
pad.
It's
256
bits.
All
of
all
of
this
sort
of
parameters
that
you're
passing
in
again
like
Jacques
vecna,
is
probably
the
best
person
in
the
organization's
asked
about
this
kind
of
stuff.
A
If
you
want
like
a
much
clearer
picture
of
what's
actually
happening
like
as
these
solidity
contracts
get
compiled
down
and
deployed
onto
the
network
for
some
of
the
next
tutorials,
we
actually
going
to
need
to
write
like
our
our
own
contracts,
as
you
can
see
here,
sort
of
got
someone
in
prepared.
So
this
is
a
great
place
to
come,
and
then,
if
you
show
you
now
I
suppose
exactly
what's
what's
going
on,
maybe
we
should
have
this
being
lined
there
we
go
and
we
should
be
able
to
send
that
same
transaction
I'm,
a
damask.
A
And
wait
for
it
to
remind
the
other
cool
place
where
you
can
go
if
you
want
to
see
like
low-level
contract
details
and
actual
like
up
codes,
especially
of
live
calls.
It's
what
we
use
a
lot
for
status.
Open
fancy
is
neat
the
scan
that
IO
itself.
If
you
pass
in
sort
of
remix
as
a
get
query,
then
you
can
actually
get
the
the
same
sort
of
debugging
and
stack
tracing
like
that
is
available.
It's
available
over
here.
A
You
can
do
like
a
full
stack
trace
whenever
you
deploy
contracts
and
stuff,
and
this
same
thing
is
available
on
eat
the
scan
itself
and
can
help
you
sort
of
try
and
debug
any
live
transactions
that
you
might
have
been
struggling
with.
We
should
we
should
be
good
there.
The
transaction
is
being
has
been
sent
through.
So
if
we
look
at
the
contract
owner,
let's
see
if
we
ever
managed
to
take,
we
have
great.
A
Obviously,
not
before
we
gets
another
great
start
from
I'm
setting
in
the
console
here,
so
we
got
two
minutes
left
and
I.
Do
very,
very
briefly
want
to
show
you
this
this
remix
browser,
because
this
is
actually
where
you're
sort
of
gonna
come
as
we'll
come
back
to
this
yeah.
This
is
where
you
going
to
come
to
write
your
own
smart
contract.
A
So
this
is
basically
like
a
browser-based
IDE
for
solidity,
and
you
can
come
here
like
it's
very,
very
easy
to
write
your
own
smart
contracts,
it's
right
through
very,
very
quickly
and
see
like
what
works.
What
doesn't
so?
You
can
obviously
like
compile
each
thing
as
you
go
through,
so
when
we
are
sort
of
well,
at
least
when
I'm
writing
smart
contracts.
This
is
where
I'll
come
to
test
stuff
and
then
obviously,
like
once
I'm
happy
that
they're
compiling
properly
that
they're
doing
the
things.
A
Here
you
can
specify
an
address
as
the
reward
mining
destination.
So,
if
you
mine
a
block
and
you
get
a
reward
for
it,
you
can
specify
an
address
and
send
either
to
its
and
it
will
sort
of
automatically
receive
it
and
you
can
send
either
to
a
contract
before
its
creation,
which
is
a
slightly
more
complicated
process.
But
I
don't
really
want
to
go
into
it.
But
it's
just
again
like
it's
important
that
ties
into
what
we
were
talking
about
in
terms
of
the
fallback
functions
right.
A
Is
that
like,
even
if
you
think
like,
if
you
have
a
routes
in
your
contract,
that
you
think
no
one
would
be
able
to
ever
call
because
you
can't
send
ether
like
there's
some
kind
of
logic
that
you're
sort
of
relying
on
that
is
external
to
your
contracts.
It
can
be
a
very,
very
dangerous
pattern
for
developing
smart
contracts,
because
there
are
these
like
sort
of
caveats,
about,
for
instance,
the
fact
that
the
reward
mining
dress
address
destination
can
be
sets
and
like
contracts,
can
self-destruct
and
send
either
to
certain
places.
A
So
if
the
security
of
your
contract
that
and
that's
obviously
not
a
great
thing,
I
don't
have
the
time
so
that
go
fully
into
like
the
rest
of
the
stuff,
but
it's
really
well
worth
it.
If
you
want
to
chat
to
me
afterwards
about
how
to
do
the
rest
of
these
things,
I'll
get
links
to
other
folks
who
have
written
about
going
through
them.
Then
please
do
thanks
so
much
for
taking
the
time
to
listen
through
all
of
this
and
like.
A
Hopefully,
it
was
useful
to
you
guys
and
please
just
put
all
your
feedback
in
the
study-
fundamentals,
Channel
and
then
we
can
use
that
to
actually
put
together
some
ready,
useful
development
resources
for
status,
specifically
as
as
we
get
us
into
our
closed
beta
and
onto
the
main
network
and
all
the
exciting
things
that
are
coming
in
the
next
few
months.
So
yeah
thanks
again
and
I,
guess:
I'll
see
you
next
time.