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:


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 you have read our privacy policy.

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