Chainbase OpenAPI Skill 用于通过 uxc 与 OpenAPI 架构执行 Chainbase 索引化数据操作,复用 uxc 的统一执行、认证与错误处理方式。
用途:该技能提供以读优先的索引化数据查询能力,覆盖账户原生余额查询、账户代币余额、账户交易历史、代币元数据、代币持有者读取、代币价格查询和交易详情查询。它明确不覆盖原始链 RPC 方法、写入或交易提交流程,也不覆盖所选 Web3 API 读取之外的更广泛 Chainbase 数据产品面。
前提条件:uxc 已安装并位于 PATH 中;能够访问 https://api.chainbase.online;可访问精选 OpenAPI 架构 URL:https://raw.githubusercontent.com/holon-run/uxc/main/skills/chainbase-openapi-skill/references/chainbase-web3.openapi.json;拥有 Chainbase API 密钥。
认证方式:Chainbase 使用 X-API-KEY 请求头认证。需配置一个 API 密钥凭据并绑定到 api.chainbase.online,命令为:
uxc auth credential set chainbase
--auth-type api_key
--api-key-header X-API-KEY
--secret-env CHAINBASE_API_KEY
uxc auth binding add
--id chainbase
--host api.chainbase.online
--scheme https
--credential chainbase
--priority 100
认证异常时可用 uxc auth binding match https://api.chainbase.online 校验当前映射。
使用方式:默认使用固定链接命令 command -v chainbase-openapi-cli;若缺失则通过 uxc link chainbase-openapi-cli https://api.chainbase.online --schema-url https://raw.githubusercontent.com/holon-run/uxc/main/skills/chainbase-openapi-skill/references/chainbase-web3.openapi.json 创建,并用 chainbase-openapi-cli -h 查看帮助。建议先检查操作架构,如 chainbase-openapi-cli get:/v1/account/balance -h、get:/v1/account/tokens -h、get:/v1/token/metadata -h。建议先用窄范围账户校验再扩大读取,例如: chainbase-openapi-cli get:/v1/account/balance chain_id=1 address=0xd8da6bf26964af9d7eed9e03e53415d37aa96045 chainbase-openapi-cli get:/v1/token/price chain_id=1 contract_address=0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48 chainbase-openapi-cli get:/v1/tx/detail chain_id=1 tx_hash=0x4e3f3bc239f496f59c3e4d4a4d5f10f7f0d6d9f4cd790beeb520d05f6f7d98ae 执行时使用键值参数,例如: chainbase-openapi-cli get:/v1/account/tokens chain_id=1 address=0xd8da6bf26964af9d7eed9e03e53415d37aa96045 page=1 limit=20 chainbase-openapi-cli get:/v1/token/holders chain_id=1 contract_address=0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48 page=1 limit=20
操作分组:账户读取包括 get:/v1/account/balance、get:/v1/account/tokens、get:/v1/account/txs;代币与交易读取包括 get:/v1/token/metadata、get:/v1/token/holders、get:/v1/token/price、get:/v1/tx/detail。
限制与防护:自动化应保持 JSON 输出封装,不使用 --text;优先解析稳定字段 ok、kind、protocol、data、error;该 v1 技能视为只读,不应暗示支持 RPC 写入方法、mempool 发送或签名;该技能有意限定在 https://api.chainbase.online 的索引化 HTTP 读取;构建大规模抓取前先使用较小的 page 和 limit 值。chainbase-openapi-cli <operation> ... 等价于 uxc https://api.chainbase.online --schema-url <chainbase_openapi_schema> <operation> ...。
参考:使用模式见 references/usage-patterns.md;精选 OpenAPI 架构见 references/chainbase-web3.openapi.json;Chainbase 认证文档见 https://docs.chainbase.com/quickstart/authenticate-your-api-key;Web3 API 文档见 https://docs.chainbase.com/api-reference/web3-api/balance。