near-jsonrpc-skill

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

NEAR JSON-RPC Skill

NEAR JSON-RPC Skill

Use this skill to run NEAR JSON-RPC operations through
uxc
+ JSON-RPC.
Reuse the
uxc
skill for shared execution and error-handling guidance.
使用本技能通过
uxc
+ JSON-RPC执行NEAR JSON-RPC操作。
复用
uxc
技能以获得共享执行逻辑和错误处理指引。

Prerequisites

前提条件

  • uxc
    is installed and available in
    PATH
    .
  • Network access to a working NEAR RPC provider.
  • This skill defaults to
    https://free.rpc.fastnear.com
    , which is listed on the official NEAR RPC providers page.
  • Access to the curated NEAR OpenRPC schema URL:
    • https://raw.githubusercontent.com/holon-run/uxc/main/skills/near-jsonrpc-skill/references/near-public.openrpc.json
  • 已安装
    uxc
    且其路径已添加至
    PATH
    环境变量。
  • 能够访问可用的NEAR RPC提供商网络。
  • 本技能默认使用
    https://free.rpc.fastnear.com
    ,该提供商已列入NEAR官方RPC提供商页面。
  • 能够访问经过整理的NEAR OpenRPC schema URL:
    • https://raw.githubusercontent.com/holon-run/uxc/main/skills/near-jsonrpc-skill/references/near-public.openrpc.json

Scope

适用范围

This skill covers a safe read-first NEAR RPC surface:
  • chain status
  • account state query
  • finalized block lookup
  • chunk lookup by chunk hash
  • gas price lookup
  • validator set lookup
This skill does not cover:
  • transaction submission methods
  • signing or wallet flows
  • archival assumptions for very old blocks or chunks
  • deprecated
    near.org
    or
    pagoda.co
    public RPC endpoints
本技能覆盖NEAR RPC的安全只读操作范围:
  • 链状态查询
  • 账户状态查询
  • 最终区块查询
  • 按区块哈希查询chunk
  • 燃气价格查询
  • 验证者集合查询
本技能包含以下内容:
  • 交易提交方法
  • 签名或钱包流程
  • 对极旧区块或chunk的归档查询
  • 已废弃的
    near.org
    pagoda.co
    公共RPC端点

Endpoint And Schema

端点与Schema

This skill uses the public FastNear mainnet RPC by default:
  • https://free.rpc.fastnear.com
The operation surface comes from the curated NEAR OpenRPC schema in this repo:
  • https://raw.githubusercontent.com/holon-run/uxc/main/skills/near-jsonrpc-skill/references/near-public.openrpc.json
uxc
JSON-RPC discovery depends on OpenRPC or
rpc.discover
. FastNear does not expose a discoverable method surface that UXC can consume directly, so this skill uses a fixed
--schema-url
link and request flow.
The official NEAR docs now treat
near.org
and
pagoda.co
RPC endpoints as deprecated. Do not use those old hosts as the default for new automation.
If the user already has a preferred provider from the official NEAR providers page, relink the same command to that provider instead of reusing the deprecated endpoints.
本技能默认使用FastNear公共主网RPC:
  • https://free.rpc.fastnear.com
操作范围来自本仓库中经过整理的NEAR OpenRPC schema:
  • https://raw.githubusercontent.com/holon-run/uxc/main/skills/near-jsonrpc-skill/references/near-public.openrpc.json
uxc
的JSON-RPC发现依赖于OpenRPC或
rpc.discover
。FastNear未暴露UXC可直接使用的可发现方法接口,因此本技能使用固定的
--schema-url
链接和请求流程。
NEAR官方文档现已将
near.org
pagoda.co
RPC端点标记为废弃。请勿将这些旧主机作为新自动化流程的默认选择。
如果用户已从NEAR官方提供商页面选定了偏好的提供商,请重新关联命令至该提供商,而非复用已废弃的端点。

Authentication

认证

The default FastNear public RPC used by this skill does not require authentication.
If the user switches to a private NEAR provider, verify its auth model before reusing this skill unchanged.
本技能使用的默认FastNear公共RPC无需认证。
如果用户切换至私有NEAR提供商,在未修改本技能的情况下复用前,请确认其认证模型。

Core Workflow

