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.

Issue with friendbot

See original GitHub issue

Trying to create testnet accounts with the server.friendbot method but I’m getting a type error with the .then .catch promise. Unsure as to why.

export function createAccount() {
  const pair = Stellar.Keypair.random();
  const publicKey = pair.publicKey();

  return new Promise((resolve, reject) => {
    Server
    .friendbot(publicKey) 
    .then(() => resolve(pair.secret()))
    .catch((err) => reject(err));
  });
}

screen shot 2017-12-27 at 6 19 26 pm

It would seem that something is up with the way you’re processing promises for the friendbot method.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
tyvdhcommented, Dec 28, 2017

Tada! Should have known that. Thanks!

I am however often getting this error…

{ NetworkError: 400
    (No stack trace)
From previous event:
    at FriendbotBuilder._sendNormalRequest (/Users/Tyler/Desktop/Web/Colorglyph/colorglyph-meteor/node_modules/stellar-sdk/lib/call_builder.js:216:16)
    at FriendbotBuilder.call (/Users/Tyler/Desktop/Web/Colorglyph/colorglyph-meteor/node_modules/stellar-sdk/lib/call_builder.js:76:21)
    at Promise (server/stellar.js:43:6)
From previous event:
    at createAccount (server/stellar.js:40:10)
    at Meteor.startup (server/stellar.js:17:3)
    at Function.time (/Users/Tyler/Desktop/Web/Colorglyph/colorglyph-meteor/.meteor/local/build/programs/server/profile.js:309:28)
    at /Users/Tyler/Desktop/Web/Colorglyph/colorglyph-meteor/.meteor/local/build/programs/server/boot.js:423:13
    at /Users/Tyler/Desktop/Web/Colorglyph/colorglyph-meteor/.meteor/local/build/programs/server/boot.js:464:5
    at Function.run (/Users/Tyler/Desktop/Web/Colorglyph/colorglyph-meteor/.meteor/local/build/programs/server/profile.js:510:12)
    at /Users/Tyler/Desktop/Web/Colorglyph/colorglyph-meteor/.meteor/local/build/programs/server/boot.js:462:11
  name: 'NetworkError',
  message: 400,
  data: 
   { status: 400,
     statusText: 'Bad Request',
     headers: 
      { 'content-type': 'application/problem+json; charset=utf-8',
        date: 'Thu, 28 Dec 2017 12:12:26 GMT',
        vary: 'Origin',
        'x-ratelimit-limit': '18000',
        'x-ratelimit-remaining': '17997',
        'x-ratelimit-reset': '3165',
        'content-length': '852',
        connection: 'Close' },
     config: 
      { transformRequest: [Object],
        transformResponse: [Object],
        headers: [Object],
        timeout: 0,
        xsrfCookieName: 'XSRF-TOKEN',
        xsrfHeaderName: 'X-XSRF-TOKEN',
        maxContentLength: -1,
        validateStatus: [Function: validateStatus],
        method: 'get',
        url: 'https://horizon-testnet.stellar.org/friendbot?addr=GAKM5SS6VE3WM73AEOB6SH3YZX4RDV33ULQIZB437Y4FMLKH4PLXHS3J&c=0.3651907871814051',
        withCredentials: undefined,
        data: undefined },
     request: 
      ClientRequest {
        domain: null,
        _events: [Object],
        _eventsCount: 2,
        _maxListeners: undefined,
        output: [],
        outputEncodings: [],
        outputCallbacks: [],
        outputSize: 0,
        writable: true,
        _last: true,
        upgrading: false,
        chunkedEncoding: false,
        shouldKeepAlive: false,
        useChunkedEncodingByDefault: false,
        sendDate: false,
        _removedConnection: false,
        _removedContLen: false,
        _removedTE: false,
        _contentLength: 0,
        _hasBody: true,
        _trailer: '',
        finished: true,
        _headerSent: true,
        socket: [Object],
        connection: [Object],
        _header: 'GET /friendbot?addr=GAKM5SS6VE3WM73AEOB6SH3YZX4RDV33ULQIZB437Y4FMLKH4PLXHS3J&c=0.3651907871814051 HTTP/1.1\r\nAccept: application/json, text/plain, */*\r\nUser-Agent: axios/0.12.0\r\nHost: horizon-testnet.stellar.org\r\nConnection: close\r\n\r\n',
        _onPendingData: [Function: noopPendingOutput],
        agent: [Object],
        socketPath: undefined,
        timeout: undefined,
        method: 'GET',
        path: '/friendbot?addr=GAKM5SS6VE3WM73AEOB6SH3YZX4RDV33ULQIZB437Y4FMLKH4PLXHS3J&c=0.3651907871814051',
        _ended: true,
        res: [Object],
        aborted: undefined,
        timeoutCb: null,
        upgradeOrConnect: false,
        parser: null,
        maxHeadersCount: null,
        [Symbol(outHeadersKey)]: [Object] },
     data: 
      { type: 'https://stellar.org/horizon-errors/transaction_failed',
        title: 'Transaction Failed',
        status: 400,
        detail: 'The transaction failed when submitted to the stellar network. The `extras.result_codes` field on this response contains further details.  Descriptions of each code can be found at: https://www.stellar.org/developers/learn/concepts/list-of-operations.html',
        instance: 'horizon-testnet-002/ZAQo8xQ6e1-8019487',
        extras: [Object] } } }

But that’s a different issue so I’ll open a separate ticket unless you’ve got some insights as to why that’s happening for me.

1reaction
bartekncommented, Dec 28, 2017

What about:

Server
    .friendbot(publicKey)
    .call()
    .then(() => resolve(pair.secret()))
    .catch((err) => reject(err));

friendbot returns FriendbotBuilder object that extends CallBuilder.

Read more comments on GitHub >

github_iconTop Results From Across the Web

The rise of the friendbot by Darlene Ramilla - Prezi
The Rise of the Friendbot. -is a type of S&T issue that takes grieving into a whole new form in the 21st century....
Read more >
friendbot ethical dilemma 01... - Course Hero
Is a dynamic problem between two potentially good objectives, either not definitely worthy or best. The diverse nature comes out of a struggle...
Read more >
FriendBot is not working · Issue #1591 · stellar/go - GitHub
I test with several accounts but all failed and showed the following error. { "type": "https://stellar.org/horizon-errors/server_error", ...
Read more >
FriendBot | Sonic News Network - Fandom
FriendBot, formerly known as FiendBot, is a character that appears in the Sonic Boom series. He is a robot created by Dr. Eggman...
Read more >
FRIENDBOT | PDF - Scribd
FRIENDBOT - View presentation slides online. ... Friendbot iss one of the science, technology and ... the moral and ethical issue helps us...
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