You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过Hedera镜像节点验证账户是否关联特定代币?

通过Hedera镜像节点验证账户与特定代币的关联状态

核心思路

Hedera镜像节点提供公开的REST API接口,可直接查询账户的代币关联信息,无需通过SDK发起签名交易,适合做只读状态验证。

操作步骤

  1. 选择对应网络的镜像节点API端点

    • 主网:https://mainnet-public.mirrornode.hedera.com/api/v1
    • 测试网:https://testnet.mirrornode.hedera.com/api/v1
    • 预览网:https://previewnet.mirrornode.hedera.com/api/v1
  2. 查询账户的所有关联代币
    构造GET请求,将路径中的{account_id}替换为目标账户的ID(格式如0.0.12345):

    curl -X GET "https://testnet.mirrornode.hedera.com/api/v1/accounts/0.0.12345/tokens"
    

    返回的JSON数据会包含该账户所有关联代币的详情,每个条目包含token_id、balance、association_type等字段。

  3. 验证目标代币的关联状态
    遍历返回的tokens数组,检查是否存在目标代币ID:

    • 找到匹配项 → 账户已关联该代币
    • 无匹配项 → 账户未关联该代币
  4. 可选:精准过滤查询
    直接添加查询参数过滤特定代币,减少返回数据量:

    curl -X GET "https://testnet.mirrornode.hedera.com/api/v1/accounts/0.0.12345/tokens?token.id=0.0.67890"
    

    若返回的tokens数组不为空,说明账户已关联目标代币;为空则未关联。

注意事项

  • 镜像节点数据是链上状态的镜像,存在几秒到十几秒的延迟,需确认数据时效性;
  • 必须使用对应网络的镜像节点端点,跨网络查询会返回无效结果;
  • 部分公共镜像节点有请求频率限制,高频查询需遵循平台规则。

内容的提问来源于stack exchange,提问作者Mulders Michiel

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.26 20:55:09