NEAR RPC: A Developer's Guide (JSON-RPC, Not EVM)
NEAR has no EVM chain ID and no eth_* namespace. It is a sharded proof-of-stake layer 1 with named accounts, WebAssembly contracts and its own JSON-RPC dialect. On the current protocol, two changes break code copied from older NEAR examples: the standalone view_* methods are gone, and every call must use named parameters rather than positional arrays.
We measured NEAR through the SwiftNodes endpoint on December 5, 2026, against protocol version 88 and nearcore 2.14.1. Blocks arrived every 0.554 seconds on average, finality trailed the head by about two blocks, and the route kept roughly 34 hours of block history. Those numbers, and the exact errors the node returns, are what this guide is built from.
The endpoint
https://rpc.swiftnodes.io/rpc/near?key=YOUR_API_KEY
The proxy slug is near. There is no WebSocket endpoint for NEAR on SwiftNodes, so plan for HTTP polling or a local subscription layer. The network identifier is chain_id: "mainnet" inside the status response; there is no EVM chain ID to configure. The genesis hash is EPnLgE7iEq9s7yTkos96M3cWymH5avBAPm3qx3NXqR8H.
If your tool expects an id, currency and rpcUrls block, NEAR does not fit that shape. Use a NEAR client library or raw JSON-RPC. The official public endpoint is https://rpc.mainnet.near.org, which is useful as a second opinion when you are debugging.
What we measured
| Item | Measured on 2026-12-05 |
|---|---|
| Protocol version | 88 (nearcore 2.14.1) |
| Network ID | mainnet; no EVM chain ID |
| Block interval | 0.554 s mean, 0.560 s median over 59 intervals (range 0.402-0.686 s) |
| Head at measurement | 227,629,466 at 2026-12-05T07:24:53Z |
| Finality lag | final 2 blocks / 1.115 s behind optimistic in one snapshot |
| Block history | From 227,418,737 (2026-12-03T21:30:04Z), about 34 hours |
| Archive | client_config.archive = false |
| Shards in sample block | 10, with IDs 1, 4, 6, 7, 8, 9, 10, 11, 12, 13 |
| Gas limit | 1 PGas per shard, 10 PGas across the sampled block |
| Gas price | 100,000,000 yoctoNEAR per gas, constant in every sampled block |
| Validators | 341 current, 350 next; 100 block-producer seats per epoch |
| Epoch length | 43,200 blocks (about 6.6 hours at the measured block time) |
| JSON-RPC batch | Not supported |
| WebSocket | Not offered on this route |
NEAR uses named parameters, not positional arrays
This is the first thing that breaks. EVM clients send params as an array:
{"jsonrpc":"2.0","id":1,"method":"eth_getBalance","params":["0x...","latest"]}
NEAR rejects that shape. A call to block with params: [{"finality":"final"}] returned HTTP 400:
{"name":"REQUEST_VALIDATION_ERROR",
"cause":{"name":"PARSE_ERROR","info":{"error_message":
"Failed parsing args: data did not match any variant of untagged enum BlockId"}},
"code":-32700,"message":"Parse error"}
The same happens when the height is a string. {"block_id":"227629278"} fails; {"block_id":227629278} works, and so does a 32-byte base58 block hash. The rule is simple: send an object, and give block_id an integer or a hash.
const res = await fetch("https://rpc.swiftnodes.io/rpc/near?key=YOUR_API_KEY", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({
jsonrpc: "2.0",
id: 1,
method: "block",
params: { finality: "final" },
}),
});
const { result, error } = await res.json();
gas_price and validators are the exceptions that accept [null] as well, but there is no reason to use the array form. Stay with named params everywhere and the dialect is consistent.
The standalone view_* methods are gone
Several NEAR tutorials still call view_account, view_access_key_list or view_state directly. On protocol 88 every one of them returned -32601 Method not found:
{"name":"REQUEST_VALIDATION_ERROR",
"cause":{"name":"METHOD_NOT_FOUND","info":{"method_name":"view_account"}},
"code":-32601,"message":"Method not found","data":"view_account"}
The replacement is the query method, which takes a request_type plus the same finality and account fields:
| What you want | Request |
|---|---|
| Account balance, code hash, storage | {"request_type":"view_account","finality":"final","account_id":"wrap.near"} |
| Contract code | {"request_type":"view_code","finality":"final","account_id":"wrap.near"} |
| Contract state | {"request_type":"view_state","finality":"final","account_id":"...","prefix_base64":""} |
| Access keys for an account | {"request_type":"view_access_key_list","finality":"final","account_id":"aurora"} |
| One access key | {"request_type":"view_access_key","finality":"final","account_id":"aurora","public_key":"ed25519:..."} |
| Read-only contract call | {"request_type":"call_function","finality":"final","account_id":"wrap.near","method_name":"ft_metadata","args_base64":""} |
A view_account query for wrap.near returned:
{"amount":"36013388368415888372931824117156",
"block_height":227629416,
"code_hash":"DL2f5xmZ44cQRP6vBMt94rvseH5d5KKnAGis2WkTAsh1",
"locked":"0",
"storage_paid_at":0,
"storage_usage":170042575}
That amount is 36,013,388.368 NEAR. The storage_usage is 170,042,575 bytes, which is why a full view_state on this contract fails:
{"name":"HANDLER_ERROR",
"cause":{"name":"TOO_LARGE_CONTRACT_STATE"},
"code":-32000,"message":"Server error",
"data":"State of contract wrap.near is too large to be viewed"}
There is no pagination on view_state. For large contracts, read specific keys with view_state plus prefix_base64, or index the contract's events and keep your own store.
Accounts, balances and 24 decimals
NEAR accounts are human-readable IDs, not 20-byte addresses. wrap.near, aurora and intents.near are valid accounts; 0x... is not. Contract accounts can hold NEAR, storage and code at the same time.
The decimal rule is the second common bug after the parameter shape. NEAR has 24 decimals, not 18. Every balance in an RPC response is an integer string in yoctoNEAR. Number(amount) / 1e18 is wrong by a factor of one million.
const yocto = BigInt("36013388368415888372931824117156");
const padded = yocto.toString().padStart(25, "0");
const near = `${padded.slice(0, -24)}.${padded.slice(-24)}`;
// "36013388.368415888372931824117156"
For reference, wrap.near held 36,013,388.368 NEAR and aurora held 145,768.498 NEAR when we sampled. Those are native balances. NEP-141 token balances are separate and come back from call_function:
const { result } = await rpc("query", {
request_type: "call_function",
finality: "final",
account_id: "wrap.near",
method_name: "ft_balance_of",
args_base64: Buffer.from(JSON.stringify({ account_id: "wrap.near" })).toString("base64"),
});
const balance = JSON.parse(Buffer.from(result.result).toString("utf8"));
// "107850764923243453203839068" yocto wNEAR
result.result is an array of bytes, not a string. Decode it before parsing. The same call with ft_metadata returned decimals: 24 and symbol: "wNEAR", so do not assume a NEP-141 token uses fewer decimals than the native token.
Blocks, chunks and shards
A block response contains a header and a chunks array. Each chunk entry gives you a shard_id, gas_used, gas_limit and height_included. To read the transactions in a block, call chunk once per entry:
const block = await rpc("block", { finality: "final" });
let txCount = 0;
for (const c of block.chunks) {
const chunk = await rpc("chunk", {
block_id: block.header.height,
shard_id: c.shard_id,
});
txCount += chunk.transactions.length;
}
Two details matter:
- Shard IDs are not
0..n-1. The sampled block had ten chunks with IDs1, 4, 6, 7, 8, 9, 10, 11, 12, 13. Callingchunkwithshard_id: 0returnedINVALID_SHARD_ID, "Shard id 0 does not exist". Always take the IDs fromblock.chunks. - The header timestamp is nanoseconds.
header.timestampis a JSON number around1.796e18, which is past JavaScript's safe integer range, so the last digits are lost.header.timestamp_nanosecis the same value as a string and keeps full precision. Use it for ordering and gap detection, and convert withNumber(timestamp_nanosec) / 1e6for milliseconds.
The sampled block carried 16 transactions across its ten shards and used 195.57 TGas of a 10,000 TGas aggregate limit, about 1.96%. NEAR is not congested at the base gas price; empty blocks are normal.
Fees and what a transaction costs
gas_price returned 100000000 in every sampled block, and the block header carries the same value. That is 100,000,000 yoctoNEAR per unit of gas:
- 1 TGas (10^12 gas) = 0.0001 NEAR.
- 1 PGas (10^15 gas), the per-shard block limit, = 0.1 NEAR.
- A full ten-shard block at the limit would cost about 1 NEAR at the minimum gas price.
A sampled transaction with five FunctionCall actions to aggregate-oracle.near burnt 1.4088 TGas in its transaction outcome and 40.25 TGas across its receipts, about 41.66 TGas or 0.00417 NEAR in total. Most of the cost was in the receipts, not the outer transaction. When you estimate cost, include both. In a scan of four recent blocks, the transactions were contract calls; we did not find a single-action native transfer to compare against.
The fee is charged in NEAR, and the protocol burns it; there is no separate priority-fee market in the EVM sense. gas_price is the number to read. If a contract call runs out of gas, the error surfaces in tx status and in the receipt outcome, not as an HTTP failure on submission.
Finality: optimistic, near-final, final
block accepts three finality values: optimistic, near-final and final. Anything else fails with a parse error that lists the accepted set. In a snapshot taken from one node, final was 2 blocks and 1.115 seconds behind optimistic, and near-final was about one block behind.
That lines up with NEAR's published finality of roughly 1.2 seconds. A block that is final is settled; a block at optimistic can still be reorged. If you credit deposits, read the block with finality: "final" and check the block hash, not just the height.
One measured caveat: through a load-balanced route, the three tags can appear out of order because consecutive requests may land on different upstreams with slightly different heads. We saw near-final return a height three blocks above an optimistic response fetched 1.3 seconds earlier. If you are testing finality behaviour, pin the requests to a single endpoint, or compare the block timestamps instead of the heights.
History: about 34 hours, plus genesis
The status response reports earliest_block_height. At measurement time it was 227,418,737, timestamped 2026-12-03T21:30:04Z, against a head of 227,629,466 at 2026-12-05T07:24:53Z. That is about 34 hours of blocks.
Older heights do not silently return the earliest block. They fail:
{"name":"HANDLER_ERROR","cause":{"name":"UNKNOWN_BLOCK"},
"code":-32000,"message":"Server error"}
The HTTP status for that response was 422. Heights 220,000,000 and 150,000,000 both returned UNKNOWN_BLOCK. The genesis block at 9,820,210 still returns a valid header, because nodes retain it, but everything between genesis and the current window is unavailable.
client_config confirms the node is not an archive: archive: false, with garbage collection set to keep five epochs. If you need NEAR history beyond a day and a half, run an archive node or use an indexer. A backfill against this route will fail with UNKNOWN_BLOCK as soon as it reaches the edge of the window.
Reading a transaction and its receipts
tx takes the transaction hash and the signer account, and can wait for a status:
const { result } = await rpc("tx", {
tx_hash: "43MT24vej3p3rhw48az8AiqvU2bmqprPqD6AMxe5Pe2p",
sender_account_id: "167752be6e0a3e2a325ff3fe3dcf1b5d1c4fb1d80467eee19eeac995bd999b74",
wait_until: "EXECUTED_OPTIMISTIC",
});
The response includes final_execution_status, the transaction, transaction_outcome and receipts_outcome. For the sampled transaction, final_execution_status was FINAL, the status object was SuccessValue, and the receipt outcomes carried the gas and logs. Key indexers on (block_hash, transaction_hash) and store the receipt IDs; a cross-contract call can produce several receipts whose outcomes arrive in a later block.
For bulk changes, EXPERIMENTAL_changes with changes_type: "account_changes" returned data, and block_effects returned the block hash plus a changes array. Both are useful for indexers that want state changes rather than raw transactions, but they are experimental and can change between nearcore releases.
Errors: read the body, not just the status
NEAR uses HTTP status codes that a JSON-RPC client may not expect:
| Failure | HTTP | JSON-RPC code | Example cause |
|---|---|---|---|
| Unknown method | 400 | -32601 | eth_blockNumber, view_account |
| Malformed params | 400 | -32700 | array params, string block_id, batch array |
Unknown block (block) |
422 | -32000 | height outside the 34-hour window |
Unknown account (query) |
200 | -32000 | definitely-not-a-real-account-zzz.near |
State too large (query) |
200 | -32000 | view_state on wrap.near |
The split matters. block uses 422 for an unknown height, but query returns HTTP 200 with the failure in the top-level error object. A client that only checks res.ok will treat a missing account as a successful call. Parse the body every time.
The body carries a name, a cause.name and a data string. Log the cause.name rather than the HTTP status; UNKNOWN_BLOCK and UNKNOWN_ACCOUNT share -32000 and only the cause tells them apart.
Also note that query returns a 200 with an error field inside the result for some conditions, such as a missing access key:
{"result":{"block_height":227629626,
"error":"access key ed25519:... does not exist while viewing","logs":[]}}
Check result.error before you read result.amount or result.keys.
What NEAR does not have
There is no eth_getLogs, eth_call or eth_getProof. Logs from a contract call live in the receipt outcome's logs field, so indexers read tx receipts and chunk transactions instead of querying a log filter. eth_* compatibility belongs to Aurora, which runs its own EVM on top of NEAR; it is not part of this endpoint.
What breaks first
- Array params. Port an EVM client and the first call fails with
BlockId. Send named objects. view_accountfrom an old tutorial. It returnsMETHOD_NOT_FOUND. Usequery.- 18-decimal math. NEAR has 24. Format from the integer string; do not divide by
1e18. shard_id: 0. Take shard IDs fromblock.chunks; they are not contiguous.Date.parse(header.timestamp). The field is nanoseconds as a number and loses precision. Usetimestamp_nanosec.- A backfill deeper than a day and a half. It will stop at
UNKNOWN_BLOCK. - Batch requests. They are not supported; one request per call.
None of these are exotic. They are the normal shape of a non-EVM chain, and each one produces a clear error once you know which layer to check.
If you also work on the EVM side of NEAR, Aurora has its own RPC surface and a separate developer guide. For halt detection and freshness checks that apply across both, see why a liveness check is not a freshness check and how old the finalized tag is on 62 chains.
The NEAR endpoint is available on the NEAR RPC page and on the free tier with one key for every chain we serve.
Frequently asked questions
- What is the NEAR RPC endpoint?
- https://rpc.swiftnodes.io/rpc/near?key=YOUR_API_KEY over HTTP. SwiftNodes does not expose a NEAR WebSocket endpoint; the chain only has HTTP JSON-RPC on our route. The official public endpoint is https://rpc.mainnet.near.org, and the network identifier is chain_id "mainnet".
- Does the NEAR RPC support eth_* methods?
- No. NEAR is not an EVM chain, and eth_blockNumber through our endpoint returns JSON-RPC error -32601 Method not found with cause METHOD_NOT_FOUND. Aurora is a separate EVM environment built on NEAR and has its own endpoint; use /aurora-rpc for eth_* calls.
- Why does view_account return Method not found on NEAR?
- The standalone view_account, view_access_key, view_access_key_list, view_code and view_state methods are no longer served by current nearcore releases. On protocol 88 the node answered all of them with -32601. Use the query method with request_type set to view_account, view_access_key, view_access_key_list, view_code, view_state or call_function instead.
- Why does block return 'data did not match any variant of untagged enum BlockId'?
- You sent positional params or a string block height. NEAR expects named params such as {"block_id":227629278} and block_id must be an integer or a 32-byte base58 block hash. A JSON array of params, or the string "227629278", produces parse error -32700.
- What is NEAR's block time and finality lag?
- Over 59 consecutive blocks the mean interval was 0.554 s (median 0.560 s, range 0.402-0.686 s). In a single snapshot the final tag was 2 blocks and 1.115 s behind the optimistic head; near-final was about 1 block behind. Treat a final block as settled about 1.1 s after it appears.
- How far back can I read NEAR blocks through SwiftNodes?
- About 34 hours. When we measured, the earliest available block was 227,418,737 at 2026-12-03T21:30:04Z against a head of 227,629,466 at 2026-12-05T07:24:53Z. The node reports client_config.archive=false, and older heights return HTTP 422 UNKNOWN_BLOCK. The genesis block at height 9,820,210 is still served, but heights between genesis and the retention window are not.
- How many decimals does NEAR have?
- 24. One NEAR is 10^24 yoctoNEAR, and all balances in RPC responses are integer strings in yoctoNEAR. Dividing by 1e18, as you would for an 18-decimal EVM token, understates a NEAR balance by a factor of one million.
- Does NEAR JSON-RPC support batch requests?
- No. A JSON array of requests returned HTTP 400 with parse error -32700, 'JSON RPC Request format was expected'. Send one request per HTTP call; a batch wrapper will fail before any method runs.
- How much does a NEAR transaction cost?
- The gas price was 100,000,000 yoctoNEAR per gas in every block we sampled, so 1 TGas costs 0.0001 NEAR. A sampled five-action contract call burnt 1.4088 TGas in the transaction outcome and 40.25 TGas across its receipts, about 0.00417 NEAR in total. Simple transfers cost far less.
John Sullivan covers RPC infrastructure, node operations, and multi-chain development at SwiftNodes — what it actually takes to keep endpoints fast, fresh, and reliable across EVM and non-EVM networks.
Related posts
- Aurora RPC: A Developer's Guide (EVM on NEAR)
Aurora is an EVM running as a contract on NEAR. Measured: 0.6 s blocks, instant finality, a 2^53 gas limit, zero cumulativeGasUsed, NEAR receipt hashes.
- RPC endpoint health check: freshness, not liveness
An RPC endpoint health check that measures freshness, not liveness: three signals, the threshold arithmetic, and a runnable check you can put in your loop.
- Heartbeats and Zombie Connections
A heartbeat keeps a quiet WebSocket open. It does not prove the peer is reading. How to spot a zombie connection and size an interval against the timeout.