Could not connect to stellar testnet using stellar testnet url
Could not connect to stellar testnet using stellar testnet url
Loading saved threads...
Ashwin · External communityPost link
External question — Stellar Stack Exchange
Author: Ashwin
Original post: https://stellar.stackexchange.com/questions/4441
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
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?
Quote
Report
MetaZebre · External communityPost link
External answer — Stellar Stack Exchange
Author: MetaZebre
Original post: https://stellar.stackexchange.com/a/4465
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
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);
}
}
createTestAccount('GA22MG3BXFBEWMEMUDIRZOTUQNRVNJJZON2G33ZRYOML3PI5OMYSCHAD');
Hope that helps.
Quote
Report
Post Reply
Quoted from Forex.com.bd-Editorial External question — Stellar Stack Exchange Author: Ashwin Source score (net votes, not local likes): 0 Original post: https://stellar.stackexchange.com/questions/4441 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. 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?
Checking account access…