query
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseQuery Skill
Query Skill
Provides Stacks network and blockchain query operations using the Hiro API. No wallet required for most queries; and fall back to the active wallet address if no address is provided.
get-account-infoget-account-transactions通过Hiro API提供Stacks网络与区块链查询操作。大多数查询无需钱包;若未提供地址,和会默认使用当前活跃钱包地址。
get-account-infoget-account-transactionsUsage
使用方法
bun run query/query.ts <subcommand> [options]bun run query/query.ts <subcommand> [options]Subcommands
子命令
get-stx-fees
get-stx-fees
Get current STX fee estimates for different priority levels.
bun run query/query.ts get-stx-feesOutput:
json
{
"network": "mainnet",
"fees": {
"low": { "microStx": 1000, "stx": "0.001 STX", "description": "Lower fee, may take longer to confirm" },
"medium": { "microStx": 2500, "stx": "0.0025 STX", "description": "Standard fee, typical confirmation time" },
"high": { "microStx": 5000, "stx": "0.005 STX", "description": "Higher fee, faster confirmation" }
},
"byTransactionType": {
"tokenTransfer": { "low": 1000, "medium": 2500, "high": 5000 },
"contractCall": { "low": 1500, "medium": 3000, "high": 6000 },
"smartContract": { "low": 2000, "medium": 4000, "high": 8000 }
},
"unit": "micro-STX",
"note": "1 STX = 1,000,000 micro-STX. Fees are estimates based on current mempool conditions."
}获取不同优先级的当前STX手续费预估。
bun run query/query.ts get-stx-fees输出:
json
{
"network": "mainnet",
"fees": {
"low": { "microStx": 1000, "stx": "0.001 STX", "description": "Lower fee, may take longer to confirm" },
"medium": { "microStx": 2500, "stx": "0.0025 STX", "description": "Standard fee, typical confirmation time" },
"high": { "microStx": 5000, "stx": "0.005 STX", "description": "Higher fee, faster confirmation" }
},
"byTransactionType": {
"tokenTransfer": { "low": 1000, "medium": 2500, "high": 5000 },
"contractCall": { "low": 1500, "medium": 3000, "high": 6000 },
"smartContract": { "low": 2000, "medium": 4000, "high": 8000 }
},
"unit": "micro-STX",
"note": "1 STX = 1,000,000 micro-STX. Fees are estimates based on current mempool conditions."
}get-account-info
get-account-info
Get account information including nonce and STX balance.
bun run query/query.ts get-account-info [--address <stxAddress>]Options:
- (optional) — Stacks address to check (uses active wallet if omitted)
--address
Output:
json
{
"address": "SP...",
"network": "mainnet",
"nonce": 42,
"balance": { "microStx": "1000000000", "stx": "1000 STX" },
"explorerUrl": "https://explorer.hiro.so/address/SP...?chain=mainnet"
}获取账户信息,包括随机数(nonce)和STX余额。
bun run query/query.ts get-account-info [--address <stxAddress>]选项:
- (可选)—— 要查询的Stacks地址(若省略则使用当前活跃钱包)
--address
输出:
json
{
"address": "SP...",
"network": "mainnet",
"nonce": 42,
"balance": { "microStx": "1000000000", "stx": "1000 STX" },
"explorerUrl": "https://explorer.hiro.so/address/SP...?chain=mainnet"
}get-account-transactions
get-account-transactions
Get transaction history for a Stacks account.
bun run query/query.ts get-account-transactions [--address <stxAddress>] [--limit 20] [--offset 0]Options:
- (optional) — Stacks address (uses active wallet if omitted)
--address - (optional) — Maximum results (default: 20)
--limit - (optional) — Pagination offset (default: 0)
--offset
Output:
json
{
"address": "SP...",
"network": "mainnet",
"total": 150,
"limit": 20,
"offset": 0,
"transactions": [
{
"txId": "0x...",
"type": "token_transfer",
"status": "success",
"sender": "SP...",
"blockHeight": 145000,
"fee": "1000",
"explorerUrl": "https://explorer.hiro.so/txid/0x...?chain=mainnet"
}
],
"explorerUrl": "https://explorer.hiro.so/address/SP...?chain=mainnet"
}获取Stacks账户的交易历史。
bun run query/query.ts get-account-transactions [--address <stxAddress>] [--limit 20] [--offset 0]选项:
- (可选)—— Stacks地址(若省略则使用当前活跃钱包)
--address - (可选)—— 最大结果数(默认:20)
--limit - (可选)—— 分页偏移量(默认:0)
--offset
输出:
json
{
"address": "SP...",
"network": "mainnet",
"total": 150,
"limit": 20,
"offset": 0,
"transactions": [
{
"txId": "0x...",
"type": "token_transfer",
"status": "success",
"sender": "SP...",
"blockHeight": 145000,
"fee": "1000",
"explorerUrl": "https://explorer.hiro.so/txid/0x...?chain=mainnet"
}
],
"explorerUrl": "https://explorer.hiro.so/address/SP...?chain=mainnet"
}get-block-info
get-block-info
Get information about a specific Stacks block.
bun run query/query.ts get-block-info --height-or-hash <value>Options:
- (required) — Block height (integer) or block hash (0x-prefixed)
--height-or-hash
Output:
json
{
"network": "mainnet",
"hash": "0x...",
"height": 145000,
"canonical": true,
"burnBlockHeight": 840000,
"burnBlockTime": 1700000000,
"burnBlockTimeIso": "2024-01-01T00:00:00.000Z",
"txCount": 12,
"txIds": ["0x..."]
}获取特定Stacks区块的信息。
bun run query/query.ts get-block-info --height-or-hash <value>选项:
- (必填)—— 区块高度(整数)或区块哈希(以0x开头)
--height-or-hash
输出:
json
{
"network": "mainnet",
"hash": "0x...",
"height": 145000,
"canonical": true,
"burnBlockHeight": 840000,
"burnBlockTime": 1700000000,
"burnBlockTimeIso": "2024-01-01T00:00:00.000Z",
"txCount": 12,
"txIds": ["0x..."]
}get-mempool-info
get-mempool-info
Get pending transactions in the Stacks mempool.
bun run query/query.ts get-mempool-info [--sender-address <addr>] [--limit 20] [--offset 0]Options:
- (optional) — Filter by sender address
--sender-address - (optional) — Maximum results (default: 20)
--limit - (optional) — Pagination offset (default: 0)
--offset
Output:
json
{
"network": "mainnet",
"total": 5,
"limit": 20,
"offset": 0,
"transactions": [
{
"txId": "0x...",
"type": "contract_call",
"sender": "SP...",
"fee": "2500",
"nonce": 43,
"receiptTime": "2024-01-01T00:00:00.000Z",
"explorerUrl": "https://explorer.hiro.so/txid/0x...?chain=mainnet"
}
]
}获取Stacks内存池中的待处理交易。
bun run query/query.ts get-mempool-info [--sender-address <addr>] [--limit 20] [--offset 0]选项:
- (可选)—— 按发送者地址过滤
--sender-address - (可选)—— 最大结果数(默认:20)
--limit - (可选)—— 分页偏移量(默认:0)
--offset
输出:
json
{
"network": "mainnet",
"total": 5,
"limit": 20,
"offset": 0,
"transactions": [
{
"txId": "0x...",
"type": "contract_call",
"sender": "SP...",
"fee": "2500",
"nonce": 43,
"receiptTime": "2024-01-01T00:00:00.000Z",
"explorerUrl": "https://explorer.hiro.so/txid/0x...?chain=mainnet"
}
]
}get-contract-info
get-contract-info
Get information about a smart contract including its ABI.
bun run query/query.ts get-contract-info --contract-id <address.contract-name>Options:
- (required) — Contract ID in format
--contract-idaddress.contract-name
Output:
json
{
"contractId": "SP...contract-name",
"network": "mainnet",
"txId": "0x...",
"blockHeight": 140000,
"functions": [
{ "name": "transfer", "access": "public", "args": [...], "outputs": {...} }
],
"variables": [...],
"maps": [...],
"fungibleTokens": [...],
"nonFungibleTokens": [...],
"explorerUrl": "https://explorer.hiro.so/txid/SP...contract-name?chain=mainnet"
}获取智能合约的信息,包括其ABI。
bun run query/query.ts get-contract-info --contract-id <address.contract-name>选项:
- (必填)—— 合约ID,格式为
--contract-idaddress.contract-name
输出:
json
{
"contractId": "SP...contract-name",
"network": "mainnet",
"txId": "0x...",
"blockHeight": 140000,
"functions": [
{ "name": "transfer", "access": "public", "args": [...], "outputs": {...} }
],
"variables": [...],
"maps": [...],
"fungibleTokens": [...],
"nonFungibleTokens": [...],
"explorerUrl": "https://explorer.hiro.so/txid/SP...contract-name?chain=mainnet"
}get-contract-events
get-contract-events
Get events emitted by a smart contract.
bun run query/query.ts get-contract-events --contract-id <address.contract-name> [--limit 20] [--offset 0]Options:
- (required) — Contract ID in format
--contract-idaddress.contract-name - (optional) — Maximum results (default: 20)
--limit - (optional) — Pagination offset (default: 0)
--offset
Output:
json
{
"contractId": "SP...contract-name",
"network": "mainnet",
"limit": 20,
"offset": 0,
"events": [...],
"explorerUrl": "https://explorer.hiro.so/txid/SP...contract-name?chain=mainnet"
}获取智能合约触发的事件。
bun run query/query.ts get-contract-events --contract-id <address.contract-name> [--limit 20] [--offset 0]选项:
- (必填)—— 合约ID,格式为
--contract-idaddress.contract-name - (可选)—— 最大结果数(默认:20)
--limit - (可选)—— 分页偏移量(默认:0)
--offset
输出:
json
{
"contractId": "SP...contract-name",
"network": "mainnet",
"limit": 20,
"offset": 0,
"events": [...],
"explorerUrl": "https://explorer.hiro.so/txid/SP...contract-name?chain=mainnet"
}get-network-status
get-network-status
Get the current status of the Stacks network.
bun run query/query.ts get-network-statusOutput:
json
{
"network": "mainnet",
"serverVersion": "stacks-node 2.4.0.0.0",
"status": "ready",
"chainTip": { "block_height": 145000, "block_hash": "0x..." },
"coreInfo": {
"peerVersion": 4026533888,
"stacksTipHeight": 145000,
"burnBlockHeight": 840000,
"networkId": 1
}
}获取Stacks网络的当前状态。
bun run query/query.ts get-network-status输出:
json
{
"network": "mainnet",
"serverVersion": "stacks-node 2.4.0.0.0",
"status": "ready",
"chainTip": { "block_height": 145000, "block_hash": "0x..." },
"coreInfo": {
"peerVersion": 4026533888,
"stacksTipHeight": 145000,
"burnBlockHeight": 840000,
"networkId": 1
}
}call-read-only
call-read-only
Call a read-only function on a smart contract.
bun run query/query.ts call-read-only --contract-id <id> --function-name <name> [--args <json>] [--sender <address>]Options:
- (required) — Contract ID in format
--contract-idaddress.contract-name - (required) — Name of the read-only function
--function-name - (optional) — JSON array of hex-encoded Clarity values (default:
--args)[] - (optional) — Sender address (uses active wallet or contract address if omitted)
--sender
The option accepts a JSON array of hex-encoded Clarity values. Use to encode values. For example, serialized as hex would be .
--args@stacks/transactionsuintCV(1)"0100000000000000000000000000000001"Output:
json
{
"contractId": "SP...contract-name",
"functionName": "get-balance",
"network": "mainnet",
"okay": true,
"result": "0x0100000000000000000000000000000064",
"cause": null
}调用智能合约上的只读函数。
bun run query/query.ts call-read-only --contract-id <id> --function-name <name> [--args <json>] [--sender <address>]选项:
- (必填)—— 合约ID,格式为
--contract-idaddress.contract-name - (必填)—— 只读函数名称
--function-name - (可选)—— 十六进制编码的Clarity值组成的JSON数组(默认:
--args)[] - (可选)—— 发送者地址(若省略则使用当前活跃钱包或合约地址)
--sender
--args@stacks/transactionsuintCV(1)"0100000000000000000000000000000001"输出:
json
{
"contractId": "SP...contract-name",
"functionName": "get-balance",
"network": "mainnet",
"okay": true,
"result": "0x0100000000000000000000000000000064",
"cause": null
}Notes
注意事项
- All queries use the Hiro API (or
api.mainnet.hiro.so)api.testnet.hiro.so - Network is controlled by the environment variable (default: testnet)
NETWORK - and
get-account-infofall back to the active wallet addressget-account-transactions - falls back to the contract's own address as sender if no wallet is active
call-read-only
- 所有查询均使用Hiro API(或
api.mainnet.hiro.so)api.testnet.hiro.so - 网络由环境变量控制(默认:testnet)
NETWORK - 和
get-account-info会默认使用当前活跃钱包地址get-account-transactions - 若当前无活跃钱包,会默认使用合约自身地址作为发送者
call-read-only