js-stellar-sdk: Docs unclear, error when creating an account
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' }
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 15 (3 by maintainers)
Commits related to this issue
- Merge pull request #435 from morleyzhi/mz-createaccount Rewrite the JS examples for creating an account with await so people can paste all the code into a console and run it without having to deal wi... — committed to stellar-deprecated/docs by morleyzhi 5 years ago
- API for directly adding signatures to transactions (#161) - Add `Transaction.prototype.addSignature(publicKey: string, signature: string)` and `Transaction.prototype.getKeypairSIgnature(keypair: Keyp... — committed to stellar/js-stellar-base by morleyzhi 5 years ago
@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:
Is that a friendbot for testnet?
I fixed friendbot URL in https://github.com/stellar/docs/commit/bdb8ea791ce060522b40c05301dfc1377bee8773 (changes will be visible at stellar.org/developers in no more than 30 minutes from now).