►
From YouTube: NEAR Lunch and Learn Ep. 05: Accounts and Runtime
Description
Here, Evgeny Kuzyakov discusses basic account models at NEAR. Including transactions, receipts, and simple transfer transactions. This video is great for beginners.
~~~ABOUT Lunch and Learns~~~
This is a new series of videos exploring a concept on the NEAR protocol blockchain discussed in the NEAR office at lunch. Grab a sandwich and settle in!
Follow the latest from NEAR Protocol on,
Website: https://nearprotocol.com/
Discord: https://near.ai/discord
Medium: https://near.ai/medium
Twitter: https://near.ai/twitter
GitHub: https://near.ai/github
A
Hi
I'm
Eugene
and
today
we
gonna
record
a
large
serious
about
rantin
and
first
question
is
what
is
run
time
so
run.
Time
is
a
thing
that
runs
everything
on
a
blockchain,
so
let's
say
we
have
transactions
coming
in
and
then
we
process
transactions
and
we
get
a
result.
So
this
is
handled
by
run
time,
ignoring
all
the
blockchain
stuff.
So
what
is
the
input
and
output
is
handled
by
the
run
time?
So,
let's
start
first
with
the
account
model
run
time.
A
A
Primitive
that
is
known
to
everybody
who
want
to
interact
with
your
account,
and
it's
part
of
the
pair
of
public
and
private
case
of
private
key
is
what
you
have
publicly
is
known
to.
Everybody
want
to
interact
us
so
on
mere
accounts.
I
actually
not
keep
by
the
public
key,
but
they
have
a
just
unique
user
name.
So,
for
example,
my
account
ID
can
be
you
Jim,
and
this
is
what
we
call
account
ID
within
the
account.
A
Eighteen
of
a
single
near
we
do
this
to
keep
the
balance
as
an
integer.
So
it's
not
a
floating
point,
and
at
the
near,
is
the
smallest
Union
that
we
have
for
the
token,
then,
on
account,
they
also
have
log
balance
and
log
balance
is
used
for
staking
or
indicating
how
much
you
wanted
to
stake.
A
currently
staked
near
is
a
proof
of
stake
system
and
stake
is
the
log
balance
that
is
used
by
the
validators.
A
So
if
validators
act
properly,
they
earn
more
stake
or
more
rewards,
and
if
they
act
maliciously,
they
gonna
lose
their
stake.
So
stake
guarantees
for
validator
start
properly,
also
an
account
on
ever
account.
We
may
have
a
contract.
This
is
a
code,
a
contract,
a
smart
contract
that
can
act
on
on
your
behalf,
on
behalf
of
the
account
so.
B
A
A
And
finally,
to
be
able
to
access
the
account,
we
can
have
multiple
access
keys
so
on
again
on
aetherium
or
on
a
Bitcoin
network.
Your
public
key
and
corresponding
private
key
gives
you
access
to
the
account
so
by
using
a
private
key.
You
sign
transaction
that
guarantees
that
you
are
donor,
the
account
and
you
can
act
on
behalf
of
this
account
near
we
have
multiple
access
keys
and
they
can
have
different
permissions.
A
A
Function
call
and
function
calls
is
a
specific
access,
key
that
only
grants
permission
for
calling
some
other
contract
it
guards,
which
account
it
can
call
and
also
how
much
tokens
it
can
use
to
pay
for
the
fees
and
which
method
it
can
call.
So
it
can
be
very
restrictive
and
we'll
come
back
to
this
slightly
later,
once
you
talk
about
transactions,
so
why
we
talk
about
accounts,
as
you
might
know,
near
is
sharded
system,
so
we
have
multiple
charts
that
both
contain
state
and
processing.
A
A
A
No,
so
every
account
belongs
to
exactly
one
shard,
but
how
this
is
decided
is
not
part
of
the
account
logic,
so
account
doesn't
control
which
chart
it
needs
to
be
like,
and
this
is
controlled
by
the
blockchain,
which
can
rebalance
accounts
from
shark
to
chart
and
actually
make
charts
equal
weight.
So
if
some
account
is
very
heavy
in
terms
of
having
a
lot
of
storage,
so
access
key,
this
chart
might
have
less
other
accounts
comparing
to
some
other
shirt.
Okay,.
B
A
On
near
run
time,
the
way
they
actually
process
it,
we
always
assume
all
accounts
belong
to
the
different
shirts.
So,
even
if
we
have
two
accounts,
Eugene
and
Ashley
that
belongs
to
the
same
shark
around
time,
we'll
make
an
assumption
they
both
belong,
like
they
belong
to
the
different
shirts.
That
is
done.
That
colocation
of
accounts
to
the
same
chart
doesn't
give
you
any
benefits
and
that's
why
we
don't
want
to
developers
or
users
to
be
thinking
about
collocating
their
accounts
to
get
any
benefit.
This
is
done
for
two
reasons.
A
A
A
A
A
A
Contains
a
field
indicating
how
much
talking
or
how
many
tokens
Alice
wants.
The
transfers
in
this
case
is
going
to
be
a
hundred,
and
this
is
a
transaction
so
now
to
indicate
to
the
chain
that
this
transaction
is
actually
done
by
Alice
and
not
someone
else.
Alice
has
to
sign
this
transaction
with
one
of
the
access
keys,
which
contains
a
private
key.
So
Alice
has
to
sign
this
transaction
by
computing,
a
hash
of
this
transaction.
This
gives
you
a
unique
field
that
she
signs
this
private
key
and
creates
a
signature.
A
A
So
transaction
starts
when
Alice
creates
this
transaction
and
then
attaches
the
signature,
and
we
call
it
signed
transaction
so
signed
transaction
can
now
be
sent
towards
the
blockchain
that
will
verify
the
blockchain
layer
I'm,
going
to
verify
that
this
transaction
is
valid
and
put
it
into
the
chunk,
which
is
piece
of
the
chart.
The
next
block
of
the
chart
we
call
it
chunks
once
signed
transaction,
arise
to
the
chunk.
This
information
is
actually
passed
to
the
runtime
and
Trenton
will
process
it
and
makes
the
necessary
logic
and.
A
Depends
on
the
blockchain
layer,
so
the
V
target
to
produce
one
block
per
second,
and
so
this
particular
transfer
will
actually
take
about
two
seconds
and
we
will
get
into
this
why
it
takes
like
longer
than
one
second.
So
this
is
a
signed
transaction.
We
have
it
now
and
let's
say
we
want
to
process
it.
So
let's
say
Alice
account
belongs
to
this
chart,
while
Bob
account
belongs
to
the
next
chart,
so
they
don't
different
chart.
So
how
is.
A
A
This
signature
can
only
be
validated
by
this
given
chart
where
account
Alice
exists.
If
a
transaction
lengths
on
this
shirt,
it
cannot
verify
that
L
is
actually
signed,
the
transaction
with
proper
key,
because
this
shirt
doesn't
have
information.
The
chart
of
Bob
doesn't
have
information
about
the
account
of
Alice,
so
it
cannot
verify
the
validity
of
the
transaction.
A
That's
why?
In
a
Charlotte
system
we
introduce
a
different
type
of
transaction
called
receipt
and
receipt
is
a
processed
transaction
that
was
created
by
the
runtime
itself,
and
receipt
can
actually
be
transferred
cross
charts
through
the
blockchain
layer
and
processed
by
the
runtime
on
the
other
chart.
So
here's
just
I.
B
Want
to
break
this
down
on
like
really
simple
terms,
so
I
understand
it.
Basically,
you
have
your
your
runtime
and
your
px,
which
is
your
okay.
So
that's
your
transfer,
and
so
it's
the
equivalent
of
like
putting
your
credit
card
in
a
machine.
You
sign
it
in
person
and
then
something
mumbled
umbels
up
and
up
in
the
internet
and
then
that's
where
the
receipt
comes
from
and
then
it
comes
out
and
lets
you
know
kind
of
similar.
It.
A
A
A
A
A
This
receipt
contains
the
amount
that
Alice
transferred
it
contains
hundred
and
ten
year,
tokens
that
when
the
receipt
is
applied
here,
Bob
gets
a
plus
hundred
talk,
it's
cool
and
that's
how
it
works.
But,
let's
say
just
to
step
back
that
Alison
correctly
entered
Bob's
account
name
and
she
put
something
like
Bob's
is
zero,
so
when
it
arrives
to
the
shard,
where
this
account
supposed
to
be
since
shard
of
Alice
actually
doesn't
know
that
this
account
doesn't
exist.
It
redirects
this
to
the
new
shirt
where
it's
supposed
to
be,
and
this
account
doesn't
exist.