On the Stellar development guides it states that using the following code, you can achieve the following:

To create a test account, send Friendbot the public key you created. It’ll create and fund a new account using that public key as the account ID.

var request = require('request');
  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);

However it states that the SDK does not have tools for creating test accounts, so I would have to make my own HTTP request.

How do I use this code to do this? For the previous code block on that page to create an account I used node.js but now I have to use a HTTP request? Could anyone help me please.

I have tried using curl "https://horizon-testnet.stellar.org/friendbot?addr=<your-public-key>" in my terminal.

3 Answers 3


In browser you can use Fetch API for this purpose:

  • How do I use this? Do I put it in my JavaScript file and then just run the file with node in the terminal? (Sorry, I am a student, still learning)
    – cloe
    Mar 9, 2018 at 12:37
  • 1
    You asked about the browser-based solution, here it is. Execute it from browser console, or include it in the JS file, attached to your web page.
    – Orbit Lens
    Mar 9, 2018 at 13:08

Your code is missing to set Keypair before send to friendbot.

var StellarSdk = require('stellar-sdk');

var pair = StellarSdk.Keypair.random();
console.log('secret => '+pair.secret());
console.log('public => '+new_addr);

Just to clarify the OPs concern,

You can use any Ajax/HTTP call library from browser/console/server to get the account funded


And yes, curl will work on server side

Your Answer

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

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