NEAR

NEAR CLI

  1. Install the NEAR CLI.

  2. Use the --node_url flag to operate through your Chainstack-deployed NEAR node:

    near COMMAND --node_url YOUR_CHAINSTACK_ENDPOINT
    

    where

    • COMMAND — a supported NEAR CLI command
    • YOUR_CHAINSTACK_ENDPOINT — your node HTTPS or WSS endpoint protected either with the key or password. See also node access details.

JSON-RPC API

Interact with your NEAR node using JSON-RPC API.

Use curl or Postman.

Example to get the latest block:

curl -H "Content-Type: application/json" \
  -d '{"jsonrpc": "2.0", "id": "1", "method": "block", "params": {"finality": "final"}}' \
  YOUR_CHAINSTACK_ENDPOINT

where

YOUR_CHAINSTACK_ENDPOINT is your node HTTPS or WSS endpoint protected either with the key or password. See also node access details.

near-api-js

  1. Install near-api-js.

  2. Use JsonRpcProvider to connect to your NEAR node.

    const nearAPI = require("near-api-js");
    const connectionInfo = {
        url: "YOUR_CHAINSTACK_ENDPOINT"
    };
    const provider = new nearAPI.providers.JsonRpcProvider(connectionInfo);
    async function main() {
        const response = await provider.block({
            finality: "final",
        });
        console.log(response)
    }
    main();
    

    where YOUR_CHAINSTACK_ENDPOINT is your node HTTPS or WSS endpoint protected either with the key or password. See also node access details.