Trying to start here;
https://www.stellar.org/developers/guides/get-started/create-account.html
Executing this code;
var request = require('request');
console.log("Create account");
request.get({
url: 'https://horizon-testnet.stellar.org/friendbot',
qs: { addr: publicKey },
json: true
}, function(error, response, body) {
console.log("Create account responded");
if (error || response.statusCode !== 200) {
console.error('ERROR!', error || body);
}
else {
console.log('SUCCESS! You have a new account ?\n', body);
}
});
I get;
Create account responded
ERROR! { type: 'https://stellar.org/horizon-errors/transaction_failed',
title: 'Transaction Failed',
status: 400,
detail: 'The transaction failed when submitted to the stellar network. The ex
tras.result_codes
field on this response contains further details. Description
s of each code can be found at: https://www.stellar.org/developers/learn/concept
s/list-of-operations.html',
instance: 'horizon-testnet-002/VRoRpxkVLt-105555',
extras:
{ envelope_xdr: 'AAAAAGXNhLrhGtltTwCpmqlarh7s1DB2hIkbP//jgzn4Fos/AAAAZAAACT0A
AJgmAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAMJ3LZEovKG4qg68LSSJrymqcXI6hID2Jtnp+wIufnZsA
AAAXSHboAAAAAAAAAAAB+BaLPwAAAEBAF1NpbU4VAH8549n7QkDOe7sRRV0JA35lERX85QlsXmmjG+zX
dnsm5khLDPEzXZNLBLVnOWpvkGvtYolfcuUI',
result_codes: { transaction: 'tx_bad_seq' },
result_xdr: 'AAAAAAAAAAD////7AAAAAA==' } }
Any suggestions? I couldn't find TX_BAD_SEQ at https://www.stellar.org/developers/learn/concepts/list-of-operations.html
EDIT:
Found a different set of instructions here https://github.com/stellar/js-stellar-sdk/blob/master/docs/reference/api/friendbot.md
So I tried
var StellarSdk = require('stellar-sdk');
var server = new StellarSdk.Server('https://horizon-testnet.stellar.org');
var pair = StellarSdk.Keypair.random();
var new_address = pair.accountId()
server.friendbot(new_address)
.then(function(resp) {
console.log(resp);
})
.catch(function(err) {
console.log(err);
});
It failed with
var new_address = pair.accountId()
^
TypeError: pair.accountId is not a function