Hedera Hashgraph Local Node AccountCreateTransaction 错误

Hedera Hashgraph Local Node AccountCreateTransaction Error

提问人:Drew 提问时间:11/1/2023 最后编辑:Drew 更新时间:11/3/2023 访问量:36

问:

我目前正在尝试按照 https://docs.hedera.com/hedera/sdks-and-apis/sdks/set-up-your-local-network 中的步骤设置我的本地网络。

我有代码:

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 transsaction 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 步骤的失败:

/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)

我尝试直接复制和粘贴在 hedera 站点上找到的代码,即使这样在我的终端中也会返回相同的错误。我在我的 docker 桌面上运行了 hedera-local-node 集群,启动它没有问题。控制台在错误之前返回“success”,指示函数工作正常。client.setOperator

我尝试直接从具有给定private_key和account_id的站点复制和粘贴代码。返回相同的错误。我也尝试过,然后用npm重新安装,但没有成功。我期望不会返回任何内容并且事务会完成,因此我可以通过检查本地镜像端点 URL 来确认。rm -rf node_moduleshttp://localhost:5551/api/v1/transactions

编辑最终解决了,事实证明我需要在 Docker 上扩展我的 RAM


javascript blockchain tostring private-key hedera-hashgraph

评论


答: 暂无答案