►
From YouTube: CasperLabs Weekly Workshop 5/07: Vesting Part 1
Description
During this workshop, we will demonstrate CasperLabs' Vesting Contract implementation.
To attend the next workshop, visit: https://bit.ly/2TQnXfM
Follow Us: https://twitter.com/meetCasperLabs
General Discussion: https://t.me/CasperLabs
Technical Discussion: https://discordapp.com/invite/Q38s3Vh
A
A
A
A
A
First,
we
define
the
vesting
error.
These
are
fewer
that
that
can
happen.
Let's,
let's
discuss
these
errors,
not
in
our
balance,
and
so
not
enough
balance
will
be
thrown
when
the
user
who's
eligible.
Who
can
withdraw
some
tokens
want
to
withdraw
more
than
he
wants.
So
if
it's
possible
to
withdrew
ten
and
he
must
withdraw
sixteen,
then
you
get
this
error.
A
Okay,
another
feature
that
I
haven't
told
you
about,
isn't
having
admin
I
mean
instance.
Why?
Because
admin
is
a
person
that
is
responsible
for
managing
this
vesting
smart
contract
and
what
is
managing
here?
Managing
is
first
deploying
the
contract
and
second
pausing
and
unpausing
the
contract
and
also.
A
Withdrawing
like,
let's
say
someone
quits,
the
company
I
told
you
this.
This
example
before
that
I'm,
a
member
of
the
company
and
as
long
as
I
work
at
the
company
I
can
withdraw
100
tokens
month
and,
let's
say
suddenly,
I
decide
to
change
my
work
or
I.
Don't
do
good
and
that's
even
better
I
don't
perform
well,
and
my
supervisors
sees
that
and
said.
Oh,
this
guy
doesn't
work
as
he
supposed
to
like.
We
should
fire
him
so
what
they
do.
They
could
pause
the
contract,
testing,
contract
and
I.
A
Will
not
get
the
ability
to
take
more
than
I
already
earned,
and
this
is
the
functionality
of
pausing
and
unpausing
and
let's
say,
I
walk
I'll
meet
with
my
admin
and
say:
look
I
did
everything
because
I
just
didn't
adjust
my
JIRA
tickets
but
I
have
everything
and
I
said:
oh
yeah
yeah,
you
good
sorry
for
that,
and
then
they
will
unpassed.
They
can
unpause
the
contract
and
the
time
starts
counting
again
for
me,
but
it
is
important
to
to
notice
that
there
was
a
gap
in
the
counting.
A
Okay,
so
now
let's
say
we
have
a
different
version
of
this
story
when
they
post
my
accountant,
my
vesting
contract
I
mean
post
my
testing
contract
and
they
actually
fired
me
and
because
there
is
a
lot
of
tokens
that
are
inside
the
vesting
contract,
because
this
is
how
it
works.
The
company
will
put
a
lot
of
tokens
into
the
vesting
contract
and
those
tokens
will
be
their
mine,
but
I
will
get
the
access
to
this
2,000
overtime,
so
those
tokens
are
dead,
but
they
fired
me.
A
And
those
are
cliff
timestop
cliff
is
this
feast
period
of
waiting
so
and
we
have
also
cliff
amount
and
the
contract.
Girls
like
this
wait.
First,
at
the
cliff
time
step,
you
can
withdraw
cliff
amount,
so
wait
one
year,
and
then
you
will
get
25%
of
of
all
the
tokens
that
are
inside
the
contract
and
then
every
month,
so
we
say
every
trip
because
so
and
the
duration
would
be
like
a
week
a
day.
24
hours
could
be
anything
you
can
withdraw
this
amount
until
you
get
everything
and
those
are
the
parameters
for
this
contract.
A
A
A
Unpause
duration.
This
is
a
sum
of
all
the
pauses
that
happened
so
let's
say
I
paused
the
contract.
Now
I
wait
one
day
and
unpause
it.
So
this
unpause
duration
would
be
one
day
and
after
sometime,
I
pause
it
again
for
a
half
day
and
unpause
it
at
the
end,
so
the
uncut
version
would
be
day
and
a
half
in
seconds.
A
A
A
A
Set
three
times
up
here
and
what
it
does
it
executes
set
time
and
it
takes
a
key
and
it
takes
a
value
and
set
time.
Scroll
down
is
an
abstract
method
that
should
be
implemented
by
the
blocking.
So
here,
I
have
set
amount
and
get
that's
gather,
get
amount
set
time
time
get
set,
boolean
and
boolean,
and
it
means
that
in
the
smart
contract,
I
need
to
only
implement
those.
A
A
A
A
A
A
A
A
A
Okay,
let's,
let's
do
the
withdraw
in
this
implementation,
so
let's
say
it
is
possible
to
withdraw
some
some,
the
on
they're,
not
down
there.
The
user
of
this
contract
decides
okay,
I
want
to
withdraw
some
tokens
and
you
cannot
be
in
few
situations
here.
So,
first
of
all,
he
wants
to
withdraw
more
than
it's
possible
and
let's
see
how
the
system
checks,
how
much
token
is
possible
to
withdraw
how
many
dollars?
A
A
A
Okay,
so
here
we
will
calculate
cliff,
timestamp
adjusted,
which
is
exactly
and
what
I
said.
So
we
add
total
post
duration
to
the
cliff
time,
because
if
the
someone
was
on
post
before
the
cliff
happens
and
then
then
we
need
to
postpone
this
cliff
time
for
a
bit
and
if
the
current
timestamp
is
before
this
this
moment,
then
the
user
is
not
eligible
to
withdraw.
Anything
so
amount
should
be
zero.
A
A
So
if
drip
duration
is
zero,
this
is
another
piece
of
the
logic
because
you
could
set
the
drip
duration
to
zero.
So
we
said
that
every
zero
be
every
zero
time
you
get
some
amount,
but
in
the
system
it
means
that
you
just
don't
specify
it's
just
like
disable.
This
feature
of
drift,
so
this
period,
so
zero
you're
not
available
to
to
have
anything.
A
Now,
let's
get
the
total
amount
of
tokens
that
halt.
Let's
get
amount
of
tokens
released
by
every
trip
and
let's
read
how
much
was
already
released,
and
we
do
this
piece
of
logic
that
sides:
let's
let's
do
the
counter:
let's
count
it
so
we
initialize
counter
with
the
cliff
amount,
so
the
amount
of
tokens
that
should
be
a
variable
at
the
cliff
time
with,
and
then
we
update
this
counter
by.
A
Like
this,
so
how
many
trips
was
there
available
drips
time
strip
amount?
So
how
many
this
trips
moment
happened
times?
How
many
tokens
in
this
particular
single
drip?
You
could
get
and
we
update
this.
So
we
already
added
the
cliff
amount
and
amount
in
drips
and
then
that,
if
you
define
let's
say
you
define
you,
ask
the
contract
after
a
long
long
time
and
this
dream
this
available
chip
becomes
large.
A
A
A
If
I
want
to
withdraw
more
than
then
it's
possible
to
withdraw
so
that
comes
from
the
amount.
This
is
the
amount
I
want
to
withdraw,
so
an
error.
If
not
then
check
the
released
amount
and
update
the
released
amount.
So
the
dis
method
just
marks
how
much
it
checks
if
I
can
would
withdraw
this
amount,
but
also
it
updates
the
already
released
amount.
And
after
this,
the
smart
contract
should
do
the
transfer.
A
A
That
just
says,
and
totally
how
much,
how
much
time
last
on
bonds-
and
so
the
last
important
piece
of
logic-
is
admin
the
release
method.
It
should
be,
it's
also
bookkeeping
and
it
should
be
called
only
by
admins
and
let's
see
how
it
goes.
First,
it
checks
whether
it's
on
if
the
contract
is
already
post.
If
the
contract
is
not
post,
then
there's
nothing
to
do
here.
Okay,
but
the
contract
is
post.
So
what
do
we
do?
Let's?
A
First,
let's
check
what
is
the
last
time
post
then
calculate
time
and
how
much
time
last
from
the
post
from
the
last
post
then
check
how
much
time
should
shoot
the
contract
be
post
and
if
the
time
of
the
last
pass
is
less
than
required
waiting
duration,
then
the
admin
didn't
wait
long
enough.
So
return
an
error.
But
if
that's
not
the
case,
then
the
admin
can
can
withdraw
the
tokens.
So
first,
let's
check
the
total
amount
check
the
released
amount.
A
If
the,
if
that's
not
the
case,
then
count
how
many
tokens
it
is
possible
to
withdraw
and
return
this
value,
so
so
the
smart
contract
when
using
this
function
will
know
how
many
tokens
to
transfer
back
and
actually
then
then
updates
the
released
amount
to
the
total
amount.
So
this
will
happen
when
the
admin
would
would
call
this
function.
Mixer
and
that's
it.
A
A
A
So
the
new
just
initializes,
the
config
and
I,
also
put
a
set
current
timestamp,
so
in
blockchain
this
will
come
from
the
block
itself,
but
for
the
test
you
need
to
set
the
time
manually
and-
and
here
is
all
the
implementation
of
the
vault
of
the
betting
trade
for
the
vault.
So
as
I
said
before,
it
is
required
to
implement,
set
time
set
amount
and
the
amount
so
here
I
have
gathers
and
inserts
for
those
three
Maps.
A
What
could
be
also
hashmap
same
thing
very
similar,
okay
and
from
here
it
is
possible
to
to
test
it.
Let's,
let's
walk
through
one
test
and
there's
many
tests,
so
we'll
walk
through
one
and
you
can
do
the
rest
if
you're
interested
at
home.
So
let's
test
pausing
50
have
to
create
a
vault,
it's
beautiful.
So
and
now
we
define
this
scenario.
So
first
pass
will
happen
at
time
to
face.
Unpause
will
happen
at
time,
5
so
3
seconds
of
pausing,
then
another
pass
happen,
a
date
and
then
say:
10
102
seconds.
A
A
We
check
if
the
unpassed
duration
is
actually
first
unpause
first
pass,
which
is
like
5
2
3.
It
is,
then
we
move
our
time
to
8
we
pulse
again.
We
move
our
time
to
to
10
with
unpause
again
and
now
we
check
whether
it's
5
minus
2,
plus
10
minus
8
and
form
more
complex
tasks.
It's
going
to
happen
like
this,
so
you,
like
you,
said
the
time
stamp.
You
do
the
action.