►
From YouTube: CasperLabs Weekly Workshop 5/07: Vesting Part 2
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
Okay,
last
time
we
worked
using
code
from
the
main
group,
so
Casper
laps,
Casper,
laps
and
the
rest
thing
was
deep
down
nested
in
one
of
the
directories.
A
A
A
You
can
check
if
it's
paused
and
at
the
end,
if
it's
paused
long
enough
admin
can
withdraw
the
rest
of
the
tokens
to
rescue
tokens
and
we
had
a
bunch
of
setters
and
getters
and
all
of
the
setters
and
getters
are
based
on
the
abstract
methods,
so
set
amount,
get
amount
set
time,
good
time
set,
bullion
Julian
and
then
in
in
tests.
We
use
this
and
we
implemented
the
trait.
This
is
here
so
demands
that
amount
amounts
at
time.
A
A
A
Again,
this
is
our
contract.
You
can
build
it.
The
goal
of
this
code
is
to
produce
a
wasn't
file
that
will
deploy
it
to
two
contracts.
One
contract
will
be
responsible
for
keeping
all
the
data
and
keeping
all
the
tokens,
so
everyone
can
interact
with
it
and
the
second
contract
will
be
a
client
contract
and
it
will
be
responsible
for
talking
today.
The
main
contract
bus
pass
key
as
the
account
in
a
RC
20.
A
A
A
This
time
we
did
small
trick
so
on
this
same
code
can
support
this
proxy
and
the
end
contract
infesting
can
contract.
If
you
remember
in
LC
20,
there
was
this
case
of.
If
the
first
argument
is
a
contra,
we're
gonna
shift
the
index
of
the
rest
arguments
by
one
and
then
we
will
have
the
arguments,
and
here
we
decided
to
do
a
different
thing,
which
is
the
first
argument
can
be
of
two
types
can
be
type
of
at
Apple
or
as
drink.
A
Then
this
code
should
be
made
to
the
final
vesting
contract
if
the
first
contract.
If
the
first
argument
is
at
Apple.
On
the
other
hand,
this
is
directed
to
the
proxy
this
client
contract
and
it's
responsible
is
to
check
if
it's
a
couple
and
if
it's
at
a
pole
that
the
first
element
of
the
topple
would
be
would
be
a
method
name,
and
the
second
would
be
the
contract
that
it
should
call.
A
A
A
If
you
talk
about
argument
here,
you
have
a
lot
of
possibilities
and
let's
take
a
look
here,
the
main
argument
is
from
arcs
and
should
return.
The
input
input
is
different
options
of
inputs,
events,
let's
say
so:
first
much
gets
drink
and
this
get
method,
name
and
method
name
could
be.
Look
here,
get
run.
Time
are
zero.
If
it's
not
there,
the
missing
argument
and
if
it's
Durden,
give
me
a
method
and
important
is
that
here
you
have
string,
so
it
tries
to
parse
it
as
a
string.
A
A
A
A
What
I
would
like
you
to
see
is
that
here,
when
I
have
to
do
the
deploy,
I
need
to
extract
a
lot
of
arguments
and
I
use,
get
comfy
get
vest
in
config.
I
can
see
here
that
it's
a
type
of
vesting
config
and
the
vesting
company
is
quite
long
structure
of
arguments.
So
how
I
do
it?
You
can
do
it
in
many
different
ways.
For
example,
you
can
serialize
the
whole
vesting
config
of
chained
to
list
of
bytes,
and
then
this
area
lies
it
inside
the
contract.
A
That's
one
of
the
possibility,
but
here
I
use
and
this
just
that
I
expect
next
arguments
to
be
one
after
each
other
and
I
say.
Please
start
with
the
fourth
argument
and
populate
50
coffee
and
try
to
take
every
argument.
One
by
one
with
this
arc
shift
that
will
be
4,
5,
6,
7,
8,
9
and
size,
because
the
I
could
decide
to
switch
this
to
the
first
place.
So
I
can
just
like
change
4
to
1
and
still
will
work.
A
A
Proceed
further:
let's
go
to
the
deployer.
If
you
go
to
main
the
deployer.
The
first
argument:
that's
called
after
the
Watson
package
is
deployed
is
call,
and
this
call
will
call
deploy
or
deploy
to
go
to
deploy
what
it
do.
It
does
take
from
arguments.
It
expects
to
be
a
P
deploy
if
it's
not
a
deploy,
then.
A
Revert
with
unknown,
deploy
command,
okay
and
if
the
deploy
vesting
contract
fails,
deploy,
wasting
contract
and
deploy.
Investing
contracts
go
like
this,
so
we
know
that
the
vesting
contract
is
responsible
for
keeping
tokens
and
now
the
question
is
how
it
keeps
talking,
and
the
answer
is
that
the
account
can
create
a
purse.
A
Okay
here
account
creates
a
purse.
We
called
fasting
purse
and
we'll
transfer
tokens
to
disperse
and
send
this
purse
to
the
vesting
contract,
and
then
it
will
forget
about
this
purse.
So
only
the
contract
will
know
this
purse,
so
only
the
contract
will
know
how
to
have
to
use
it,
how
to
extract
money
from
it
tokens
from
it
to
send
to
someone.
Let's
see
how
we
do
it
so.
First,
all
the
tokens
comes
from
the
account
that
actually
do
that
to
the
deploy.
A
A
A
A
With
all
the
arguments
we
will
see
how
the
contract
is
handling
this
in
a
moment,
and
then
we
save
it
under
a
name
that
comes
from
the
argument
as
well,
so
we
can
name
our
vesting
contract,
so
everyone
can
have,
for
example,
multiple
vesting
contracts.
It
could
be
like
one
account
create.
Let's
say
we
are
a
Casper
Labs
and
we
want
to
create
multiple
accounts,
multiple
vesting
wallets
for
different
people,
so
we
just
put
the
different
names
and
we
and
our
main
account
will
hold
multiple
of
this
by
name
by
different
names.
A
Okay
and
the
same
very
simple
here
we
have
deployed
proxy
and
deploy
proxy
is
much
simpler
if
just
storing
a
veteran
proxy
contract
name
under
under
a
key
and
it's
gonna
be
called
vesting
proxy
okay.
So
we
have
our
contracts
deployed
and
realized.
Let's
see
how
that
actually
happened.
What
happened
inside.
A
A
A
So
if
it's
not
initialized,
please
call
the
construct
function
and
after
that,
do
the
initialization
the
mark
is
as
initialized
and
after
it's
initialized.
It
will
only
call
entry
point.
So,
let's
take
a
look
at
the
code.
Construct
construct
is
here,
construct
uses
vesting
contract
blasting
contract
is
implemented
here,
we'll
get
there
in
a
minute.
So
first
match
arguments
expect
in
it.
You
need
to
will
have
anime
account
recipient
account
and
the
coffee
set
admin
account
and
recipient
account.
A
Here,
in
the
count,
so
these
are
set
keys,
I
think
we
discussed
set
key
in
the
past.
This
is
just
generic
setter
for
every
type
that's
available
in
the
system
under
a
name,
and
we
also
have
the
corresponding
key
function.
That's
a
generic
together
for
the
given
name
and
it's
of
type
T,
so
you
need
to
you
need
to
give
the
type.
A
A
Okay,
now
batting
trait.
This
is
very
simple:
I
create
I,
have
to
create
empty
struct
struct
and
implement
it
to
implement
vesting
trait
or
destruct
and
I'm
I
need
to
implement
all
the
abstract
methods
which
are
set
key
keys.
That
each
is
at
a
key
and
the
current
timestamp
comes
from
the
block
time.
A
A
A
A
A
So
it
goes
like
this
create
a
empty
purse,
so
I
need
to
send
some
some
purse
to
the
contract,
so
the
contract
can
transfer
the
money
tokens
to
the
purse
and
send
it
me
back
and
then
I
can
take
my
tokens
from
this
new
purse
back
to
my
original
main
purse.
So
why
we
do
this.
Let's
say
you
send
your
main
purse
to
the
contract
and
then
the
contract
could
actually
save
this
purse
under
some
named
key
and
later
because
it
knows
it,
it
can
take
all
your
tokens
from
the
purse.
A
So
that's
why
I,
no
one
should
ever
be
responsible
for
it
ever
be,
sharing
the
main
purchase
with
anyone
else.
That
way,
there
is
also
always
this
need
for
creating
new
purse
and
and
sending
this
to
the
contract.
So
that's
how
we
do
it
here
and
after
we
send
it
we
take
after
this
is
executed.
We
take
the
members
and
transfer
our
tokens
from
the
new
purse
to
Dementors.
A
A
A
We
talked
verified
technologies,
verify
recipient
account,
so
get
the
recipient
get
caller
and
track
give
the
recipient
this
caller.
It's
not
true
an
error,
just
a
guard
but
very
important
that
prevents
from
stealing
okay
and
now
called
the
vault
use
the
logic
withdraw
and
keep
in
mind
that
this
logic
is
actually
a
book,
keep
bookkeeping.
Think
so
the
the
transfers
happen
outside
of
the
logic
so
fish.
The
logic
would
have
to
like
confirm.
Ok,
this
is
possible
to
happen
so
and
I'm
gonna
mark
this
as
something
that
happened.
A
And
is
gonna
be
marked
and
then
only
after
them,
the
contract
will
transfer
out
CLX
to
purse,
so
just
talking
contract
to
transfer
from
the
main
internal
pores
to
this
external,
like
ongoing
proof
that
that
that
as
an
argument,
so
that
is
separation
here.
Of
course,
the
best
ink
logic
could
be
modeled,
so
it
actually,
for
example,
here
in
the
vesting
here.
It
could,
for
example,
create
the
method,
transfer
tokens,
and
maybe
that's
a
good
idea
to
do
this,
and
then
it
could
abstract
the
transfer.
A
A
That
we
passed
as
the
argument
to
the
constructor
and
after
I
have
this
I
transfer
from
local
pours
to
disperse
the
amount,
so
tokens
are
already
in
the
purse
and
looked
at.
I
actually
don't
do
anything
about
it.
I
just
leave
it
like
this
and
after
this
this
call
to
the
contract
ends.
The
tokens
are
already
on
the
purse
and
the
account
calling
now
is
dispersed
so
can
withdraw.
A
A
A
Testing
is
very
similar
to
the
logic
tests
so
in
the
vesting
dot
RS,
which
is
in
the
same
directory,
created
implementation
of
the
vesting
contract,
and
we
can
call
the
investing
contract
deployed.
That
gives
us
a
vesting
environment.
That
say,
with
the
deployed
contract
with
the
proxy
and
with
accounts
with
positive
balances
and
I
can
have
that
config,
which
you're
gonna
use.
A
A
A
A
A
A
A
It
is
possible
to
that's
that's
interesting
part.
So
when
we
execute
the
contracts
transaction
by
transaction,
we
can
manipulate
the
time
of
the
block
and
see
how
I
did
in
the
set
block
time.
I
have
the
function
set
block
time.
That
sets
me
my
local
current
time
to
do
the
value
I
want
and
then
when
I
call
on
Direct,
which
is
gonna,
is
the
executor
function.
A
Can
set
a
long
time
like
this
and
then
and
then
this
way
I
can
see
me
light
the
time
lasting
in
my
test
very
important,
because
here
we
were
writing
a
contract.
That's
gonna
depend
on
time,
so
it's
very
important
to
be
able
to
shift
time
and,
for
example,
in
et
room.
It's
really
really
hard
to
do
this,
because
here
we
operate
on
the
virtual
machine
and
that's
that
is
that
we
can
spawn
that
we
can
create
by
our
own
on
the
same
thread.
A
A
A
So
whoever
holds
the
purse
object,
have
access
to
those
tokens
in
AC
20
that
I
implemented
only
accounts
have
access,
because
the
amount
of
tokens
is
associated
not
to
the
some
kind
of
purse
that
the
contract
can
create,
but
rather
to
the
account
address,
which
is
which
is
not
good
but
C
20
and
we
are
working
on
the
standard
of
our
own
token.
That
can
do
this
first
thing
and
works
this
way.
So
so,
hopefully
that.