I tried getting balance of my stellar account after generating key pairs using the following code:

const server = new StellarSdk.Server("https://horizon-testnet.stellar.org");

// the JS SDK uses promises for most actions, such as retrieving an account const account = await server.loadAccount(pair.publicKey()); console.log("Balances for account: " + pair.publicKey()); account.balances.forEach(function (balance) { console.log("Type:", balance.asset_type, ", Balance:", balance.balance); });

The error I'm getting is this: (node:6622) UnhandledPromiseRejectionWarning: NotFoundError: Not Found at NotFoundError.NetworkError [as constructor] (/home/ashwin/stellar/node_modules/stellar-sdk/lib/errors.js:11:24) at new NotFoundError (/home/stellar/node_modules/stellar-sdk/lib/errors.js:29:24) at /home/stellar/node_modules/stellar-sdk/lib/call_builder.js:255:55 at step (/home/stellar/node_modules/tslib/tslib.js:141:27) at Object.next (/home/stellar/node_modules/tslib/tslib.js:122:57) at /home/stellar/node_modules/tslib/tslib.js:115:75 at new Promise () at Object.__awaiter (/home/stellar/node_modules/tslib/tslib.js:111:16) at CallBuilder._handleNetworkError (/home/stellar/node_modules/stellar-sdk/lib/call_builder.js:250:24) at

Why is this error occuring and how can it be resolved?

1 Answer 1


you say you generated your key pair. That's all good, but that does not create the actual account on the Stellar Network.

To actually instantiate the account on the Stellar Network (main or test) you need to send it at least the minimum balance (that is 1 XLM).

If you are on the testnet, you can ask friendbot, a faucet, that will create your address by sending 10 000 XLM to it.

Here is the code I used to create Chad's test account:

const fetch = require('node-fetch');

async function createTestAccount(pubKey) {
    try {
        const response = await fetch('https://friendbot.stellar.org?addr=' + encodeURIComponent(pubKey));
        const responseJSON = await response.json();
        console.log(pubKey.slice(-4) + "'s account created on TestNet:)\n", responseJSON);
    } catch (e) {
        console.error("ERROR!", e);


Hope that helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.