2

I wish to create an account on a private stellar network. The network was created using this docker image https://github.com/stellar/docker-stellar-core-horizon, with the --standalone flag.

When I attempt to create a network in the following way I receive the error Network.current(...).networkId is not a function.

The SDK is connected to the network and I am able to get the network information using StellarSdk.Network.current().

stellarServer
  .loadAccount(sourceKey.publicKey())
  .then(sourceAccount => {
    transaction = new StellarSdk.TransactionBuilder(sourceAccount)
      .addOperation(
        StellarSdk.Operation.createAccount({
          destination: dest,
          startingBalance: "100"
        })
      )
      .build();
    transaction.sign(sourceKey);
    return stellarServer.submitTransaction(transaction);
  })
  .then(result => {
    console.log("success" + JSON.stringify(result, undefined, 2));
  })
  .catch(error => {
    console.log("error" + error);
  });
2

You need to choose your private network first.

StellarSdk.Network.use(new StellarSdk.Network('your_private_network_passphrase_here'))

Then create an instance of StellarSdk.Server using the link to your local Horizon server.

let stellarServer = new StellarSdk.Server('http://{horizon_instance_address}:{horizon_port}')

And after that you can proceed with your code.

  • Thank you. My error was not initiating a new StellarSdk.Network but rather simply using the passphrase after `StellarSdk.Network.use("passphrase") – Mahmoud Khraisha Oct 3 '18 at 15:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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