核心工作流程

  1. Use the fixed link command by default:
    • command -v near-jsonrpc-cli
    • If missing, create it:
      uxc link near-jsonrpc-cli https://free.rpc.fastnear.com --schema-url https://raw.githubusercontent.com/holon-run/uxc/main/skills/near-jsonrpc-skill/references/near-public.openrpc.json
    • near-jsonrpc-cli -h
  2. Inspect operation help first, then run known read methods:
    • near-jsonrpc-cli -h
    • near-jsonrpc-cli query -h
    • near-jsonrpc-cli gas_price -h
    • near-jsonrpc-cli status
    • near-jsonrpc-cli gas_price --input-json '{"block_id":null}'
  3. Prefer narrow validation before deeper queries:
    • near-jsonrpc-cli status
    • near-jsonrpc-cli block '{"finality":"final"}'
    • near-jsonrpc-cli query '{"request_type":"view_account","finality":"final","account_id":"near"}'
  4. Use object JSON for request objects, and
    --input-json
    when a method expects positional null/default params:
    • object request:
      near-jsonrpc-cli chunk '{"chunk_id":"75cewvnKFLrJshoUft1tiUC9GriuxWTc4bWezjy2MoPR"}'
    • positional null/default encoded from an object payload:
      near-jsonrpc-cli gas_price --input-json '{"block_id":null}'
      near-jsonrpc-cli validators --input-json '{"epoch_reference":null}'
  1. 默认使用固定关联命令:
    • command -v near-jsonrpc-cli
    • 若该命令不存在,则创建:
      uxc link near-jsonrpc-cli https://free.rpc.fastnear.com --schema-url https://raw.githubusercontent.com/holon-run/uxc/main/skills/near-jsonrpc-skill/references/near-public.openrpc.json
    • near-jsonrpc-cli -h
  2. 先查看操作帮助,再运行已知的只读方法:
    • near-jsonrpc-cli -h
    • near-jsonrpc-cli query -h
    • near-jsonrpc-cli gas_price -h
    • near-jsonrpc-cli status
    • near-jsonrpc-cli gas_price --input-json '{"block_id":null}'
  3. 在执行深度查询前优先进行窄范围验证:
    • near-jsonrpc-cli status
    • near-jsonrpc-cli block '{"finality":"final"}'
    • near-jsonrpc-cli query '{"request_type":"view_account","finality":"final","account_id":"near"}'
  4. 请求对象使用JSON格式,当方法需要位置参数为null或默认值时,使用
    --input-json
    • 对象请求示例:
      near-jsonrpc-cli chunk '{"chunk_id":"75cewvnKFLrJshoUft1tiUC9GriuxWTc4bWezjy2MoPR"}'
    • 从对象负载编码位置参数为null/默认值的示例:
      near-jsonrpc-cli gas_price --input-json '{"block_id":null}'
      near-jsonrpc-cli validators --input-json '{"epoch_reference":null}'

Recommended Read Operations

推荐只读操作

  • status
  • query
  • block
  • chunk
  • gas_price
  • validators
  • status
  • query
  • block
  • chunk
  • gas_price
  • validators

Guardrails

防护机制

  • Keep automation on the JSON output envelope; do not use
    --text
    .
  • Parse stable fields first:
    ok
    ,
    kind
    ,
    protocol
    ,
    data
    ,
    error
    .
  • Stay on the read-only method surface by default.
  • The fixed schema is required because FastNear is not directly discoverable by UXC; do not drop
    --schema-url
    from the linked command unless the provider proves it exposes usable OpenRPC or
    rpc.discover
    .
  • Do not use this skill for transaction submission, signing, or wallet-authenticated flows.
  • The official NEAR docs mark the old
    near.org
    and
    pagoda.co
    public RPC endpoints as deprecated. Prefer providers from the official RPC providers page instead.
  • Public providers can differ in archival retention and rate limits. If
    chunk
    or older
    block
    lookups fail with unknown or garbage-collected errors, switch to a provider that explicitly supports the needed history.
  • For methods such as
    gas_price
    and
    validators
    that expect positional params, use
    --input-json '{"...":null}'
    instead of array payloads; UXC CLI positional JSON accepts objects, not arrays.
  • near-jsonrpc-cli <operation> ...
    is equivalent to
    uxc https://free.rpc.fastnear.com --schema-url <near_openrpc_schema> <operation> ...
    .
  • 自动化流程应使用JSON输出格式;请勿使用
    --text
    参数。
  • 优先解析稳定字段:
    ok
    kind
    protocol
    data
    error
  • 默认仅使用只读方法接口。
  • 由于FastNear无法被UXC直接发现,因此必须使用固定schema;除非提供商证明其暴露了可用的OpenRPC或
    rpc.discover
    接口,否则请勿从关联命令中移除
    --schema-url
    参数。
  • 请勿使用本技能进行交易提交、签名或钱包认证流程。
  • NEAR官方文档已将旧的
    near.org
    pagoda.co
    公共RPC端点标记为废弃。请优先选择官方RPC提供商页面中的提供商。
  • 不同公共提供商的归档保留时长和速率限制可能不同。如果
    chunk
    或旧
    block
    查询因未知或垃圾回收错误失败,请切换至明确支持所需历史数据的提供商。
  • 对于
    gas_price
    validators
    等需要位置参数的方法,请使用
    --input-json '{"...":null}'
    而非数组负载;UXC CLI的位置参数JSON仅接受对象,不接受数组。
  • near-jsonrpc-cli <operation> ...
    等价于
    uxc https://free.rpc.fastnear.com --schema-url <near_openrpc_schema> <operation> ...

References

参考资料