validation

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Validation Skill

Validation Skill

Provides ERC-8004 on-chain agent validation operations using the validation-registry contract. Read operations (get-status, get-summary, get-agent-validations, get-validator-requests) work without a wallet. Write operations (request, respond) require an unlocked wallet.
通过validation-registry合约提供ERC-8004链上Agent验证操作。读操作(get-status、get-summary、get-agent-validations、get-validator-requests)无需钱包即可使用。写操作(request、respond)需要解锁的钱包。

Usage

使用方法

bun run validation/validation.ts <subcommand> [options]
bun run validation/validation.ts <subcommand> [options]

Subcommands

子命令

request

发起验证请求

Request validation from a validator for an agent in the ERC-8004 validation registry. The request hash must be a 32-byte SHA-256 hash of the request data. Requires an unlocked wallet.
bun run validation/validation.ts request --validator <address> --agent-id <id> --request-uri <uri> --request-hash <hex> [--fee <fee>] [--sponsored]
Options:
  • --validator
    (required) — Stacks address of the validator to request validation from
  • --agent-id
    (required) — Agent ID to request validation for (non-negative integer)
  • --request-uri
    (required) — URI pointing to the validation request data
  • --request-hash
    (required) — 32-byte SHA-256 hash of the request data as a hex string
  • --fee
    (optional) — Fee preset (
    low
    ,
    medium
    ,
    high
    ) or micro-STX amount
  • --sponsored
    (flag) — Submit as a sponsored transaction
Output:
json
{
  "success": true,
  "txid": "0xabc...",
  "message": "Validation requested from SP2... for agent 42.",
  "validator": "SP2...",
  "agentId": 42,
  "requestUri": "ipfs://request...",
  "network": "mainnet",
  "explorerUrl": "https://explorer.hiro.so/txid/0xabc..."
}
向ERC-8004验证注册表中的验证者发起Agent验证请求。请求哈希必须是请求数据的32字节SHA-256哈希值。需要解锁的钱包。
bun run validation/validation.ts request --validator <address> --agent-id <id> --request-uri <uri> --request-hash <hex> [--fee <fee>] [--sponsored]
选项:
  • --validator
    (必填)—— 要请求验证的验证者的Stacks地址
  • --agent-id
    (必填)—— 要请求验证的Agent ID(非负整数)
  • --request-uri
    (必填)—— 指向验证请求数据的URI
  • --request-hash
    (必填)—— 请求数据的32字节SHA-256哈希值,以十六进制字符串形式提供
  • --fee
    (可选)—— 手续费预设(
    low
    medium
    high
    )或micro-STX金额
  • --sponsored
    (标志)—— 作为赞助交易提交
输出:
json
{
  "success": true,
  "txid": "0xabc...",
  "message": "Validation requested from SP2... for agent 42.",
  "validator": "SP2...",
  "agentId": 42,
  "requestUri": "ipfs://request...",
  "network": "mainnet",
  "explorerUrl": "https://explorer.hiro.so/txid/0xabc..."
}

respond

响应验证请求

Submit a validation response for a pending validation request. Only the validator specified in the original request can call this. Response must be an integer between 0 and 100. Can be called multiple times for progressive updates. Requires an unlocked wallet.
bun run validation/validation.ts respond --request-hash <hex> --response <value> --response-uri <uri> --response-hash <hex> [--tag <tag>] [--fee <fee>] [--sponsored]
Options:
  • --request-hash
    (required) — 32-byte SHA-256 hash of the original request as a hex string
  • --response
    (required) — Validation response score (integer between 0 and 100)
  • --response-uri
    (required) — URI pointing to the validation response data
  • --response-hash
    (required) — 32-byte SHA-256 hash of the response data as a hex string
  • --tag
    (optional) — Classification tag for the validation response
  • --fee
    (optional) — Fee preset (
    low
    ,
    medium
    ,
    high
    ) or micro-STX amount
  • --sponsored
    (flag) — Submit as a sponsored transaction
