►
From YouTube: NEAR Certified Demo | Episode 1.1 -- Dice
Description
This demonstration was presented by the author(s) after just 1 week of working with the NEAR platform as part of the NEAR Certified Developer program.
You can find the source code to this demo here:
https://github.com/Learn-NEAR/NCD-01--dice
--- Follow the latest from NEAR Protocol on:
Website: https://near.org/
Discord: https://near.chat/
Blog: https://near.org/blog/
Twitter: https://twitter.com/NEARProtocol
GitHub: https://github.com/near https://github.com/nearprotocol
#Blockchain #FutureIsNEAR #NEAR #nearprotocol
A
Okay,
so
let's
go
directly
to
the
contract.
This
is
a
a
dice,
a
rhodes
project,
a
demo,
it's
a
simple
demo.
This
is
a
contractor
lib
dot
ice.
A
We
can,
I
can
see,
what's
the
point
to
show
you
so,
let's
show,
let's
talk
about
some
of
the
main
structure
of
this,
this
one,
the
main
structure
here
here
near
dice.
A
This
is
the
main
structure
we
have
owner
id.
This
one
is
for.
I
see
I
want
to
make
this
we
want.
We
want
to
make
this
contract.
Have
some
financial
you
know
features,
so
not
only
players
can
play
at
this
on
this
contract.
Also,
the
the
owner
can
gain
some.
You
know
some
some
reward.
The
reward
comes
from
when
maybe
sarah
wins
a
game.
A
Maybe
he
roll
a
dice
six
and
he
gets
the
six,
so
he
wins
half
of
the
jackpot
and
from
his
wing
his
from
his
reward,
the
owner
can
get
maybe
five
percent.
This
five
percent
is
defined
as
a
fraction
here
reward
reward-free
fraction,
so
this
is
a
numerator
is
the
denominator.
A
So,
let's
go
on
so
this
size
number
defined
in
one
row:
action
we
can.
We
can
draw
one
by
four
wrote:
two
dice
together
or
three
dies
together.
This
is
a
expand
point
for
further
work
for
this
demo.
It's
only
one
dice
one
action.
You
know,
as
this
rolling
phase
defines
we
can,
the
user
should
buy,
buy
dice
first
and
then
androidize.
A
A
So
there
are
two
to
you
know,
collections
wing,
history
stores
all
the
wing
event.
We
we
choose
to
this
this
vector
from
the
near
sdk
collections,
because
we
want
those
to
store
as
long
as
possible,
but
in
further
work
in
further
work.
We
may
consider
about
the
storage
fee
about
this
vector
it
may
may
grow
on
uncontrolled.
You
know
so
this
accounts.
A
This
account
is
still
used
to
store,
like
user
buy
some
dice.
Maybe
let's
say
when
near
paradise
a
user
can
block
can
bought
10
dice
using
10-year,
and
then
the
dice
is
recording
this
lookup
map
this
account
id
and
how
many,
how
much
they
paid
for
dice
so
for
lookup
map
using
low
customers
is
considered
about
the
this
map
can
can
shrink
if,
if
user
rule
dies
and
cause
the
balance
reduced
to
zero,
then
the
lookup
map
will
remove
this.
A
This
entry
to
to
save
some
space
of
the
you
know:
storage
storage,
space
and
this
contract.
We
we
forbidden
default,
so
we
can
use
this
new
func,
this
new
message
to
for
the
initial
method
to
pass
through
owner
id
size,
number
rolling
fee
and
the
tips
fraction
and
after
the
initiation
initialize
of
this
contract.
We
also
have
to
do
to
do
a
action
to
really
start
this
playground,
that
is,
to
deposit
jackpot,
because
after
the
initialization
the
checkpoint
is
is
empty.
A
A
The
randomness
here
is
the
oh
rhodis
this
function,
so
we
get
randomness
from
this
one
random
seed,
because
I
say
I
think
randomly
is
written,
32
bytes
randomness,
so
we
have
many
ways
to
to
make
it
to
a
a
random
number
in
our
our
our
own
range
here
is
just
a
one
way
to
we
add
up.
It
will
add
up
all
32
bytes
to
one
byte
with
this
wrapping
edge
and
to
use
this
to
limit
the
random
to
from
one
to
six.
A
Another
point
to
mention:
is
we
split
this?
You
see
two
methods
here:
biodice
and
the
road
eyes
at
the
first
version.
There
is
only
one
one
method:
rodize
we
will
make
the
rhodius
payable
and
but
we,
but
we
add
up
front
and
we
found
a
console
something
difficult
to
do,
because
the
web
wallet,
if
appear
if
appearable
method
is
called
from
the
front
end.
The
front-end
page
would
redirect
to
the
you
know
official
web
page,
and
so
the
front-end
cannot
get
any
written
value.
A
Yeah
show
the
front
end.
A
A
C
C
Have
a
question:
do
you
see
any
potential
like
weak
places
in
in
the
contract
itself
or
it
or
in
its
integration
with
front
end
for
the
attacks
like
when
people
can,
you
know
can
cheat,
because
this
is
a
little
bit
of
of
gambling
application
right
so
and
you
most
of
first
users,
like
you,
attract
a
lot
of
people
who
who
come
to
make
a
quick
bug
correct,
so
anything
that
you
can
come.
Obviously,
you
know
like
like
very
fast
like
okay,
so
this
is
where
I
have
certain
concerns,
or
anything.
A
I
think
it
can
yoga
can
not
cheating
on
this
game,
because
because
the
road
eyes
this
one
rhodes
yeah
it's
something
like
kind
of
a
atomic
action.
You
know
the
people
cannot
know
they
cannot
predict
this
random
seed
yeah.
This
random
thing
is,
is
generated
after
the
people
have
taken.
Take
his
guess.
You
know
this
is
his
guess
and
called
the
causes
function.
Then
the
function
gets
those
random
shifts.
C
No,
I
mean
I
mean
if
we
play
with
with
front
end
like
and
I
I
would
like
to
to
roll
the
dice
like
a
hundred
times
and
pay
just
for
one
time.
Is
it
possible,
like
there
is
no
way
like
whatever
I
use,
like
my
my
hiker
skills,.
A
A
B
This
is
great
marco.
Thank
you.
So
much
really
appreciate
the
demo.
Congratulations
on
the
progress
and
if
there
aren't
any
other
questions,
I
think
we
can
move
on
to
the
next
demonstration
thanks
so
much
marco,
I
will.
A
B
I
will
fork
your
repo
yeah.
I
will
fork
your
repo
into
the
into
the
the
main
organization
that
we've
been
using
and
and
that
way
people
can
follow
up
with
your
your
source
code
and
try
and
deploy
the
application
and
and
is
is
everything
in
one
repository,
or
is
this
split
across
multiple
repositories,
front,
end
and
contract?
How
have
you
organized
it.
A
B
B
A
Yeah
we
have
a.
We
have
a
very
fine,
very
nice
instructions,
nice
readme.md.