►
From YouTube: NEAR Blockchain Concepts (6/6) -- View vs Change Methods
Description
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
So
welcome.
We
are
here
with
vlad
frolov
he's
heading
up
the
team
on
the
api
side
and
the
explorer
side
of
near
protocol
and
we're
gonna
talk
today
about
you,
know,
parts
of
the
api
that
you
know
vlad
thinks
are
useful
for
us
and
vlad.
Should
we
call
you
frol
or
vlad
or
what's
the
right?
What's
the
right
way.
B
A
That's
right,
yeah,
cool,
okay,
so
so,
for
what
is
the
focus
of
today
going
to
be?
I
think
you
have
some
some
intent
to
talk
about
link
drops
accounts
keys.
What's
what's
the
right
focus
for
today.
B
Yeah,
first
of
all,
it's
nice
to
meet
you
sheriff
and
to
welcome
everybody
to
watch
our
series
of
videos
yeah.
I
was
about
to
talk
about
the
view
and
change
methods
on
nir
in
a
perspective,
how
they
are
different
and
how
they
are
useful
in
the
first
place.
B
So,
let's
try
to
dive
into
it
immediately.
You
can
find
in
the
docs
there
are.
There
is
some
distilled
information
about
potential
gotchas,
so
you
may
encounter
with
view
and
change
functions,
but
today
we
are
I'm
going
to
dive
into
them
from
the
point
of
view
of
api
and
we'll
navigate
through
how
the
data
is
flowing
and
we'll
follow
it.
So
for
today's
video
I
decided
to
go
with
an
example
of
our
near
link
drop
contract.
You
can
find
it
on
github.
B
We
are
not
going
to
dive
much
into
the
details,
it's
implemented
in
rust
and
you
can
read
up
the
source
code.
What
they
want
us
to
focus
on
is
that
there
are
several
methods
like
send
and
claim,
and
there
is
also
like
there
are
a
bunch
of
other
methods,
but
one
that
we
are
going
to
focus
today.
Is
this
get
key
balance
method
specifically,
so
this
one
is
quite
small
and
I
suggest
we
just
study
it.
A
little
bit
closer
essentially
get
key
balance.
B
A
is
a
function
which
you
provide
with
the
key
and
it
will
return
you
a
balance
in
unsigned
one
28
bits,
integer
yoktanir
precision,
so
we
have
and
accounts
map
on
the
on
our
state,
and
we
can
query
it
by
the
given
key
and
if
everything
is
fine,
so
the
key
is
not
missing.
B
B
So
that's
how
you
read
it
when
we
have
this
send
method
implementation,
we
can
see
that
there
is
something
is
going
on,
but
ultimately
we
just
insert
our
public
key
and
the
balance
attached
to
this
key
into
the
structure
we
just
covered.
Everything
else
is
not
important
right
now
for
us,
and
let's
focus
only
on
this
accounts
mapping,
so
we
essentially
map
not
the
accounts,
but
the
public
keys
to
the
balances
that
we
fund
and
that's
how
this
contract
is
working
in
this.
B
A
Before
we
leave
the
contract,
can
we
just
point
out
that
that
you
you
are?
We
started
the
conversation
talking
about
view
and
change
methods
and
as
a
rust
developer,
you
can
immediately
tell
the
difference
between
a
view
and
a
change
method
because
of
the
mutable
reference
to
self
right.
So
yeah.
B
So
that's
a
little
right.
Thank
you,
yeah
yeah,
so,
basically
in
scent
we
can
see
that
self
is
mutable
reference.
We
can
call
the
methods
that
are
mutating
the
values
on
self
and
with
the
get
key
balance,
as
you
can
see
itself
is,
is
immutable
and
it's
it's
very
handy,
as
sheriff
pointed
out
to
immediately
spot
the
method
that
intend
to
be
view,
methods.
B
So
I
would
like
to
make
this
difference
clear
what
these
like.
When
we
implement
the
methods
on
the
contract
level,
they
seem
to
be
just
the
functions
on
the
same
level
of
abstraction,
they're
kind
of
the
same.
We
just
assume
that
one
you
can
call
and
change
the
data
and
call
another,
and
we
don't
need
to
change.
The
data
seems
to
be.
There
is
like
there
is
no
distinction,
but
on
the
blockchain
level
the
calls
that
are
not
requiring
us
to
modify
the
data
could
be
executed
for
free.
B
B
Essentially,
if
imagine,
if
you
have
your
accounts
mapping
on
your
local
machine,
what
would
you
take
to
look
up
the
the
key
that
is
provided
to
you
and
know
the
balance?
It's
it's
a
regular
program.
There
is
no
problem
to
implement
it
and
you
just
go
and
find
the
necessary
key
in
the
hashmap
or
even
in
a
sequential
array.
B
You
know,
but
whenever
you
modify
the
data
on
blockchain,
you
need
to
make
all
the
validators
arrive
to
the
same
state
and
it
is
expensive
and
you
need
to
make
sure
that
consensus
is
reached,
and
all
of
that
is
taking
quite
amount
of
resources
across
the
network.
So
that's
the
main,
distinct
distinction
between
those
those
two
types
of
functions
and
even
though
they
look
very
similar
on
the
contract
level,
they
could
be
they.
They
are
quite
different
on
network
level.
B
So
whenever
you
see
transactions
on
on
the
network,
those
transactions
that
are
call
method
transactions,
these
are
change
methods.
So,
whenever
you
deposit
the
stake,
whenever
you
set
something
when
you
send
subtle
race,
whatever
you
do,
you
modify
the
current
state.
That's
why
you
need
to
submit
a
transaction.
The
transaction
will
get
processed
and
all
of
that
will
get
executed
and
your
contract
will
be
executed
on
a
number
of
machines
on
the
network
and
they
will
change
the
state
and
the
state
will
will
need
to
be
consistent
across
every
single
time
execution.
B
So
it
should
be
pure,
essentially
a
pure
function,
meaning
that
whenever
you
have
this
input,
you
will
have
the
same
output
exactly
well,
and
we
only
record
such
change
methods
on
the
network.
Every
function
call
is
essentially.
B
B
Argument
here
it's
a
public
key
and
this
is
exactly
what
we
send
it
with
our
function
call
method
in
a
transaction
action.
B
B
B
Wow
I
forgot
to.
B
So,
okay
sheriff,
can
you
see
the
screen
well
or
should
they
change.
A
The
text
is
pretty
small,
but
it's
it's
it's
fine.
Maybe
you
could
take
it
out
of
this
and
put
it
into
another
tool
where
we
could
look
at
it
a
little
bit
better.
What's
your
what's
your
goal,
what
are
we
gonna.
B
Look
at
the
payload,
it
will
it'll
be
quite
short
here.
The
goal
is
essentially
to
display
this.
We
have
a
call
to
to
the
rpc,
it's
very
simple:
you
provide
json
standard,
json
or
pc
parameters.
You
specify
the
method
we
are
going
to
submit
a
transaction
broadcast
tx
and
here
the
transaction
that
is
represented
in
base
58
encoding
and.
B
I
guess
it's
a
basic
base68
too
many
characters
that
are
not
on
base
58
yeah,
so
the
base64
encoded
byte
stream,
which
the
byte
stream
is
in
its
turn,
serialized
structure
of.
B
B
It's
a
structure
that
represents
the
transaction,
essentially
the
signed
transaction.
It
has
actions,
it
has
nones,
it
has
signer
receiver
account
ids.
All
of
that
information
that
we
don't
want
to
focus
right
now
on.
But
what
I
wanted
to
show
is
that
there
is
no
indication
that
we
are
calling
the
some
sort
of
function
in
the
api.
From
the
api
point
of
view.
From
the
api
point
of
view,
we
are
setting
a
transaction,
it
doesn't
matter
which
kind
of
transaction
is
sent.
It's
always
like
this.
You
send
a
broadcast
tx.
B
B
Tx
status
either
experimental
one
or
even
regular
one.
Let's
take
a
look
into
it.
So
this
one
now
we
can
see
a
response,
actually
yeah
responses
here.
Let's.
B
So,
essentially
in
response
where
it
returned
the
same
object,
we
send
it
in
serialized
way.
B
So
just
a
reminder
in
response
to
broadcast
tx,
we
received
the
same
transaction
but
json
serialized
now,
so
we
can
essentially
just
confirm
that
everything
is
what
we
expected
to
send
was
there.
B
We
have
a
status
success,
value,
empty
string
and
the
the
initial
transaction
was
the
following.
The
signer
was
frauled
here
with
this
public
key.
I
signed
this
transaction
and
all
the
rest
is
not
very
important
right
now,
and
the
actions
of
this
transaction
was
that
the
first,
the
first
action.
C
B
B
B
So
again
you
receive
the
json
rpc
response
with
the
result
in
it
with
the
status
of
execution
and
the
initial
transactions
here,
and
the
transaction
is
sending
from
fraud.near
to
near.
With
this
pub
signed
with
this
public
key
and
the
actions
were
only
a
single
item.
It's
a
function,
call
method
call
method
name
is
sent.
B
B
B
If
you
go
back
again,
you
can
see
this
attached.
Deposit
is
the
variable
that
you
can
use
inside
the
contracts
to
manipulate
with
that
attached,
balance
and
store
it
or
send
over
somewhere
else.
So
this
is
the
function,
call
that
is
made
through
a
transaction.
It
is
changing
the
state
we
paid
near
talk.
We
we
paid
near
tokens
to
issue
the
transaction.
We
paid
network
tokens
to
execute
the
transaction
we
paid
for
gas,
and
we
also
attached
some
near
tokens
to
the
execution.
B
So
we
spend
our
tokens,
we
transfer
them.
It's
also
change
on
the
network,
so
we
made
a
bunch
of
changes
only
to
the
balance
of
our
own
and
also
the
method
itself
will
also
change
certain
state.
Certain
data
store
it
on
the
net.
B
Now
what
I
want
us
to
use
is
a
another
rpc
method
on
on
the
network.
Here
is
a
coral
command
that
you
essentially
craft
a
json
or
pc
body
with
the
method
name,
query.
B
Let
me
briefly
mentioned
that
we
have
a
dock
for
it,
so
we
have
a
bunch
of
different
query
types
to
view
access
key
or
whatnot,
and
there
is
also
a
documentation
how
to
make
a
contract
function.
Call
through
a
query,
but
I
want
us
to
make
sure
we
understand
that
it's
a
viewfind
view
method
function
call.
So
it's
the
only
way
to
change
something
on
the
network.
It
is
through
it
calling
making
a
transaction
and
sending
it.
B
B
B
It
expects
to
receive
a
single
argument
key
in
base
58
public
key
encoding,
and
it
will
return
me
a
strain
representation
of
the
balance.
Let's
see
so
what
we
have
we
need
to.
We
specify
the
method,
name,
get
key
balance
and
we
also
need
to
specify
our
arguments.
The
argument
is
a
key
and
we
need
to.
B
Encode
it
here
in
base64,
because
we
don't
require
everybody
to
use
json.
You
can
write
your
own
contract
and
expect
certain
inputs
in
any
format,
even
binary.
Most
of
our
sdks
you
by
default,
use
json
encoding,
but
we
don't
want
to
limit
anybody.
That's
why
we
choose
to
use
base64
encoding
here
so
to
come
up
with
a
proper
rx
parameter,
I'm
going
to
use
base64
from
a
con
line.
I
will
say:
okay,
I
want
to
create
the
key
which
key
okay,
let's
get
back,
we
just
sent
a
transaction.
A
Function
and
if
the
parameter
name
was
the
same
for
this
getkeybalance
function,
if
the
parameter
name
was
public
key,
you
could
have
just
used
the
original
base64
encoding
and
re-encode
it,
because
the
parameter
name.
B
B
That
it's
a
14
yoktaneer
here
attached
to
this
public
key.
B
B
So
this
is
a
this
constant
here,
it's
exactly
one
near
which
is
used
for
contract
operation
later
to
cover
storage
and
other
needs.
So
whenever
you
create
a
dread
packet,
you
will
deposit
one
year
for
the
account
operation.
A
And,
and
so
in
that
you've
you've
now
made
a
distinction
between
the
change
function.
The
view
function
right,
so
the
change
function
was
originally
sending
the
red
packet
you
sent
that
broadcast
tx
commit
transaction.
We
looked
at
the
response
to
get
an
idea
of
what
the
original
transaction
being
sent
was
because
there
was
encoded
as
json.
We
could
read
it
more
easily.
B
A
To
the
network-
and
so
you
could
see
okay
deposit
on
that
line
as
part
of
this
original
transaction
was
15
near
there's
a
signature.
A
You
know
the
method,
name
that
you
were
calling
send,
etc
right
all
these
details,
so
that
was
the
change
function
that
sent
the
transaction
that
the
network
arrived
at
consensus
over
this
transaction.
Basically,
you
were
changing
the
truth
of
the
network,
but
then
the
second
example
was
this
simple.
You
know
query
that
that
you
made
where
you
made
a
function,
call
using
the
query
method
function,
call
as
a
parameter
asking
the
network
for
some
truth
for
some
data
without
changing
anything,
and
it
just
replied.
A
Happily,
here's
how
much
you
know
near
is
attached
to
this.
This
public
key
inside
of
the
link
drop
contract
right
so
that
that's
kind
of
the
distinction
that
you're
making
right.
B
Exactly
yeah,
you,
you
perfectly
summarized
it
and
what
I
also
want
for
us
to
just
play
a
little
bit.
What
if
we
just
try
to
execute,
send
methods
as
a
view
function
right?
B
I
think
it's
it's
great
to
you
know,
experiment
with
such
things,
so
I
changed
the
method
name.
I
left
it
recently
the
same.
I
even
left
the
args
for
now
to
be
the
same,
which
is
a
key
instead
of
public
key.
So
let's
go
ahead
and
see
what's
going
to
happen
so
first,
this
was
gq
would
be
easier,
so
wasm
execution
failed
because
it
couldn't
decentralize
input
from
json
missing
field
public
key.
So
here
we
go
it's
the
first
error.
It
couldn't
really
parse
our
right.
So.
B
C
B
Yeah,
so
let's,
let's
just
try
to
fulfill
this
requirement
and.
B
A
C
B
Yep,
as
well
as
promises
which
create
essentially
a
new
function,
call
they
cannot
be
used
in
a
view
function
environment
because
they
would
create
a
new
receipt
and
they
would
cause
like
more
execution
to
to
progress,
and
that's
why
it's
a
crucial
limitation
of
viewpoles.
You
cannot
do
cross-contract
calls
in
view
methods,
but
you
can
simulate
that
you
can
always
think
about
your
cross
contract
polls
as
a
chain
of
call
to
one
function.
It
will
return
your
result.
You
send
this
result
to
the
next
function.
B
A
Yeah,
can
we
just
talk
for
a
couple
of
minutes
about
the
first,
maybe
five
or
six
of
these,
because
I'm
surprised
that
you
can't
I
I
have
a
guess,
but
I'm
surprised
that
you
can't
interrogate
the
you
know:
virtual
machine
for
signer
account
id
or
attach
deposit
or
prepaid
gas
is
it.
Why
is
that?
Why
can't
you
just
interrogate
the
environment
and
then
return
that
value
with
attached
deposit.
B
Well,
I
guess
it's
from
the
just.
You
know
strictness
point
of
view.
We
want
to
sign
our
county
to
be
always
validated
that
it
is
indeed
a
signer
and
in
the
in
the
context
of
the
view,
call
there
is
no
signature
involved.
I
don't
need
to
have
a
key.
I
don't
need
to
have
having
even
account
on
me
or
to
make
a
view.
Call
that's
why
you
can.
B
I
cannot
confirm
that
I'm
the
user
that
is
signing
this
thing,
that's
why,
instead,
what
we
usually
require
in
view
functions
is
to
specify
the
account
id
explicitly
as
an
argument
and
instead,
instead
of
trying
to
come
up
with
some
api,
how
you
would
pass
certain
environment
vari
variables
throughout
this
view,
function.
A
A
No
account
to
deposit
it
from
so
there's
really
that
that's
also
nonsensical
right,
prepaid
gas
and
you
prepaid
gas
same
idea.
B
B
This
view
view
function
is
you
can
you
can
run
it
for
for
an
hour?
No
problem
from
like
from
network
perspective,
it's
fine,
but
from
our
pc
point
of
view
it
will
be
too
expensive
to
allow
everybody
to
call
very
expensive
functions
and
that's
why
we
limited
on
the
jason
rpc
side
view
functions
to
be
quite
small
in
their
allowance,
so
they
can't
can
only
spend
something
like
100
milliseconds.
I
guess
how
are
you
limiting
that
through
gas,
so
we
essentially
use
the
same
gas
technique.
B
A
For
anything,
okay,
so
it's
a
little
bit
confusing
for
me
because
there
is,
there
is
a.
There
are
two
max
gas
kind
of
limits
in
genesis,
config
and-
and
there
are
some
some
branches
in
near
core
that
distinguish
between
view
function.
Calls
and
change
function,
calls
using
those
gas
limits
as
a
sort
of
the
maximum
limit
of
gas.
That.
B
Can
be
brought
if
your
masses
do
not
use
the
genesis
config
they
they
use
either
either
we
use
a
hard
coded
value
or
can
be
configured
at
runtime
like
any.
Essentially
I,
as
the
owner
of
a
node,
I
can
run
any
like.
I
can
run
my
own
rpc
node,
modify
the
value
and
allow
to
to
view
function,
calls
to
be
executed
for
an
hour.
No
problem
I
can.
I
can.
I
can
enable
it
for
my
my
own
rpc
server.
C
B
It
will
not
affect
the
network
in
any
way
it
will.
It
will
it's
just
a
matter
of
resource
constraint.
We
don't
want
to
allow
like
our
arbitrary
computation
happening
on
the
on
our
public
nodes.
It's
only.
B
So,
basically,
what
to
to
to
just
you
know,
push
the
boundary
of
this
idea.
Let's
have
this
thought
experiment,
essentially
what
a
view
function
is
needed.
Let's
have
exactly
a
look.
What
this
function
is
needed
is
the
this
map
of
which
is
called
accounts,
which
is
essentially
public
key
to
balance.
This
is
the
only
thing
it's
it
needs
to
get
executed.
B
B
B
So
I
even
have
a
suggestion
that
we
may
explore
in
the
future
extension
to
near
api
jazz,
which
will
essentially
download
the
state
download
the
contract
and
execute
certain
methods
that
it's
needed
on
the
on
the
browser
on
the
client
side.
You
can
do
it,
you
know
again
and
again,
whatever
amount
of
times
for
whichever
accounts
it
needs
to
compete,
to
make
the
computation
and
this
way
avoid
any
interaction
through
json
or
pc.
So
you
don't
need
json
or
pc
anymore.
A
Yeah,
that
makes
sense
so
so,
if
you're,
if
you're
dealing
with
kind
of
some
some
application,
that
that
has
a
lot
of
reads
from
the
network
and
you
want
to
make
it
more
responsive.
That's
your
point.
You
can
just
download
the
the
contract
and-
and
you
can
download
the
state
of
the
of
the
account
right
there
in
your
browser
and
just
just
interact
with
it
locally
and
then
update
the
cache
whenever,
whenever
you
want
to
do
that
right,
yeah
yeah
that
that's
interesting,
I
hadn't
thought
of
that.
Yeah.
A
Yeah
I'm
this.
This
has
been
great
frol.
I
don't
think
there's
is
there
much
else
that
you
want
to
cover
in
terms
of
this
or
do
you
feel
like
this
is
this?
Is
enough.
B
I
feel
it
it's
enough
for
now
we
may
dive
into
like
more
in
details
how
they
function
like
how
the
transactions
essentially
are
construct
constructed,
but
I
think
we
can
go
to
with
a
different.
So
it's
it's
a
completely
different
topic.
Yeah.
C
B
A
huge
one
I
would
cover
it
in
a
separate
session.
A
Yeah,
okay,
cool!
So
should
we
stop
recording
here
and
then.
B
I
think
thanks
everybody
to
for
listening
and
hope
you,
if
you
have
any
questions,
feel
free
to
ask
them
in
discord
and
reach
me
out
give
help.
So.