Output:
json
{
  "success": true,
  "txid": "0xdef...",
  "message": "Validation response 85 submitted for request hash a3f2b1....",
  "response": 85,
  "responseUri": "ipfs://response...",
  "tag": "security",
  "network": "mainnet",
  "explorerUrl": "https://explorer.hiro.so/txid/0xdef..."
}
为待处理的验证请求提交验证响应。仅原始请求中指定的验证者可调用此命令。响应必须是0到100之间的整数。可多次调用以进行渐进式更新。需要解锁的钱包。
bun run validation/validation.ts respond --request-hash <hex> --response <value> --response-uri <uri> --response-hash <hex> [--tag <tag>] [--fee <fee>] [--sponsored]
选项:
  • --request-hash
    (必填)—— 原始验证请求的32字节SHA-256哈希值,以十六进制字符串形式提供
  • --response
    (必填)—— 验证响应分数(0到100之间的整数)
  • --response-uri
    (必填)—— 指向验证响应数据的URI
  • --response-hash
    (必填)—— 响应数据的32字节SHA-256哈希值,以十六进制字符串形式提供
  • --tag
    (可选)—— 验证响应的分类标签
  • --fee
    (可选)—— 手续费预设(
    low
    medium
    high
    )或micro-STX金额
  • --sponsored
    (标志)—— 作为赞助交易提交
输出:
json
{
  "success": true,
  "txid": "0xdef...",
  "message": "Validation response 85 submitted for request hash a3f2b1....",
  "response": 85,
  "responseUri": "ipfs://response...",
  "tag": "security",
  "network": "mainnet",
  "explorerUrl": "https://explorer.hiro.so/txid/0xdef..."
}

get-status

查询验证状态

Get the status of a validation request by its 32-byte request hash. Returns validator, agent ID, response score, response hash, tag, last update block, and whether a response has been submitted. Does not require a wallet.
bun run validation/validation.ts get-status --request-hash <hex>
Options:
  • --request-hash
    (required) — 32-byte SHA-256 hash of the validation request as a hex string
Output:
json
{
  "success": true,
  "requestHash": "a3f2b1...64hex",
  "validator": "SP2...",
  "agentId": 42,
  "response": 85,
  "responseHash": "b4e9c2...64hex",
  "tag": "security",
  "lastUpdate": 123456,
  "hasResponse": true,
  "network": "mainnet"
}
通过32字节的请求哈希查询验证请求的状态。返回验证者、Agent ID、响应分数、响应哈希、标签、最后更新区块以及是否已提交响应。无需钱包。
bun run validation/validation.ts get-status --request-hash <hex>
选项:
  • --request-hash
    (必填)—— 验证请求的32字节SHA-256哈希值,以十六进制字符串形式提供
输出:
json
{
  "success": true,
  "requestHash": "a3f2b1...64hex",
  "validator": "SP2...",
  "agentId": 42,
  "response": 85,
  "responseHash": "b4e9c2...64hex",
  "tag": "security",
  "lastUpdate": 123456,
  "hasResponse": true,
  "network": "mainnet"
}

get-summary

查询验证汇总

Get the aggregated validation summary for an agent. Returns the total validation count and average response score. Does not require a wallet.
bun run validation/validation.ts get-summary --agent-id <id>
Options:
  • --agent-id
    (required) — Agent ID to query (non-negative integer)
Output:
json
{
  "success": true,
  "agentId": 42,
  "count": 3,
  "avgResponse": 88,
  "network": "mainnet"
}
获取某个Agent的聚合验证汇总信息。返回总验证次数和平均响应分数。无需钱包。
bun run validation/validation.ts get-summary --agent-id <id>
选项:
  • --agent-id
    (必填)—— 要查询的Agent ID(非负整数)
输出:
json
{
  "success": true,
  "agentId": 42,
  "count": 3,
  "avgResponse": 88,
  "network": "mainnet"
}

get-agent-validations

