API
To invoke smart contracts on the NEAR blockchain, we use a JSON RPC 2.0 interface. This interface is used by near-api-js
to call on two types of methods; view
and change
.
view
methods:
View methods do not effect the blockchain state and use the RPC
query
method with a param ofrequest_type
:call_function
.
[ Click here ] to see an example of a call_function
request.
change
methods:
Alternatively, you can modify state on the blockchain by invoking a
change
method. To perform this RPC call, a signed transaction is required. This can be done either synchronously usingbroadcast_tx_commit
or asynchronously viabroadcast_tx_async
.
[ Click here ] to see an example of a broadcast_tx_async
request.
[ Click here ] to see an example of a broadcast_tx_commit
request.
See here for more information about
view
andchange
methods.
Got a question?
Ask it on StackOverflow!