question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Docs unclear, error when creating an account

See original GitHub issue

I got an error from the very beginning. The code snippets in your “Create an Account” is very unclear.

Are they supposed to be inside a single or a separate files? (i pasted everything into one file) Are they run from the browser or via Terminal? (i run it using Node from Terminal)

Anyway, here’s the response that i get:

Unhandled rejection NotFoundError: [object Object]

SUCCESS! You have a new account :)
 { _links:
   { transaction:
      { href: 'https://horizon-testnet.stellar.org/transactions/4e3212bd9b1624fe501a0adc37126aafb785888fd45de3a52eb38cdbba1603d4' } },
  hash: '4e3212bd9b1624fe501a0adc37126aafb785888fd45de3a52eb38cdbba1603d4',
  ledger: 6182957,
  envelope_xdr: 'AAAAAGXNhLrhGtltTwCpmqlarh7s1DB2hIkbP//jgzn4Fos/AAAAZAAACT0AAMVDAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAD21ktzSjDM/q/1kSQANbZyD7gQDKEA0aSgM90zbk/uwAAAAXSHboAAAAAAAAAAAB+BaLPwAAAEBM2wZbgLDXe7NdKTGvHHiRGhnNsQ5F2d7TJK5scwTo69OMGWxR0K6K2kXnmWgRxLgMLaLLRRnxzIlxcT1907wO',
  result_xdr: 'AAAAAAAAAGQAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAA=',
  result_meta_xdr: 'AAAAAAAAAAEAAAADAAAAAABeWC0AAAAAAAAAAA9tZLc0owzP6v9ZEkADW2cg+4EAyhANGkoDPdM25P7sAAAAF0h26AAAXlgtAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAwBeWC0AAAAAAAAAAGXNhLrhGtltTwCpmqlarh7s1DB2hIkbP//jgzn4Fos/AAJ6s4+6ejQAAAk9AADFQwAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAQBeWC0AAAAAAAAAAGXNhLrhGtltTwCpmqlarh7s1DB2hIkbP//jgzn4Fos/AAJ6nEdDkjQAAAk9AADFQwAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAA' }

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:15 (3 by maintainers)

github_iconTop GitHub Comments

5reactions
therealsanmahcommented, Jan 31, 2018

@rizkysyazuli - Agree, the docs in the page aren’t super clear. You can put all of them into a single file like you have seem to done. There is one caveat though.

The second and third snippets are both asynchronous. The second snippet makes an API call to fund an account (and activate it), and only after that is successful, should you be executing the third snippet to get the account details.

In your case, since you’ve pasted all the snippets as they are, in order, your third snippet is executed even before the api call in the second snippet returns. So, it is not able to find the account details you’re looking for and that fails with a NotFoundError. Since this is also a promise, and it doesn’t have the catch block you see the error Unhandled rejection NotFoundError: [object Object].

This is the correct way to use the snippets from the documentation:

// create a completely new and unique pair of keys
// see more about KeyPair objects: https://stellar.github.io/js-stellar-sdk/Keypair.html
var StellarSdk = require('stellar-sdk')
var pair = StellarSdk.Keypair.random();
pair.secret();
// SAV76USXIJOBMEQXPANUOQM6F5LIOTLPDIDVRJBFFE2MDJXG24TAPUU7
pair.publicKey();
// GCFXHS4GXL6BVUCXBWXGTITROWLVYXQKQLF4YH5O5JT3YZXCYPAFBJZB

var request = require('request');
request.get({
  url: 'https://horizon-testnet.stellar.org/friendbot',
  qs: { addr: pair.publicKey() },
  json: true
}, function (error, response, body) {
  if (error || response.statusCode !== 200) {
    console.error('ERROR!', error || body);
  }
  else {
    console.log('SUCCESS! You have a new account :)\n', body);

    var server = new StellarSdk.Server('https://horizon-testnet.stellar.org');
    // the JS SDK uses promises for most actions, such as retrieving an account
    server.loadAccount(pair.publicKey()).then(function (account) {
      console.log('Balances for account: ' + pair.publicKey());
      account.balances.forEach(function (balance) {
        console.log('Type:', balance.asset_type, ', Balance:', balance.balance);
      });
    }).catch(function (err) {
      console.error(err);
    });
  }
});

1reaction
maxpaynestorycommented, Mar 20, 2018

Is that a friendbot for testnet?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Security update for Google Drive
On your computer, go to drive.google.com. At the top, type: is:security_update_applied or is:security_update_removed in the search bar. Make security update ...
Read more >
Error Messages: Examples, Best Practices & Common Mistakes
Useful error messages can keep users on your site and increase conversions. See examples and learn the best practices.
Read more >
Troubleshoot uploading your state-issued ID - Login.gov
... try the steps below if you're still getting an error while uploading your state-issued identification. You can make 10 attempts to upload...
Read more >
Troubleshooting common eDiscovery issues - Office 365
An eDiscovery search fails and returns a "recipient not found" error message. This error might occur if the user object cannot be found...
Read more >
Create or update your Adobe account
Learn how to create an Adobe account or change the email address ... If you are unclear about which email address is associated...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found