►
Description
During this workshop, we will demonstrate CasperLabs' Voting 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
I'll
start
with
logic
and
go
to
contract
and
then
to
test
I'll
show
you
how
I
extract
its
pieces
of
contracts
to
be
utils,
so
they're
gonna
be
reusable
across
projects.
After
writing.
Some
few
smart
contracts
I
realized
that
some
things
can
be
reusable
and
also
I
tried
different
approach
to
saving
data
on
blockchain.
Instead
of
saving
to
multiple
named
keys
to
do
the
very
atomic
named
keys,
I
now
serialized
to
one
large
object
and
save
it
on
the
blockchain
and
I'll
show
you
how
it's
possible
to
read
it
from
from
the
using
the
castle.
A
A
A
A
So
the
main
element
here
is
voting
voting
contains
start
and
end
time
stamps
of
the
voting.
So
you
cannot
vote
before
and
after
those
times,
and
it
contains
lists
of
projects
which
is
a
b3
map
which
is
hash
map
of
a
project.
Id
to
project
object,
take
a
look
project.
Id
is
just
a
wrapper
around
264,
but
I
wanted
this
to
be
some
kind
of
type.
A
Rather
than
this
you
60,
unnamed,
you
64
and
I.
Have
a
project
object,
which
is
the
representation
of
project
method.
Are?
Is
the
instance
like
this
is
the
element
you
can
vote
on?
If
you,
if
you're
doing
the
voting-
and
you
have
a
list
of
participants
and
participant-
is
the
again
hash
map
of
public
key
to
the
participant
object
and
the
idea
behind
is
that
each
participant
has
a
public
key
and
it
has
some
metadata
associate
actually
not
the
teaser
daraa,
and
these
data
are
total
vaulting
power.
A
A
A
A
A
Actually
add
and
update
so
how
I
realize
this
add
or
update
a
functionality?
Is
that
I
check
first
in
the
list
of
participants,
whether
I
have
a
participant
registered
under
this
public
key
and
take
a
look
that
I'm
using
get
mute?
So
if
it
is
possible,
if
it
is
there
so
I
get
this
some
participant
I
can
update
it.
So
I
can
use
this
participant
object
to
actually
change
change
its
elements.
So
in
this
other
of
the
participant,
the
another
element
is
a
total
voltage
power.
A
A
A
A
A
So
that
why
I
use
this
get
mode-
and
here
I
can
do
the
insert
and
insert
is
nice
because
allows
you
to
it,
behaves
in
the
weight
of
add
or
update,
and
the
next
function
is
remove
project?
It
exists
and
cancel
votes.
So,
if
you're
removing
the
project,
you
also
want
to
remove
all
the
votes.
People
cast
it
so,
as
I
showed
you
before
in
distract
of
participant,
we
have
this
list
of
boats.
A
That
are
casted
for
this
project
and
so
does
have
the
remove
project.
If
exist
and
canceled
vote
function,
works,
it
removed
fish.
It
removes
the
project
from
the
project
list
and
this
is
remove.
Gonna
return,
the
results,
an
object.
If
it's
there
is
gonna
return
it
if
it's
not
there.
So
if
we're,
if
we
are
removing
a
project
and
that
doesn't
exist,
it's
gonna
return,
none.
So
this
fine.
This
piece
of
code
will
not
execute,
and
in
this
piece
of
code,
I'm
doing
it'll
mute
so
I'm
a
mutable
participants
and
I
will
move
out.
A
A
This
function
allows
you
to
vote
on
particular
project
as
a
public
key,
so
we
have
all
the
elements
here
to
public
key
project.
Id
vote,
so
amount
of
votes,
and
also
there
is
a
vote
at
here.
That
should
be
a
time
of
the
vote,
so
it's
gonna
verify
whether
this
vote
add
is
before
that.
It
is
not
before
start
time
stamp
and
it
is
not
after
and
timestamp.
So
it's
within
the
bounds
of
voting
period.
A
A
A
The
update
for
the
used
voting
power-
okay
and
here
we
have
serialize
and
deserialize
ation
I'm
gonna
talk
about
this
now.
I'll
show
you
first
serialization
deserialization
test,
that's
here.
So
what
I
do
I
create
a
new
voting
I
create
the
project.
Id
I,
create
a
project
and
I
call
add
or
update
project
I'm,
adding
new
project,
then
I,
add
or
update
participant
I
have
a
predefined
Ally
account
man
with
the
power
and
I
cast
the
vote.
A
When
I
des
I
realize
it
when
I
serialize,
it
I'll
show
you
what
I'm
doing
here
to
serialize
what
I
am
returning,
which
is
the
most
important
I'm
returning
a
type
that
I
called
voting
serialized,
and
it
is
a
topple
couple
of
three
elements
and
all
of
these
elements
or
all
of
those
elements
here,
will
represent
the
whole
voting
object.
And
why
I
used
it
like
this,
because,
for
example,
one
could
say
why
not
you
serve
that
to
serialize
it
to
bytes
or.
A
A
A
A
That
means
that
what
we
can
do
is,
for
example,
we
could
have
a
list
of
buys
like
32,
bytes
and
different
types
like
we
can
have
a
a
string
that
could
destabilize
a
string.
But
if
you
change
the
CL
type
to
something
else
like
even
vector
of
bytes,
it's
going
to
disorder
allies
as
a
different
structure.
A
A
List
of
bull
elements
and
the
result
will
be
a
CL
type,
actually
CL
value
and
I
will
be
able
to
save
it.
So,
and
this
happens
thanks
to
the
implementation
we
have
from
the
normal
object.
So
if
I
write
a
b-tree
map
that
comes
from
other
coaches,
which
is
Korra's
element,
but
because
I
have
the
we
have
the
sterilization
of
remark
to
the
CL
value
that
is
typed
using
CL
type
and
its
type
like
here.
Using
the
map,
then
I'm
getting
I
can
do
this
and
then
I'll
be
able
to
save
it.
A
So
this
way,
let's
go
back
to
the
code
if
I
disable
eyes,
if
I
serve
you
like
an
object
that
can
be
saved,
that
that
will
be
CL
typed,
which
is
in
this
case
it's
a
couple
of
three
elements
because
I
have
tupple
of
one
two
or
three.
So
my
top
object
here
is
couple
of
of
three
now
I
have
couple
of
two,
which
is
you
64,
and
to
64
I'll,
go
back
here
to
check
okay,
I
have
Topol
of
I.
Have
you
64
fine,
then
I
have
a
project.
A
Serialized
projects
I
realized,
so
that's
gonna
be
a
bit
remap
of
you,
64
and
I'm.
Turning
this
project
object
here
into
list
of
strings.
I
can
go
back,
I,
see.
Okay,
the
big
tree
map
will
be
map
so
I
have
it
here,
I
can
use
key
can
be
any
value.
Any
type
value
can
be
any
type.
So
my
key
is
you
64,
I'm
fine
and
the
lists
fixed
list
of
strings.
First
I
have
a
string.
That's
fine
and
I
have
a
Felix
list
that
can
be
string.
A
A
If
public
key,
but
public
key
is
not
on
the
list,
so
I
cannot
use
it
so
I
have
to
unwrap
it
and
use
underlying
bikes
and
now
I'm
getting
fixed
list
of
bytes.
The
fixes
I
get
by
it.
I
get
and
then
a
couple
of
again
of
three
which
we
know
we
have
to
64
64.
We
have
and
map.
We
have
so
if
I
say
realize
something
to
this
side
and
then
it
means
I
can
easily
save
it
as
I
did
in
the
contract.
A
A
A
The
output
looks
like
so
I
have
this
readme
to
discredit
the
reading.
So
when
I
do
the
query
state
using
the
client
on
top
of
this
object,
I'm
getting
this
very
large
CL
value
that
and
with
those
types
so
that
you
have
couple
of
three,
then
you
have
the
first
element.
That's
double
of
two
that
has
first
element
you
64
second
element
to
64
and
so
on,
and
so
on.
A
A
A
But
not
cast
vote
can
be
done
only
by
the
admin.
So
so,
when
the
deploy
happens
and
the
image
first
deploy
happens
and
the
init
function
is
called
I
call
set
admin
account
as
account
that
is
calling
the
contract
and
then
I
create
a
voting.
And
that's
going
to
do
me
a
result.
So
I'm
up
map
the
real
as
to
save
faulting.
A
A
A
Looked
at
every
so
now,
if
I
want
to
do
the
query
of
the
state
of
the
contract,
I
have
this
data
function
is
going
to
return
me
a
voting
and
what
it
does
it
queries
do
the
query
contract,
so
it
returns
the
key,
and
this
name
vaulting
data
and
I
can
destabilize
it.
I'm
getting
the
building,
I'm
very
handy
and
now
on
I
can
use
the
vaulting
structures
to
assert
whether
things
happened
or
not.
A
So,
for
example,
here
I
I
if
I
want
to
get
the
participant
by
the
public
key
I
get
the
data
and
now
I
can
access
elements
of
the
struct
directly
submit
the
project
and
if
I
want
to
call
it
and
do
the
change.
For
example,
I
want
to
add
ready
participant.
I
have
the
parameters
here
and
like
use,
call
on
direct
I,
specify
the
sender
and
the
argument,
and
that's
it.