Hi have setup a private network. Now how do I create the first account so I can start using the network? I have tried the following:
const Stellar = require('stellar-sdk')
const NETWORK_PASSPHRASE = "TEST Stellar Network ; June 2020";
var server = new Stellar.Server('http://localhost:8000', {allowHttp: true});
let sourceKeys = Stellar.Keypair.master(NETWORK_PASSPHRASE);
console.log("sourceKeys Public key : ", sourceKeys.publicKey());
console.log("sourceKeys Secret : ", sourceKeys.secret());
try{
const pk = "GAABRIRAI3QHVSGAPWNFMOMWEMG7ATCQGRO2B4F72WYKVR46JYEWSOLF"
let sourceKeys = Stellar.Keypair.master(NETWORK_PASSPHRASE);
server.loadAccount(sourceKeys.publicKey())
.then(function(sourceAccount) {
let txn = new Stellar.TransactionBuilder(sourceAccount, opts={fee: 1, networkPassphrase: NETWORK_PASSPHRASE})
.addOperation(
Stellar.Operation.createAccount({
destination: pk,
startingBalance: "100"}))
.addMemo(Stellar.Memo.text('Test Transaction'))
.setTimeout(5)
.build();
txn.sign(sourceKeys);
return server.submitTransaction(txn);
})
.then(function(result) {
console.log(JSON.stringify(result))
})
.catch(function(error) {
console.error('Something went wrong!', error);
});
}catch(err){
console.error("ERROR :", error)
}
but I keep getting the following error:
Error: Request failed with status code 400
at createError (C:\dev\stellar\stellar-wallet\node_modules\axios\lib\core\createError.js:16:15)
at settle (C:\dev\stellar\stellar-wallet\node_modules\axios\lib\core\settle.js:17:12)
at IncomingMessage.handleStreamEnd (C:\dev\stellar\stellar-wallet\node_modules\axios\lib\adapters\http.js:236:11)
at IncomingMessage.emit (events.js:203:15)
at endReadableNT (_stream_readable.js:1145:12)
at process._tickCallback (internal/process/next_tick.js:63:19)
UPDATE 1
I have tried to use GO client and it is posting the transaction (I can see the transaction on horizon) but it is returning an error:
strconv.ParseInt: parsing "": invalid syntax
I personally think that there is a bug on the GO client library for horizon, since for some reason it is failing to parse the field "fee_charged".
Any help would be appreciated