查询Agent的验证列表

Get a paginated list of validation request hashes for an agent. Returns request hashes as hex strings. Cursor-based pagination with page size 14. Does not require a wallet.
bun run validation/validation.ts get-agent-validations --agent-id <id> [--cursor <cursor>]
Options:
  • --agent-id
    (required) — Agent ID to query (non-negative integer)
  • --cursor
    (optional) — Pagination cursor (non-negative integer, from previous response)
Output:
json
{
  "success": true,
  "agentId": 42,
  "validations": ["a3f2b1...64hex", "c5d8e4...64hex"],
  "cursor": null,
  "network": "mainnet"
}
获取某个Agent的验证请求哈希分页列表。返回十六进制字符串格式的请求哈希。采用基于游标的分页,每页大小为14。无需钱包。
bun run validation/validation.ts get-agent-validations --agent-id <id> [--cursor <cursor>]
选项:
  • --agent-id
    (必填)—— 要查询的Agent ID(非负整数)
  • --cursor
    (可选)—— 分页游标(非负整数,来自上一次响应)
输出:
json
{
  "success": true,
  "agentId": 42,
  "validations": ["a3f2b1...64hex", "c5d8e4...64hex"],
  "cursor": null,
  "network": "mainnet"
}

get-validator-requests

查询验证者的请求列表

Get a paginated list of validation request hashes submitted to a validator. Returns request hashes as hex strings. Cursor-based pagination with page size 14. Does not require a wallet.
bun run validation/validation.ts get-validator-requests --validator <address> [--cursor <cursor>]
Options:
  • --validator
    (required) — Stacks address of the validator to query
  • --cursor
    (optional) — Pagination cursor (non-negative integer, from previous response)
Output:
json
{
  "success": true,
  "validator": "SP2...",
  "requests": ["a3f2b1...64hex", "c5d8e4...64hex"],
  "cursor": null,
  "network": "mainnet"
}
获取提交给某个验证者的验证请求哈希分页列表。返回十六进制字符串格式的请求哈希。采用基于游标的分页,每页大小为14。无需钱包。
bun run validation/validation.ts get-validator-requests --validator <address> [--cursor <cursor>]
选项:
  • --validator
    (必填)—— 要查询的验证者的Stacks地址
  • --cursor
    (可选)—— 分页游标(非负整数,来自上一次响应)
输出:
json
{
  "success": true,
  "validator": "SP2...",
  "requests": ["a3f2b1...64hex", "c5d8e4...64hex"],
  "cursor": null,
  "network": "mainnet"
}

Notes

注意事项

  • Read operations (get-status, get-summary, get-agent-validations, get-validator-requests) work without a wallet
  • Write operations require an unlocked wallet (
    bun run wallet/wallet.ts unlock
    )
  • --request-hash
    and
    --response-hash
    must be exactly 32 bytes (64 hex characters); use SHA-256
  • --response
    score must be an integer between 0 and 100 (inclusive)
  • respond
    can only be called by the validator specified in the original validation request
  • respond
    can be called multiple times on the same request for progressive updates
  • Pagination uses cursor-based navigation; pass the
    cursor
    from one response into the next call
  • Validation is a Stacks L2 operation — check transaction status with
    stx get-transaction-status
    after write calls
  • 读操作(get-status、get-summary、get-agent-validations、get-validator-requests)无需钱包即可使用
  • 写操作需要解锁的钱包(执行
    bun run wallet/wallet.ts unlock
  • --request-hash
    --response-hash
    必须恰好为32字节(64个十六进制字符);使用SHA-256生成
  • --response
    分数必须是0到100之间的整数(包含边界值)
  • respond
    只能由原始验证请求中指定的验证者调用
  • 可以对同一请求多次调用
    respond
    以进行渐进式更新
  • 分页使用基于游标导航;将上一次响应中的
    cursor
    传入下一次调用
  • 验证是Stacks L2操作——写操作后使用
    stx get-transaction-status
    检查交易状态