ethereum-jsonrpc-skill
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseEthereum JSON-RPC Skill
Ethereum JSON-RPC 技能
Use this skill to run Ethereum execution JSON-RPC operations through + JSON-RPC.
uxcReuse the skill for shared execution, auth, and error-handling guidance.
uxc使用本技能可通过 + JSON-RPC执行以太坊执行层JSON-RPC操作。
uxc复用技能以获取通用执行、认证及错误处理指引。
uxcPrerequisites
前置条件
- is installed and available in
uxc.PATH - Network access to a compatible Ethereum execution JSON-RPC provider.
- Access to the official execution OpenRPC schema URL:
https://raw.githubusercontent.com/ethereum/execution-apis/assembled-spec/refs-openrpc.json
- 已安装且其可在
uxc中访问。PATH - 可访问兼容的以太坊执行层JSON-RPC服务提供商网络。
- 可访问官方执行层OpenRPC schema的URL:
https://raw.githubusercontent.com/ethereum/execution-apis/assembled-spec/refs-openrpc.json
Scope
适用范围
This skill covers a safe read-first Ethereum execution surface:
- chain identity and public state reads
- block, balance, logs, and call-based state reads
- pubsub subscriptions for new heads, logs, and pending transactions
eth_subscribe
This skill does not cover:
eth_sendRawTransaction- ,
personal_*,admin_*,debug_*,engine_*txpool_* - wallet signing flows
- private/authenticated RPC providers with custom auth models
本技能覆盖以太坊执行层中以读取操作为主的安全操作范围:
- 链标识与公共状态读取
- 区块、余额、日志及基于调用的状态读取
- 通过发布订阅机制获取新区块头、日志及待处理交易
eth_subscribe
本技能不包含以下内容:
eth_sendRawTransaction- 、
personal_*、admin_*、debug_*、engine_*系列方法txpool_* - 钱包签名流程
- 采用自定义认证模型的私有/需认证RPC服务提供商
Endpoint And Schema
端点与Schema
This skill defaults to a public read provider:
- HTTPS RPC:
https://ethereum-rpc.publicnode.com
The operation surface comes from the official Ethereum execution OpenRPC schema:
https://raw.githubusercontent.com/ethereum/execution-apis/assembled-spec/refs-openrpc.json
uxcrpc.discover--schema-urlThe official execution OpenRPC document is strong enough for normal request/response methods, but it does not currently expose pubsub methods such as . Use the schema-backed link for reads, and use directly for subscriptions.
eth_subscribeuxc subscribe startFor subscriptions, use a WebSocket Ethereum RPC provider that you have verified actually accepts . Do not assume a public HTTPS host automatically guarantees the same host is stable for pubsub.
eth_subscribewss://本技能默认使用公共读取服务提供商:
- HTTPS RPC:
https://ethereum-rpc.publicnode.com
操作范围源自官方以太坊执行层OpenRPC schema:
https://raw.githubusercontent.com/ethereum/execution-apis/assembled-spec/refs-openrpc.json
uxcrpc.discover--schema-url官方执行层OpenRPC文档足以支持常规请求/响应方法,但目前未包含等发布订阅方法。读取操作使用基于schema的链接,订阅操作则直接使用。
eth_subscribeuxc subscribe start订阅操作需使用已验证支持的WebSocket以太坊RPC服务提供商。请勿假设公共HTTPS主机对应的主机一定能稳定支持发布订阅功能。
eth_subscribewss://Authentication
认证
The default public read provider used by this skill does not require authentication.
If a user later points the same workflow at a private Ethereum RPC provider, verify its auth model first before reusing this skill unchanged.
本技能使用的默认公共读取服务提供商无需认证。
若用户后续将同一工作流指向私有以太坊RPC服务提供商,需先验证其认证模型,再复用本技能。
Core Workflow
核心工作流
-
Use the fixed link command by default:
command -v ethereum-jsonrpc-cli- If missing, create it:
uxc link ethereum-jsonrpc-cli https://ethereum-rpc.publicnode.com --schema-url https://raw.githubusercontent.com/ethereum/execution-apis/assembled-spec/refs-openrpc.json ethereum-jsonrpc-cli -h
-
Inspect operation schema first:
ethereum-jsonrpc-cli eth_blockNumber -hethereum-jsonrpc-cli eth_getBlockByNumber -hethereum-jsonrpc-cli eth_getBalance -h
-
Prefer chain and balance/block reads before deeper state queries:
ethereum-jsonrpc-cli eth_chainIdethereum-jsonrpc-cli eth_blockNumberethereum-jsonrpc-cli eth_getBalance Address=0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045 Block=latest
-
Execute with key/value or positional JSON:
- key/value:
ethereum-jsonrpc-cli eth_getBalance Address=0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045 Block=latest - positional JSON:
ethereum-jsonrpc-cli eth_getBlockByNumber '["latest", false]' - nested positional JSON:
ethereum-jsonrpc-cli eth_call '[{"to":"0xA0b86991c6218b36c1d19d4a2e9eb0ce3606eb48","data":"0x313ce567"},"latest"]'
- key/value:
-
Usedirectly for pubsub streams:
uxc subscribe startuxc subscribe start wss://<verified-ethereum-rpc-host> eth_subscribe '{"params":["newHeads"]}' --sink file:$HOME/.uxc/subscriptions/eth-new-heads.ndjsonuxc subscribe start wss://<verified-ethereum-rpc-host> eth_subscribe '{"params":["logs",{"address":"0xA0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"}]}' --sink file:$HOME/.uxc/subscriptions/eth-logs.ndjsonuxc subscribe status <job_id>uxc subscribe stop <job_id>
-
默认使用固定链接命令:
command -v ethereum-jsonrpc-cli- 若不存在则创建:
uxc link ethereum-jsonrpc-cli https://ethereum-rpc.publicnode.com --schema-url https://raw.githubusercontent.com/ethereum/execution-apis/assembled-spec/refs-openrpc.json ethereum-jsonrpc-cli -h
-
先查看操作schema:
ethereum-jsonrpc-cli eth_blockNumber -hethereum-jsonrpc-cli eth_getBlockByNumber -hethereum-jsonrpc-cli eth_getBalance -h
-
在进行深层状态查询前,优先执行链信息、余额/区块读取操作:
ethereum-jsonrpc-cli eth_chainIdethereum-jsonrpc-cli eth_blockNumberethereum-jsonrpc-cli eth_getBalance Address=0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045 Block=latest
-
使用键值对或位置JSON格式执行操作:
- 键值对格式:
ethereum-jsonrpc-cli eth_getBalance Address=0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045 Block=latest - 位置JSON格式:
ethereum-jsonrpc-cli eth_getBlockByNumber '["latest", false]' - 嵌套位置JSON格式:
ethereum-jsonrpc-cli eth_call '[{"to":"0xA0b86991c6218b36c1d19d4a2e9eb0ce3606eb48","data":"0x313ce567"},"latest"]'
- 键值对格式:
-
直接使用处理发布订阅流:
uxc subscribe startuxc subscribe start wss://<verified-ethereum-rpc-host> eth_subscribe '{"params":["newHeads"]}' --sink file:$HOME/.uxc/subscriptions/eth-new-heads.ndjsonuxc subscribe start wss://<verified-ethereum-rpc-host> eth_subscribe '{"params":["logs",{"address":"0xA0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"}]}' --sink file:$HOME/.uxc/subscriptions/eth-logs.ndjsonuxc subscribe status <job_id>uxc subscribe stop <job_id>
Recommended Read Operations
推荐读取操作
net_versioneth_chainIdeth_blockNumbereth_getBlockByNumbereth_getBalanceeth_getLogseth_call
net_versioneth_chainIdeth_blockNumbereth_getBlockByNumbereth_getBalanceeth_getLogseth_call
Recommended Subscription Operations
推荐订阅操作
eth_subscribe
Subscription modes that are usually most useful:
params[0]newHeadslogsnewPendingTransactions
eth_subscribe
订阅中最常用的模式:
params[0]newHeadslogsnewPendingTransactions
Guardrails
防护机制
- Keep automation on the JSON output envelope; do not use .
--text - Parse stable fields first: ,
ok,kind,protocol,data.error - Stay on read-only methods and by default.
eth_subscribe - The official execution OpenRPC schema drives read help and request execution, but it does not cover ; treat subscriptions as runtime-only flows, not schema-discovered operations.
eth_subscribe - Do not call write/admin/debug/engine methods through this skill without explicit follow-up design and review.
- Use for pubsub methods; the fixed
uxc subscribe startlink is for normal request/response methods.ethereum-jsonrpc-cli - Subscription jobs should always write to a sink file so events can be inspected and replayed safely.
- Before documenting or automating a public Ethereum pubsub host, confirm the specific provider actually exposes WebSocket JSON-RPC subscriptions; public HTTPS endpoints do not guarantee a matching endpoint.
wss:// - is equivalent to
ethereum-jsonrpc-cli <operation> ....uxc https://ethereum-rpc.publicnode.com --schema-url <ethereum_execution_openrpc_schema> <operation> ...
- 自动化操作基于JSON输出格式;请勿使用参数。
--text - 优先解析稳定字段:、
ok、kind、protocol、data。error - 默认仅使用只读方法及。
eth_subscribe - 官方执行层OpenRPC schema支持读取操作的帮助信息及请求执行,但不包含;订阅操作视为仅运行时流程,而非通过schema发现的操作。
eth_subscribe - 未经明确的后续设计与审核,请勿通过本技能调用写入/管理/调试/引擎类方法。
- 发布订阅方法使用;固定的
uxc subscribe start链接用于常规请求/响应方法。ethereum-jsonrpc-cli - 订阅任务应始终写入到输出文件,以便安全地检查和重放事件。
- 在记录或自动化公共以太坊发布订阅主机前,需确认该服务提供商确实支持WebSocket JSON-RPC订阅;公共HTTPS端点不保证对应的端点可用。
wss:// - 等价于
ethereum-jsonrpc-cli <operation> ...。uxc https://ethereum-rpc.publicnode.com --schema-url <ethereum_execution_openrpc_schema> <operation> ...
References
参考资料
- Usage patterns:
references/usage-patterns.md - Ethereum execution API specs: https://github.com/ethereum/execution-apis
- Ethereum JSON-RPC overview: https://ethereum.org/developers/docs/apis/json-rpc/
- 使用模式:
references/usage-patterns.md - 以太坊执行层API规范:https://github.com/ethereum/execution-apis
- 以太坊JSON-RPC概述:https://ethereum.org/developers/docs/apis/json-rpc/