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

Hedera本地节点AccountCreateTransaction超时问题及解决

问题:Hedera本地网络执行AccountCreateTransaction时触发gRPC TIMEOUT错误

环境与代码

按照Hedera官方文档搭建本地网络,使用的Node.js代码如下:

const {
    Client,
    PrivateKey,
    Hbar,
    AccountId,
    AccountCreateTransaction,
} = require("@hashgraph/sdk");
require('dotenv').config();

const myAccountId = process.env.MY_ACCOUNT_ID;
const myPrivateKey = process.env.MY_PRIVATE_KEY;
const myPublicKey = process.env.MY_PUBLIC_KEY;


async function main() {
    console.log("account id is: " + process.env.MY_ACCOUNT_ID);

    const node = {"127.0.0.1:50211": new AccountId(3)};
    const client = Client.forNetwork(node).setMirrorNetwork("127.0.0.1:5600");

    //set the transaction fee paying account
    client.setOperator(myAccountId, myPrivateKey);
    console.log('success');

    console.log(PrivateKey.fromString(myPublicKey));
    const newAccount = await new AccountCreateTransaction()
        .setKey(PrivateKey.fromString(myPublicKey))
        .setInitialBalance(new Hbar(1))
        .execute(client);

     //Get receipt
     const receipt = await newAccount.getReceipt(client);

     //Get the account ID
     const newAccountId = receipt.accountId;
     console.log(newAccountId);
}

void main();

报错信息

执行代码时,在AccountCreateTransaction.execute()步骤持续报错:

/Users/{name}/Desktop/{org_name}/hello-hedera-js-sdk/node_modules/@hashgraph/sdk/lib/Executable.cjs:679
    throw new Error(`max attempts of ${maxAttempts.toString()} was reached for request with last error being: ${persistentError != null ? persistentError.toString() : ""}`);
          ^

Error: max attempts of 10 was reached for request with last error being: GrpcServiceError: gRPC service failed with status: TIMEOUT
    at AccountCreateTransaction.execute (/Users/{name}/Desktop/{org_name}/hello-hedera-js-sdk/node_modules/@hashgraph/sdk/lib/Executable.cjs:679:11)
    at async main (/Users/drew/Desktop/Greensmith/hello-hedera-js-sdk/localtx.js:31:24)

排查过程

  • 已确认Docker上的hedera-local-node集群启动状态正常
  • client.setOperator执行成功,控制台输出success
  • 尝试直接复用官方示例代码、删除并重装node_modules,均无法解决问题

解决方案

最终定位问题根源为Docker内存不足,扩容Docker的可用内存后,问题得到解决。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.07 05:25:01