Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read properties of undefined (reading 'accountId') #2102

Closed
svetoslav-nikol0v opened this issue Jan 26, 2024 · 0 comments · Fixed by #2103
Closed

Cannot read properties of undefined (reading 'accountId') #2102

svetoslav-nikol0v opened this issue Jan 26, 2024 · 0 comments · Fixed by #2103
Assignees
Labels
bug Something isn't working
Projects
Milestone

Comments

@svetoslav-nikol0v
Copy link
Contributor

svetoslav-nikol0v commented Jan 26, 2024

Description

When I try to set proxies for the network I get the following error Cannot read properties of undefined (reading 'accountId')

Steps to reproduce

  1. Set proxies in that way how it's described in the example
  2. Execute the example and get the receipt of transaction

Example:

import { Client, AccountId, PrivateKey, Hbar, TransferTransaction} from "@hashgraph/sdk"
import dotenv from 'dotenv'

dotenv.config();

const main = async () => {
    const nodes = {
        "34.94.106.61:50211": new AccountId(3),
        "50.18.132.211:50211": new AccountId(3),
        "35.237.119.55:50211": new AccountId(4),
        "3.212.6.13:50211": new AccountId(4),
        "35.245.27.193:50211": new AccountId(5),
        "52.20.18.86:50211": new AccountId(5),
    };

    const originAccountId = AccountId.fromString(process.env.OPERATOR_ID);
    const privateKey = PrivateKey.fromStringED25519(process.env.OPERATOR_KEY);
    const targetAccountId = AccountId.fromString(process.env.TARGET_ID);

    const client = Client.forNetwork(nodes)
    client.setOperator(originAccountId, privateKey);

    const validHbar = (hbars) => {
        return typeof hbars == "number"
        ? new Hbar(hbars.toFixed(6))
        : new Hbar(Number(hbars).toFixed(6));
    };

    const hbarAmount = validHbar(2);
    const txResponse = new TransferTransaction()
        .setMaxTransactionFee(new Hbar(5))
        .addHbarTransfer(originAccountId, hbarAmount.negated())
        .addHbarTransfer(targetAccountId, hbarAmount)
        .freezeWith(client);
    console.log("executing transaction...");
    const txSubmit = await txResponse.execute(client);
    const receipt = await txSubmit.getReceipt(client);
    console.log("Receipt:", receipt);
    client.close()
};

main();

Additional context

No response

Hedera network

testnet

Version

v2.40.0

Operating system

None

@svetoslav-nikol0v svetoslav-nikol0v added the bug Something isn't working label Jan 26, 2024
@svetoslav-nikol0v svetoslav-nikol0v self-assigned this Jan 26, 2024
@svetoslav-nikol0v svetoslav-nikol0v added this to the 2.41.0 milestone Jan 26, 2024
svetoslav-nikol0v added a commit that referenced this issue Jan 30, 2024
)

* add a node to the selected nodes if only it hasn't been added already

Signed-off-by: svetoslav-nikol0v <svetoslav.nikolov@limechain.tech>

* remove creating function within loops

Signed-off-by: svetoslav-nikol0v <svetoslav.nikolov@limechain.tech>

* refactor code

Signed-off-by: svetoslav-nikol0v <svetoslav.nikolov@limechain.tech>

* fix

Signed-off-by: svetoslav-nikol0v <svetoslav.nikolov@limechain.tech>

* adding logger

Signed-off-by: svetoslav-nikol0v <svetoslav.nikolov@limechain.tech>

* formatting

Signed-off-by: svetoslav-nikol0v <svetoslav.nikolov@limechain.tech>

---------

Signed-off-by: svetoslav-nikol0v <svetoslav.nikolov@limechain.tech>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Issue Board
Awaiting triage
Development

Successfully merging a pull request may close this issue.

1 participant