►
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-04--the-giving-foundation
---
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
B
Okay,
okay,
yeah,
so
this
is
giving
foundation
by
yeah,
so
my
teammate
gan
and
myself
just
so.
The
basic
idea
of
this
is
to
make
sure
that
if
a
person
wants
to
like
donate
some
money,
he
can
choose
whatever
projects
you
want
to
donate
like.
Instead
of
like
just
giving
money
to
the
ngo,
he
can
just
donate
to
a
specific
projects
out
because
in
an
ngo
there
can
be
like
several
projects
are
there,
so
I
can
choose
any
projects
and
I
can
go
and
donate
there
so
yeah.
B
So
for
that
what
we
have
to
do
is
first,
we
have
to
register
our
ngo
once
we
register
ngo.
We
can
add
basically
projects
into
that.
So
suppose
I
I'm
a
like
a
ngo,
and
I
want
to
raise
that.
So
I
can
use
my
pro
portal
and
I
can
register
mind
you
and
then
there
I
can
add
the
different
projects
who
wants
to
register
under
my
ngo
and
then
yeah,
so
the
other
facility,
like
claim
tax.
I
will
explain
this
while
going
through
the
code
yeah.
B
So,
in
order
to
register
ngo,
so
we
can
provide
the
ngo
address
and
then
we
can
add
different
projects.
Basically,
while
adding
the
projects,
we
can
specify
the
project
address
and
also
the
funds
required
to
for
that
particular
project,
so
suppose
for
like
children,
welfare.
So
there
is
a
I
want
to
like
register.
One
project
called
children
welfare.
So
I
can
put
that
into
this
and
then
I
can
say:
okay,
what
is
the
specific
amount
of
funds
is
required
for
this
one?
B
And
if
someone
wants
to
donate,
they
can
use
our
portal
and
they
can
donate
basically
yeah
so
yeah.
So
this
is
a
flow.
Basically,
I
can
explain
through
the
code
yeah.
So
this
is
the
code
base
and
we
yeah.
We
have
basically
two
class
project
and
ngo,
so
this
ngo
is
the
exported
class.
So
basically,
this
is
the
ngo
where
a
person
when
they
try
to
register
this
particular
register
ngo
method,
they
can
call
and
they
can
register
an
ngo.
B
So
internally
we
generate
an
basically
an
id
for
the
ngo
to
uniquely
identify
and
then
push
push
that
into
a
list
and
yeah.
So
there's
a
another
like
we
have
vector
where
we
have
where
we
are
pushing
this
one,
and
also
we
have
a
map
basically
to
map
the
of
ngo
id
with
the
ngo
and
then,
if
suppose,
now
someone
wants
to
add
their
project
in
the
in
a
specific
ngo.
So
they
can
do
that.
B
So
they
can
do
that
by
calling
this
ad
project
and
in
here
they
have
to
pass
the
ngo
id.
Basically
when
they,
when
they
come,
they
can
choose
the
ngo
id.
It's
all
from
the
front
end
view.
If
we
see
we,
they
can
provide
the
ngo
id
whatever
we
have
and
inside
that
ngo
id
they
can
tell
okay,
we
are
registering
our
project
inside
this
ngo
and
they
can
send
the
address
basically
for
the
project,
since
we
need
the
address.
A
B
Here
we
are
just
trying
to
see
whether
whatever
ngo
id
they
have
passed
past
it
already
exist.
If
it
don't
exist,
then
we
will
not
be
able
to
arrest
that
we
can
say
that.
Okay,
this
ngo
instance
is
not
existing,
so
we
cannot
add
this
particular
project,
so
we
have
to
send
an
ngo
id
which
is
already
registered
in
our
portal
yeah
and
yeah.
So
this
is
the
way
we
will
add
that
our
project
and
and
also
we
have
a
mapping
of
the
project
id
and
projects.
B
Also
like
this
one,
like
project
id
and
the
map
for
the
project.
This
is
the
get
ngo.
So
first
one
a
person
wants
to
see
what
are
the
ngos
we
have,
so
they
can
just
see
all
the
ngos
we
have
and
then
from
there
once
they
choose
the
ngo.
Then
they
can
add
the
projects
and
then
they
can
donate
that
so
they're
to
flow.
When
this,
if
a
person
wants
to
add
their
project,
they
can
do
or
if
their
person
wants
to
donate
to
a
specific
project
they
can
do.
B
This
is
get
projects
to
get
the
project
so
once
they
have
the
ngos,
they
can
choose
one
of
the
ng
and
they
can
pass
the
ngo
id.
So
we
will
provide
all
the
basically
the
project.
So
if
you
see
here
we
can.
B
We
are
listing
all
the
projects
here
based
on
the
ngo
id
and
then
once
that
is
done
once
a
person
has
like
a
registered
project
so
that
that
flow
is
done
and
now
suppose,
if
I
am
a
user
and
I
want
to
donate
to
a
particular
project
in
a
specific
ng
or
any
ngo.
So
I
will
see,
though,
all
the
ngos,
I
will
choose
the
ngo
and
then
I
will
go
to
the
project.
I
will
choose
the
project
and
then
I
will
invoke
basically
this
particular
function.
B
What
it
will
do
is
it
will
just
see
first,
whether
that
ngo
id
is
there
or
not,
and
then
also
it
will
see
what
are
the
funds
required
and
based
on
the
funds.
It
will
subtract
what
what
I
am
making
so
suppose.
It's
like
a
hundred
dollars
so
and
I'm
doing
like
50,
so
that
will
be
subtracted
and
it
will
be
updated.
B
So
for
this
specific
project
I
have
the
50
of
the
donations
like
50
is
done,
so
just
50
is
left
so
we'll
update
that
in
the
project
so
the
next
time,
whoever
comes,
they
will
see.
Okay
for
this
project,
we
have
already
like
got
some
funding,
and
this
much
funding
is
left
and
we
will.
We
will
do
the
transfer
basically
yeah
yeah,
so
this
is
done
and
yeah
for
so
the
other
part.
What
we
are
doing
is
for
extra
like
for
the
future
enhancement.
B
We
were
doing
like
suppose,
if
someone
wants
to
claim
a
certain
like
tax
benefit,
so
to
show
that
okay,
he
has
done
some
donation,
so
he
can
do
that
so
that
that
will
be
like
next.
We
have.
B
We
were
planning
to
see
the
transaction
and
the
amount
he
has
done,
and
then
we
can
issue
a
particular
tax
certificate
or
something
like
that,
so
that
he
can
claim
that
tax
center
yeah
and
in
order
to
run
this
one,
I
will
ask
my
team
teammate
gyan
to
share
her
skin
and
invoke
the
contacts
and
also
execute
the
test
cases.
Also
yeah.
C
All
right,
I
am
back
with
the
demo,
so
what
we
have
done
to
run
the
contracts
yet
again,
as
you've
already
seen,
I
have
written
some
stuff.
So
initially
we
register
we
are
going
to
register
a
couple
of
ngos
post
the
end
user
register,
we'll
use
the
ids
to
add
the
projects
to
the
ngos,
we'll
get
the
ngos
we'll
get
the
projects
and
then
we'll
perform
the
donut
too
I'll
also
explain
the
union
test
once
we
we
are
done
with
this.
So
let
me
run
the.
C
Okay,
so
I'm
just
gonna
pick
up
the
one
ngo.
Let's
say
this
one
and
now
I'm
going
to
add
a
project
to
this
ngo.
C
Okay,
so
you
can
see
that
the
address
of
the
project
is
again
one
of
my
own
test
net
ids.
That
is
a
name
and
then
I'm
sending
a
couple
of
funds
right
and
then
I'm
going
to
get
the
ngo
as
well
as
get
the
different
projects
that
are
associated
with
this
particular.
So
what
we
can
do
is
just
to
experiment.
C
So
you
can
see
that
there
is
this
call
that
is
being
scheduled.
One
project
has
been
created.
There
are
a
couple
of
funds.
The
project
name
is
book,
drive
one.
Then
there
is
a
second
project
called
book
type
2..
All
right,
then
I'm
going
to
get
the
ngo.
So
you
see
that
three
ngos
that
we've
registered
right
at
the
beginning
and
then
we're
going
to
get
the
projects
for
this
particular
given
end
you.
C
That
is
two
projects
that
we
created
now,
let's
copy
one
of
the
project
ids
and
see
if
somebody
can
actually
donate
to
this
project
right
so
here
is
gonna,
be
the
project
id
that
was
generated,
copying
the
ngo
id
all
right
and
for
donation
I'm
going
to
be
sending
the
amount
right
here,
so
I
am
being
a
little
all
right.
Let's
say,
let's
say
that
I'm
going
to
send
two
nearest
right.
Let
me
save
this
and
then.
C
Please
ignore
the
pointers
okay,
so
you
can
see
that
this
function,
donate
is
being
called
with
some
attached
to
here.
It
says
done.
That
means
the
transaction
is
done,
let's
open
this
and
check
it
out
in
the
explorer.
C
So
I
basically
want
to
show
that
you
know
amount
was
transferred,
so
you
can
see
that
two
were
transferred
to
gan
lakshmi
or
tesla
was
the
registered
project
owner
right.
I
had
registered
two
projects.
One
of
them
was
the
book
drive
two
and
I
chose
that
project,
and
you
can
see
that
too
near
what
transfers
within
the
contract
itself.
Let
me
quickly
walk
through
the
while
I
walk
it.
C
So,
as
expected,
the
unit
tests
are
just
checking
the
different
functionality.
We
can,
whether
we
can
register
an
ngo.
Can
we
add
a
project?
Can
we
get
the
registered
projects?
Can
we
get
all
the
projects,
then
a
sad
part
is
there,
that
is,
that
returns
the
failure
of
the
project
edition
by
sending
a
wrong
ngo
id.
So
this
has
run
in
the
past,
so
this
will
run
as
we
are
short
of
time.
We.
C
Yeah,
I've
run
it
before
as
well.
Okay,
so
ngo
project,
happy
parts
and
then
start
parts.
You
can
see
that
it's
all
passed
and
then
we
have.
A
Okay,
great
right
on
time,
thank
you,
okay
and
then
jan,
you
had
a
request
just
to
revisit
the
demo
from
before,
because
there
was
a
an
issue
with
copy
pasting
id.
So
please
go
ahead
and
take
a
minute
to
correct
that.
Yes,
but
let's
keep.
C
Yeah,
okay
yeah,
so
in
my
previous
demo,
okay,
so
I
actually
ran
the
whole
thing
again,
so
you
can
see
here
like
after
the
test
cases,
I
copy
pasted
the
wrong
id.
So
here
is
a
new
game
id
and
this
person
guess
true.
You
can
see
that
the
transaction
was
successful
and
there
is
a
winner.
Basically,
what
again
I
wanted
to
show
you
is
that
so
gyan
lakshmi.snet
is
the
winner.
So
all
the
amount
that
is
captured
in
the
contract
should
actually
be
going
to
this
person
through
the
transfer
function.
C
So
you
can
see
that
there
is
a
transfer
function
that
happened
inside
there's
some
logs
etc
and
some
amount
yeah
25
year
was
transport,
so
that
is
like
the
cumulative
of
whatever
whatever
amount
was
sent
to
sending
the
what
was
locked
in
the
day.
So
this
was
transferred
to
the.
C
Show
the
last
the
parts
like
these
parts
that
what
happens
once
somebody
like
makes
a
guess.
They
make
a
guess
that
this
is
what
wasn't
running
three
functions,
make
a
guess,
finish
the
game
and
then
get
the
winner
at
this
yeah.
That's
all.