NEAR Protocol (NEAR) - NEAR Protocol

NEAR Protocol is a high-performance, sharded Layer-1 blockchain with human-readable account names (example.near) and a developer-friendly runtime (contracts in Rust and JavaScript).

It is not EVM-compatible: NEAR exposes its own JSON-RPC 2.0 API with NEAR-native methods (query, block, chunk, tx, send_tx, and others) rather than the Ethereum eth_* surface. The native token is NEAR, denominated in yoctoNEAR (1 NEAR = 10^24 yoctoNEAR). This reference documents the NEAR JSON-RPC interface, available over HTTP and WebSocket.

Key Features

  • Native JSON-RPC: A JSON-RPC 2.0 API with NEAR-specific methods — not eth_*; account and contract reads go through the query method with a request_type
  • Sharded Layer-1: Blocks are split into per-shard chunks (Nightshade sharding) — many methods take a shard_id or return per-chunk data
  • Named Accounts: Human-readable account IDs (example.near) alongside 64-character implicit (hex) accounts
  • yoctoNEAR: Balances and gas are denominated in yoctoNEAR (1 NEAR = 10^24 yoctoNEAR — 24 decimals)
  • Finality Control: Most read methods accept finality (optimistic / final) or an explicit block_id (height or hash)
  • Access Keys: Accounts hold multiple access keys — full-access or function-call keys with allowances — queried over RPC

TECHNICAL DISCLAIMER: AUTHORITATIVE JSON-RPC API SPECIFICATION.

GetBlock's RPC API reference documentation is provided exclusively for informational purposes and to optimize the developer experience. The canonical specification for the NEAR JSON-RPC interface is maintained by NEAR and published at docs.near.org/api/rpc. Method availability can depend on the node's nearcore version — some methods were renamed from EXPERIMENTAL_ prefixes in nearcore 2.14.0.

Network Information

PropertyValue
Network NameNEAR Protocol Mainnet
Chain IDmainnet
Native CurrencyNEAR
DenominationyoctoNEAR (1 NEAR = 10^24 yoctoNEAR — 24 decimals)
Account ModelNamed accounts (example.near) + implicit (hex)
ConsensusNightshade (sharded Proof-of-Stake)
FinalityDeterministic (doomslug + final)
Block Explorernearblocks.io

Base URL

https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/

NEAR Protocol is served from the Frankfurt region only — use the Frankfurt base URL above. WebSocket is available at wss://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/.

Supported Networks

NetworkChain IDJSON-RPCWSSGraphQLMEV protected (WebSocket)MEV protected (JSON-RPC)Frankfurt, GermanyNew York, USASingapore, Singapore
Mainnetmainnet✅✅❌❌❌✅❌❌
Testnettestnet✅✅❌❌❌✅❌❌

Quickstart

In this section, you will learn how to make your first call with either:

  • Axios
  • Python

Before you begin, you must have already installed npm or yarn on your local machine. If not, check out npm or yarn.

  1. Set up your project using this command:

    For npm:

    bashmkdir near-api-quickstart
    cd near-api-quickstart
    npm init --yes

    Or yarn:

    bashmkdir near-api-quickstart
    cd near-api-quickstart
    yarn init --yes

This creates a project directory named near-api-quickstart and initialises a Node.js project within it.

  1. Install Axios using this command:
    Using npm:

    bashnpm install axios

    Using yarn:

    bashyarn add axios
  2. Create a new file and name it index.js. This is where you will make your first call.

  3. Set ES module "type": "module" in your package.json.

  4. Add the following code to the file (index.js):

    jsimport axios from "axios"
    let data = JSON.stringify({
      "jsonrpc": "2.0",
      "method": "gas_price",
      "params": [
        169528908
      ],
      "id": "getblock.io"
    });
    
    let config = {
      method: 'post',
      maxBodyLength: Infinity,
      url: 'https://shared.eu-central-1.getblock.io/<ACCESS_TOKEN>',
      headers: { 
        'Content-Type': 'application/json'
      },
      data : data
    };
    
    axios.request(config)
    .then((response) => {
      console.log(JSON.stringify(response.data));
    })
    .catch((error) => {
      console.log(error);
    });
    

    Replace <ACCESS_TOKEN> with your actual access token from GetBlock.

  5. Run the script:

    bashnode index.js

    The current gas price will log in the console like this:

    json {
        "jsonrpc": "2.0",
        "result": {
            "gas_price": "100000000"
        },
        "id": "getblock.io"
    }

