NEAR Documentation
  • Basics
  • Develop
  • Stake
  • Integrate
  • Tokens
  • Contribute
  • API
  • Community
  • GitHub

›Using Contracts

Quickstart

  • Orientation
  • Building Apps
  • Networks

Tutorials

  • Introduction
  • Guided Walkthroughs

    • Figment Tutorials
    • Create Transactions
    • Issue a Token
    • Cross-Contract Calls
    • Simple AssemblyScript tests
    • Simple Rust smart contract

    Helpful References

    • Contract Structure
    • Project Structure

    Videos

    • Accounts & keys
    • Smart Contract Reviews
    • Misc

JavaScript library

  • Introduction
  • Guides
  • Examples

Smart Contracts

  • Introduction
  • Creating Contracts

    • Rust
    • AssemblyScript

    Using Contracts

    • Rust
    • JavaScript
    • API

    Testing Contracts

    • Testing contracts

    Virtual Machine Limits

    • Runtime Limits

Ethereum Compatibility

  • Network status
  • Simple script & NEAR CLI guide
  • Pet Shop example
  • Web3 provider
  • Using Truffle
  • Local setup
  • Proxy RPC Server
  • Testing contracts

Machine Setup

  • Local Development on TestNet
  • Local Development on Local Network
  • Running a node
  • Running a Node on Windows

FAQ

  • Developer FAQ
Edit

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 of request_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 using broadcast_tx_commit or asynchronously via broadcast_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 and change methods.

Got a question? Ask it on StackOverflow!

Last updated on 1/20/2021 by Josh
← JavaScriptTesting contracts →
  • view methods:
  • change methods:
  • Wallet
  • Explorer
  • Examples
  • Docs
  • Twitter
  • GitHub
  • Discord
  • Telegram
  • WeChat
  • YouTube

Developers

  • Overview
  • Technology
  • Docs
  • GitHub
  • Bounties
  • Developer Program
  • Survey

Ecosystem

  • Events
  • Contributor Program
  • Guild Program
  • Startup Accelerator
  • Bounties
  • Tokens

About

  • Team
  • Careers
  • Backers
  • Press Kit
  • Brand Guidelines
  • Privacy Policy

2020 NEAR Protocol|All rights reserved|hello@near.org|Privacy Policy