Skip to main content
Reading data from the blockchain is free, fast, and does not require a private key (unless you are connecting to a private node).

1. Calling View Methods

Use near.view() to query smart contracts. This connects to the RPC and fetches the state directly.

Basic Usage

Arguments are automatically JSON-serialized for you.

Typed Return Values

By default, near.view returns any. You can pass a generic type to get a strongly-typed response.
Pro Tip: For even better type safety (including arguments), check out Type-Safe Contracts.

2. Reading Historical Data (Time Travel)

By default, you read from the “Optimistic” head of the chain (the absolute latest state). Sometimes you need to read from a specific point in the past, or ensure you are reading fully finalized data. Most read methods accept an options object as the last argument.

3. Checking Balances

Available Balance

Use near.getBalance() to get the available (spendable) balance. This accounts for storage costs and staked tokens.

Full Account State

Use near.getAccount() when you need all balance details:
Why is available different from balance?NEAR accounts must reserve tokens to pay for on-chain storage. However, staked tokens count towards this requirement. So:
  • If staked ≥ storage cost → all liquid balance is available
  • If staked < storage cost → some liquid balance is reserved
This is why getBalance() returns available, not balance — it’s what you can actually spend.

4. Listing Access Keys

Use near.getAccessKeys() to list all access keys for an account.
To get a single access key by public key, use near.getAccessKey():

5. Batching Requests

If you need to make multiple read calls at once, use near.batch(). This runs them in parallel (like Promise.all) but preserves the types of the results in the returned tuple.

6. Network Status

Use near.getStatus() to check the health of the node and the latest block height.