Before you begin, you must have installed Python and Pip on your local machine.

  1. Set up your project using this command:

    bashmkdir near-api-quickstart
    cd near-api-quickstart
  2. Set up a virtual environment to isolate dependencies:

    bashpython -m venv venv
    source venv/bin/activate  
    # On Windows, use venv\Scripts\activate
  3. Install the requests library:

    bashpip install requests
  4. Create a new file called main.py and insert the following code:

    python import requests
    import json
    
    url = "https://shared.eu-central-1.getblock.io/<ACCESS_TOKEN>"
    
    payload = json.dumps({
      "jsonrpc": "2.0",
      "method": "gas_price",
      "params": [
        169528908
      ],
      "id": "getblock.io"
    })
    headers = {
      'Content-Type': 'application/json'
    }
    
    response = requests.request("POST", url, headers=headers, data=payload)
    
    print(response.text)
    

    Replace <ACCESS_TOKEN> with your actual access token from GetBlock.

  5. Run the script:

    bashpython main.py

Available API Methods

Network & Node

MethodDescription
statusReturns the node's general status: sync status, nearcore and protocol version, latest block hash and height, and the current validator set
network_infoReturns the node's current network connections: active peers, known producers, and sent/received data counts
validatorsReturns the active validator set and validation state for an epoch
gas_priceReturns the gas price for a specific block, or the latest price when called with [null]
genesis_configReturns the network's genesis configuration: the parameters the chain was launched with
EXPERIMENTAL_protocol_configReturns the protocol configuration for the latest or a specific block: runtime, gas, and economic parameters currently in force

Blocks & Chunks

MethodDescription
blockReturns detailed information about a block, selected by finality ("final"/"optimistic") or by block_id (height or hash)
chunkReturns the details of a chunk, by chunk hash, or by block_id plus shard_id
block_effectsReturns the state changes that occurred in a block — account, access-key, data, and contract-code changes

Accounts & Contracts

MethodDescription
query: view_accountReturns the basic account information for a NEAR account: balance, locked stake, storage usage, and the hash of its contract code (if any)
query: view_codeReturns the deployed contract code (WASM, base64-encoded) for an account, with its hash
query: view_stateReturns the key-value state stored under a contract account, optionally filtered by a base64 key prefix
query: call_functionExecutes a read-only contract view method and returns its result, without creating a transaction

Access Keys

MethodDescription
query: view_access_keyReturns information about a single access key on an account: its nonce and permission (full access or a function-call permission)
query: view_access_key_listReturns all access keys registered to an account, each with its public key, nonce, and permission

State Changes

MethodDescription
changesReturns fine-grained state changes filtered by a changes_type

Transactions

MethodDescription
send_txBroadcasts a signed transaction and waits for the requested execution milestone (wait_until: NONE, INCLUDED, EXECUTED_OPTIMISTIC, FINAL, etc
broadcast_tx_asyncBroadcasts a signed transaction and returns its hash immediately, without waiting for execution
broadcast_tx_commitBroadcasts a signed transaction and waits until it is included and executed, returning the full outcome
txReturns the status of a previously submitted transaction, by tx_hash plus sender_account_id (or by signed_tx_base64)
tx_statusReturns the transaction status plus the full list of receipts
EXPERIMENTAL_receiptFetches a single receipt by its id, returning its predecessor, receiver, and action or data payload

Maintenance

MethodDescription
EXPERIMENTAL_maintenance_windowsReturns the upcoming maintenance windows (block-height ranges) for a validator account — the periods in the current epoch when it is neither producing nor validating and can safely restart

Light Client

MethodDescription
next_light_client_blockReturns the next light-client block after the given known block hash — the data a light client needs to advance and verify the chain without a full node
EXPERIMENTAL_light_client_proofReturns an execution-outcome inclusion proof (for a transaction or receipt) against a given light-client head, so a light client can verify the outcome

Support

For technical support and questions:

See Also