Chainbase Web3 API Skill
Use this skill to run Chainbase indexed data operations through uxc + OpenAPI.
Reuse the uxc skill for shared execution, auth, and error-handling guidance.
Prerequisites
- -
uxc is installed and available in PATH. - Network access to
https://api.chainbase.online. - Access to the curated OpenAPI schema URL:
-
https://raw.githubusercontent.com/holon-run/uxc/main/skills/chainbase-openapi-skill/references/chainbase-web3.openapi.json
Scope
This skill covers a read-first indexed data surface:
- - account native balance lookup
- account token balances
- account transaction history
- token metadata
- token holder reads
- token price lookup
- transaction detail lookup
This skill does not cover:
- - raw chain RPC methods
- write or transaction submission flows
- the broader Chainbase data product surface beyond the selected Web3 API reads
Authentication
Chainbase uses X-API-KEY header auth.
Configure one API-key credential and bind it to api.chainbase.online:
CODEBLOCK0
Validate the active mapping when auth looks wrong:
CODEBLOCK1
Core Workflow
- 1. Use the fixed link command by default:
-
command -v chainbase-openapi-cli
- If missing, create it:
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
- INLINECODE10
- 2. Inspect operation schema first:
-
chainbase-openapi-cli get:/v1/account/balance -h
-
chainbase-openapi-cli get:/v1/account/tokens -h
- INLINECODE13
- 3. Prefer narrow account validation before broader reads:
-
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
- INLINECODE16
- 4. Execute with key/value parameters:
-
chainbase-openapi-cli get:/v1/account/tokens chain_id=1 address=0xd8da6bf26964af9d7eed9e03e53415d37aa96045 page=1 limit=20
- INLINECODE18
Operation Groups
Account Reads
- - INLINECODE19
- INLINECODE20
- INLINECODE21
Token And Transaction Reads
- - INLINECODE22
- INLINECODE23
- INLINECODE24
- INLINECODE25
Guardrails
- - Keep automation on the JSON output envelope; do not use
--text. - Parse stable fields first:
ok, kind, protocol, data, error. - Treat this v1 skill as read-only. Do not imply RPC write methods, mempool send, or signing support.
- Chainbase has multiple product surfaces. This skill is intentionally limited to indexed HTTP reads on
https://api.chainbase.online. - Start with small
page and limit values before building large crawls. - INLINECODE35 is equivalent to
uxc https://api.chainbase.online --schema-url <chainbase_openapi_schema> <operation> ....
References
- - Usage patterns: INLINECODE37
- Curated OpenAPI schema: INLINECODE38
- Chainbase auth docs: https://docs.chainbase.com/quickstart/authenticate-your-api-key
- Chainbase Web3 API docs: https://docs.chainbase.com/api-reference/web3-api/balance
Chainbase Web3 API 技能
通过 uxc + OpenAPI 使用此技能运行 Chainbase 索引数据操作。
复用 uxc 技能以获取共享执行、认证和错误处理指导。
前置条件
- - 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
范围
此技能涵盖以读取为主的索引数据接口:
- - 账户原生余额查询
- 账户代币余额
- 账户交易历史
- 代币元数据
- 代币持有者查询
- 代币价格查询
- 交易详情查询
此技能不涵盖:
- - 原始链 RPC 方法
- 写入或交易提交流程
- 除选定 Web3 API 读取之外的更广泛 Chainbase 数据产品范围
认证
Chainbase 使用 X-API-KEY 头部认证。
配置一个 API 密钥凭证并将其绑定到 api.chainbase.online:
bash
uxc auth credential set chainbase \
--auth-type api_key \
--api-key-header X-API-KEY \
--secret-env CHAINBASEAPIKEY
uxc auth binding add \
--id chainbase \
--host api.chainbase.online \
--scheme https \
--credential chainbase \
--priority 100
当认证出现问题时,验证当前映射:
bash
uxc auth binding match https://api.chainbase.online
核心工作流程
- 1. 默认使用固定链接命令:
- 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
- 2. 首先检查操作模式:
- chainbase-openapi-cli get:/v1/account/balance -h
- chainbase-openapi-cli get:/v1/account/tokens -h
- chainbase-openapi-cli get:/v1/token/metadata -h
- 3. 在进行广泛读取前,优先进行窄范围账户验证:
- chainbase-openapi-cli get:/v1/account/balance chain_id=1 address=0xd8da6bf26964af9d7eed9e03e53415d37aa96045
- chainbase-openapi-cli get:/v1/token/price chain
id=1 contractaddress=0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48
- chainbase-openapi-cli get:/v1/tx/detail chain
id=1 txhash=0x4e3f3bc239f496f59c3e4d4a4d5f10f7f0d6d9f4cd790beeb520d05f6f7d98ae
- 4. 使用键/值参数执行:
- 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 contractaddress=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 写入方法、内存池发送或签名功能。
- Chainbase 拥有多个产品接口。此技能有意限制为 https://api.chainbase.online 上的索引 HTTP 读取。
- 在构建大规模爬取前,先使用较小的 page 和 limit 值。
- chainbase-openapi-cli <操作> ... 等同于 uxc https://api.chainbase.online --schema-url openapischema> <操作> ...。
参考资料
- - 使用模式:references/usage-patterns.md
- 精选 OpenAPI 模式:references/chainbase-web3.openapi.json
- Chainbase 认证文档:https://docs.chainbase.com/quickstart/authenticate-your-api-key
- Chainbase Web3 API 文档:https://docs.chainbase.com/api-reference/web3-api/balance